Documentation
¶
Index ¶
- Constants
- Variables
- func ContextWithAnonymousClaims(ctx context.Context) context.Context
- func ContextWithClaims(ctx context.Context, claims *Claims) context.Context
- func New(cfg *anypb.Any, logger *zap.Logger, scope tally.Scope) (service.Service, error)
- func NewStorage(cfg *anypb.Any, logger *zap.Logger, scope tally.Scope) (service.Service, error)
- type Claims
- type ClaimsConfig
- type ClaimsContextKey
- type ClaimsFromOIDCTokenFunc
- type Issuer
- type OIDCProvider
- func (p *OIDCProvider) CreateToken(ctx context.Context, subject string, ...) (*oauth2.Token, error)
- func (p *OIDCProvider) Exchange(ctx context.Context, code string) (*oauth2.Token, error)
- func (p *OIDCProvider) GetAuthCodeURL(ctx context.Context, state string) (string, error)
- func (p *OIDCProvider) GetStateNonce(redirectURL string) (string, error)
- func (p *OIDCProvider) Read(ctx context.Context, userID, provider string) (*oauth2.Token, error)
- func (p *OIDCProvider) RefreshToken(ctx context.Context, t *oauth2.Token) (*oauth2.Token, error)
- func (p *OIDCProvider) ValidateStateNonce(state string) (string, error)
- func (p *OIDCProvider) Verify(ctx context.Context, rawToken string) (*Claims, error)
- type Provider
- type Service
- type Storage
- type TokenReader
- type TokenStorer
Constants ¶
View Source
const AnonymousSubject = "system:anonymous"
View Source
const Name = "datalift.service.authn"
View Source
const StorageName = "datalift.service.authn.storage"
Variables ¶
View Source
var AlwaysAllowedMethods = []string{
"/datalift.authn.v1.AuthnAPI/Callback",
"/datalift.authn.v1.AuthnAPI/Login",
"/datalift.healthcheck.v1.HealthcheckAPI/*",
}
AlwaysAllowedMethods is a list of method patterns that are always open and not blocked by authn or authz. TODO(maybe): convert this to an API annotation or make configurable on the middleware that use the list.
Functions ¶
func ContextWithClaims ¶
Types ¶
type Claims ¶
type Claims struct { *jwt.StandardClaims // Groups could be derived from the token or an external mapping. Groups []string `json:"grp,omitempty"` }
Standardized representation of a user's claims.
type ClaimsConfig ¶
type ClaimsConfig struct {
// contains filtered or unexported fields
}
func NewClaimsConfig ¶
func NewClaimsConfig(subjectClaimName string, groupsClaimName string) *ClaimsConfig
func (*ClaimsConfig) ClaimsFromOIDCToken ¶
type ClaimsContextKey ¶
type ClaimsContextKey struct{}
type ClaimsFromOIDCTokenFunc ¶
type Issuer ¶
type Issuer interface { // CreateToken creates a new OAuth2 for the provided subject with the provided expiration. If expiry is nil, // the token will never expire. CreateToken(ctx context.Context, subject string, tokenType authnmodulev1.CreateTokenRequest_TokenType, expiry *time.Duration) (token *oauth2.Token, err error) RefreshToken(ctx context.Context, token *oauth2.Token) (*oauth2.Token, error) }
type OIDCProvider ¶
type OIDCProvider struct {
// contains filtered or unexported fields
}
func WithClaimsFromOIDCTokenFunc ¶
func WithClaimsFromOIDCTokenFunc(p *OIDCProvider, fn ClaimsFromOIDCTokenFunc) *OIDCProvider
func (*OIDCProvider) CreateToken ¶
func (p *OIDCProvider) CreateToken(ctx context.Context, subject string, tokenType authnmodulev1.CreateTokenRequest_TokenType, expiry *time.Duration) (*oauth2.Token, error)
func (*OIDCProvider) GetAuthCodeURL ¶
func (*OIDCProvider) GetStateNonce ¶
func (p *OIDCProvider) GetStateNonce(redirectURL string) (string, error)
func (*OIDCProvider) RefreshToken ¶
Refresh the issuer token. If the provider token is not valid, refresh it. If any error occurs continue auth code flow.
func (*OIDCProvider) ValidateStateNonce ¶
func (p *OIDCProvider) ValidateStateNonce(state string) (string, error)
type Provider ¶
type Provider interface { GetStateNonce(redirectURL string) (string, error) ValidateStateNonce(state string) (redirectURL string, err error) Verify(ctx context.Context, rawIDToken string) (*Claims, error) GetAuthCodeURL(ctx context.Context, state string) (string, error) Exchange(ctx context.Context, code string) (token *oauth2.Token, err error) }
type Service ¶
type Service interface { Issuer Provider TokenReader // Read calls are proxied through the IssuerProvider so the token can be refreshed if needed. }
type Storage ¶
type Storage interface { TokenReader TokenStorer }
type TokenReader ¶
Click to show internal directories.
Click to hide internal directories.