2015-08-18 05:57:27 +05:30
|
|
|
package connector
|
|
|
|
|
|
|
|
import (
|
2015-12-08 06:49:55 +05:30
|
|
|
"errors"
|
2015-08-18 05:57:27 +05:30
|
|
|
"html/template"
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
|
2015-12-08 06:49:55 +05:30
|
|
|
"github.com/coreos/dex/repo"
|
2015-08-18 05:57:27 +05:30
|
|
|
"github.com/coreos/go-oidc/oidc"
|
|
|
|
"github.com/coreos/pkg/health"
|
|
|
|
)
|
|
|
|
|
2015-12-08 06:49:55 +05:30
|
|
|
var ErrorNotFound = errors.New("connector not found in repository")
|
|
|
|
|
2015-08-18 05:57:27 +05:30
|
|
|
type Connector interface {
|
2015-12-10 04:49:39 +05:30
|
|
|
// ID returns the ID of the ConnectorConfig used to create the Connector.
|
2015-08-18 05:57:27 +05:30
|
|
|
ID() string
|
2015-12-10 04:49:39 +05:30
|
|
|
|
|
|
|
// LoginURL returns the backend's authorization URL for a sessionKey
|
|
|
|
// and OAuth2 prompt type.
|
2015-08-18 05:57:27 +05:30
|
|
|
LoginURL(sessionKey, prompt string) (string, error)
|
2015-12-10 04:49:39 +05:30
|
|
|
|
|
|
|
// Register allows connectors to register a callback handler with the
|
|
|
|
// dex server.
|
|
|
|
//
|
|
|
|
// Connectors should register with a path that extends the namespace
|
|
|
|
// URL provided when the Connector is instantiated.
|
2015-08-18 05:57:27 +05:30
|
|
|
Register(mux *http.ServeMux, errorURL url.URL)
|
|
|
|
|
|
|
|
// Sync triggers any long-running tasks needed to maintain the
|
|
|
|
// Connector's operation. For example, this would encompass
|
|
|
|
// repeatedly caching any remote resources for local use.
|
|
|
|
Sync() chan struct{}
|
|
|
|
|
2015-12-10 04:49:39 +05:30
|
|
|
// TrustedEmailProvider indicates whether or not we can trust that email
|
|
|
|
// claims coming from this provider.
|
2015-08-18 05:57:27 +05:30
|
|
|
TrustedEmailProvider() bool
|
|
|
|
|
|
|
|
health.Checkable
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:generate genconfig -o config.go connector Connector
|
|
|
|
type ConnectorConfig interface {
|
2015-12-10 04:49:39 +05:30
|
|
|
// ConnectorID returns a unique end user facing identifier. For example "google".
|
2015-08-18 05:57:27 +05:30
|
|
|
ConnectorID() string
|
2015-12-10 04:49:39 +05:30
|
|
|
|
|
|
|
// ConnectorType returns an implementation specific identifier. For example "oidc".
|
2015-08-18 05:57:27 +05:30
|
|
|
ConnectorType() string
|
2015-12-10 04:49:39 +05:30
|
|
|
|
|
|
|
// Connector is invoked by the dex server and returns a Connector configured
|
|
|
|
// to use the provided arguments. URL namespace is used to register callbacks.
|
|
|
|
// loginFunc is used to associate remote identies with dex session keys.
|
|
|
|
//
|
|
|
|
// The returned Connector must call loginFunc once upon successful
|
|
|
|
// identification of a user.
|
|
|
|
//
|
|
|
|
// Additional templates are passed for connectors that require rendering HTML
|
|
|
|
// pages, such as the "local" connector.
|
2015-08-18 05:57:27 +05:30
|
|
|
Connector(ns url.URL, loginFunc oidc.LoginFunc, tpls *template.Template) (Connector, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConnectorConfigRepo interface {
|
|
|
|
All() ([]ConnectorConfig, error)
|
2015-12-08 06:49:55 +05:30
|
|
|
GetConnectorByID(repo.Transaction, string) (ConnectorConfig, error)
|
2015-08-18 05:57:27 +05:30
|
|
|
}
|
2015-11-11 01:08:40 +05:30
|
|
|
|
|
|
|
type IdentityProvider interface {
|
|
|
|
Identity(email, password string) (*oidc.Identity, error)
|
|
|
|
}
|