2016-07-25 20:00:28 +00:00
|
|
|
// Package connector defines interfaces for federated identity strategies.
|
|
|
|
package connector
|
|
|
|
|
2016-08-03 04:14:24 +00:00
|
|
|
import "net/http"
|
2016-07-25 20:00:28 +00:00
|
|
|
|
|
|
|
// Connector is a mechanism for federating login to a remote identity service.
|
|
|
|
//
|
|
|
|
// Implementations are expected to implement either the PasswordConnector or
|
|
|
|
// CallbackConnector interface.
|
|
|
|
type Connector interface {
|
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
|
2016-08-03 04:14:24 +00:00
|
|
|
// Identity represents the ID Token claims supported by the server.
|
|
|
|
type Identity struct {
|
|
|
|
UserID string
|
|
|
|
Username string
|
|
|
|
Email string
|
|
|
|
EmailVerified bool
|
|
|
|
|
|
|
|
// ConnectorData holds data used by the connector for subsequent requests after initial
|
|
|
|
// authentication, such as access tokens for upstream provides.
|
|
|
|
//
|
|
|
|
// This data is never shared with end users, OAuth clients, or through the API.
|
|
|
|
ConnectorData []byte
|
|
|
|
}
|
|
|
|
|
2016-07-25 20:00:28 +00:00
|
|
|
// PasswordConnector is an optional interface for password based connectors.
|
|
|
|
type PasswordConnector interface {
|
2016-08-03 04:14:24 +00:00
|
|
|
Login(username, password string) (identity Identity, validPassword bool, err error)
|
2016-07-25 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CallbackConnector is an optional interface for callback based connectors.
|
|
|
|
type CallbackConnector interface {
|
|
|
|
LoginURL(callbackURL, state string) (string, error)
|
2016-08-03 04:14:24 +00:00
|
|
|
HandleCallback(r *http.Request) (identity Identity, state string, err error)
|
2016-07-25 20:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GroupsConnector is an optional interface for connectors which can map a user to groups.
|
|
|
|
type GroupsConnector interface {
|
2016-08-03 04:14:24 +00:00
|
|
|
Groups(identity Identity) ([]string, error)
|
2016-07-25 20:00:28 +00:00
|
|
|
}
|