Documentation
¶
Overview ¶
Package auth decides who an operator is. It does not decide whether they are allowed in: that is a policy applied once, over whatever a method reports.
Index ¶
Constants ¶
const ( OIDC = "oidc" // DefaultTenantClaim is what most providers that send groups at all call // them. It is not part of OpenID Connect, which is why it can be changed. DefaultTenantClaim = "groups" )
const Password = "password"
Password is the sign-in that needs nothing but this deployment: an address and a secret compared against a stored hash.
Variables ¶
var ( ErrRefused = errors.New("the credentials were refused") ErrNoMethod = errors.New("no such sign-in method") )
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials interface {
// Verify reports the address behind a correct pair, or refuses.
Verify(ctx context.Context, email, password string) (string, error)
}
Credentials is how the password method reaches the operators. Declared here, by the side that uses it, so this package holds no storage.
type Identity ¶
type Identity struct {
// Subject is stable at the source and is what an account is linked by.
// A method that has no such notion leaves it empty.
Subject string
Email string
// Claims are the values the source sent about what this identity belongs
// to. What they are called at the provider — groups, roles, scopes — is
// the provider's business; here they are values, and a value that is the
// name of a tenant places the identity in it.
Claims []string
// EmailUnverified is what the source said about the address, not what to
// do about it. A method with no such notion leaves it false.
EmailUnverified bool
}
Identity is what a method could establish about whoever is signing in.
type Method ¶
type Method interface {
// Name appears in urls and in configuration.
Name() string
// Label appears on the sign-in page.
Label() string
// Identify reads the request and reports who is signing in, or refuses.
Identify(ctx context.Context, r *http.Request) (Identity, error)
}
Method establishes an identity from a request. One implementation per way of signing in.
func NewPassword ¶
func NewPassword(credentials Credentials) Method
NewPassword builds the local sign-in. It never provisions: an operator has to exist before they can present a password.
type OIDCSettings ¶
type OIDCSettings struct {
Issuer string
ClientID string
ClientSecret string
RedirectURL string
Scopes []string
// TenantClaim is the claim carrying the groups an identity belongs to.
// It is not part of OpenID Connect: providers differ on the name, and some
// send none at all, so the deployment names it.
TenantClaim string
// SecureCookie marks the handshake cookie Secure. It follows the panel's
// own setting, because both cookies travel the same way.
SecureCookie bool
Logger *slog.Logger
}
OIDCSettings is what a deployment gives the OpenID Connect method.
func (OIDCSettings) Configured ¶
func (s OIDCSettings) Configured() bool
type Policy ¶
type Policy struct {
// RequiredClaim admits only identities carrying this value, whatever the
// provider calls the claim it arrives in.
RequiredClaim string
// AcceptUnverifiedEmail admits an identity whose provider says the address
// was never verified. It matters where addresses are self-asserted, and it
// does not where accounts are created by an administrator, which is why
// the deployment decides.
AcceptUnverifiedEmail bool
// AutoProvision creates an operator on first sign-in instead of requiring
// one to exist already.
AutoProvision bool
}
Policy is who is let in once a method has said who they are. It is applied to every method, so a rule cannot be enforced for one way of signing in and forgotten for another.
type Redirector ¶
Redirector is a method that begins by sending the operator somewhere else and finishes when they come back. Identify then reads the return leg.
func NewOIDC ¶
func NewOIDC(settings OIDCSettings) Redirector
NewOIDC builds the OpenID Connect sign-in. It is a Redirector: it sends the operator to the provider and reads the return leg.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the ways of signing in that a deployment offers, in the order they were added, which is the order the sign-in page shows them.
func NewRegistry ¶
func NewRegistry() *Registry