fosite: github.com/ory/fosite/compose Index | Files

package compose

import "github.com/ory/fosite/compose"

Index

Package Files

compose.go compose_oauth2.go compose_openid.go compose_pkce.go compose_strategy.go config.go

func Compose Uses

func Compose(config *Config, storage interface{}, strategy interface{}, hasher fosite.Hasher, factories ...Factory) fosite.OAuth2Provider

Compose takes a config, a storage, a strategy and handlers to instantiate an OAuth2Provider:

 import "github.com/ory/fosite/compose"

 // var storage = new(MyFositeStorage)
 var config = Config {
 	AccessTokenLifespan: time.Minute * 30,
	// check Config for further configuration options
 }

 var strategy = NewOAuth2HMACStrategy(config)

 var oauth2Provider = Compose(
 	config,
	storage,
	strategy,
	NewOAuth2AuthorizeExplicitHandler,
	OAuth2ClientCredentialsGrantFactory,
	// for a complete list refer to the docs of this package
 )

Compose makes use of interface{} types in order to be able to handle a all types of stores, strategies and handlers.

func ComposeAllEnabled Uses

func ComposeAllEnabled(config *Config, storage interface{}, secret []byte, key *rsa.PrivateKey) fosite.OAuth2Provider

ComposeAllEnabled returns a fosite instance with all OAuth2 and OpenID Connect handlers enabled.

func NewOAuth2HMACStrategy Uses

func NewOAuth2HMACStrategy(config *Config, secret []byte, rotatedSecrets [][]byte) *oauth2.HMACSHAStrategy

func NewOAuth2JWTStrategy Uses

func NewOAuth2JWTStrategy(key *rsa.PrivateKey, strategy *oauth2.HMACSHAStrategy) *oauth2.DefaultJWTStrategy

func NewOpenIDConnectStrategy Uses

func NewOpenIDConnectStrategy(config *Config, key *rsa.PrivateKey) *openid.DefaultStrategy

func OAuth2AuthorizeExplicitFactory Uses

func OAuth2AuthorizeExplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2AuthorizeExplicitFactory creates an OAuth2 authorize code grant ("authorize explicit flow") handler and registers an access token, refresh token and authorize code validator.

func OAuth2AuthorizeImplicitFactory Uses

func OAuth2AuthorizeImplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2AuthorizeImplicitFactory creates an OAuth2 implicit grant ("authorize implicit flow") handler and registers an access token, refresh token and authorize code validator.

func OAuth2ClientCredentialsGrantFactory Uses

func OAuth2ClientCredentialsGrantFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2ClientCredentialsGrantFactory creates an OAuth2 client credentials grant handler and registers an access token, refresh token and authorize code validator.

func OAuth2PKCEFactory Uses

func OAuth2PKCEFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2PKCEFactory creates a PKCE handler.

func OAuth2RefreshTokenGrantFactory Uses

func OAuth2RefreshTokenGrantFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2RefreshTokenGrantFactory creates an OAuth2 refresh grant handler and registers an access token, refresh token and authorize code validator.

func OAuth2ResourceOwnerPasswordCredentialsFactory Uses

func OAuth2ResourceOwnerPasswordCredentialsFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2ResourceOwnerPasswordCredentialsFactory creates an OAuth2 resource owner password credentials grant handler and registers an access token, refresh token and authorize code validator.

func OAuth2StatelessJWTIntrospectionFactory Uses

func OAuth2StatelessJWTIntrospectionFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2StatelessJWTIntrospectionFactory creates an OAuth2 token introspection handler and registers an access token validator. This can only be used to validate JWTs and does so statelessly, meaning it uses only the data available in the JWT itself, and does not access the storage implementation at all.

Due to the stateless nature of this factory, THE BUILT-IN REVOCATION MECHANISMS WILL NOT WORK. If you need revocation, you can validate JWTs statefully, using the other factories.

func OAuth2TokenIntrospectionFactory Uses

func OAuth2TokenIntrospectionFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2TokenIntrospectionFactory creates an OAuth2 token introspection handler and registers an access token and refresh token validator.

func OAuth2TokenRevocationFactory Uses

func OAuth2TokenRevocationFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OAuth2TokenRevocationFactory creates an OAuth2 token revocation handler.

func OpenIDConnectExplicitFactory Uses

func OpenIDConnectExplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OpenIDConnectExplicitFactory creates an OpenID Connect explicit ("authorize code flow") grant handler.

**Important note:** You must add this handler *after* you have added an OAuth2 authorize code handler!

func OpenIDConnectHybridFactory Uses

func OpenIDConnectHybridFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OpenIDConnectHybridFactory creates an OpenID Connect hybrid grant handler.

**Important note:** You must add this handler *after* you have added an OAuth2 authorize code handler!

func OpenIDConnectImplicitFactory Uses

func OpenIDConnectImplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OpenIDConnectImplicitFactory creates an OpenID Connect implicit ("implicit flow") grant handler.

**Important note:** You must add this handler *after* you have added an OAuth2 authorize code handler!

func OpenIDConnectRefreshFactory Uses

func OpenIDConnectRefreshFactory(config *Config, storage interface{}, strategy interface{}) interface{}

OpenIDConnectRefreshFactory creates a handler for refreshing openid connect tokens.

**Important note:** You must add this handler *after* you have added an OAuth2 authorize code handler!

type CommonStrategy Uses

type CommonStrategy struct {
    oauth2.CoreStrategy
    openid.OpenIDConnectTokenStrategy
    jwt.JWTStrategy
}

type Config Uses

type Config struct {
    // AccessTokenLifespan sets how long an access token is going to be valid. Defaults to one hour.
    AccessTokenLifespan time.Duration

    // RefreshTokenLifespan sets how long a refresh token is going to be valid. Defaults to 30 days. Set to -1 for
    // refresh tokens that never expire.
    RefreshTokenLifespan time.Duration

    // AuthorizeCodeLifespan sets how long an authorize code is going to be valid. Defaults to fifteen minutes.
    AuthorizeCodeLifespan time.Duration

    // IDTokenLifespan sets the default id token lifetime. Defaults to one hour.
    IDTokenLifespan time.Duration

    // IDTokenIssuer sets the default issuer of the ID Token.
    IDTokenIssuer string

    // HashCost sets the cost of the password hashing cost. Defaults to 12.
    HashCost int

    // DisableRefreshTokenValidation sets the introspection endpoint to disable refresh token validation.
    DisableRefreshTokenValidation bool

    // SendDebugMessagesToClients if set to true, includes error debug messages in response payloads. Be aware that sensitive
    // data may be exposed, depending on your implementation of Fosite. Such sensitive data might include database error
    // codes or other information. Proceed with caution!
    SendDebugMessagesToClients bool

    // ScopeStrategy sets the scope strategy that should be supported, for example fosite.WildcardScopeStrategy.
    ScopeStrategy fosite.ScopeStrategy

    // AudienceMatchingStrategy sets the audience matching strategy that should be supported, defaults to fosite.DefaultsAudienceMatchingStrategy.
    AudienceMatchingStrategy fosite.AudienceMatchingStrategy

    // EnforcePKCE, if set to true, requires clients to perform authorize code flows with PKCE. Defaults to false.
    EnforcePKCE bool

    // EnablePKCEPlainChallengeMethod sets whether or not to allow the plain challenge method (S256 should be used whenever possible, plain is really discouraged). Defaults to false.
    EnablePKCEPlainChallengeMethod bool

    // AllowedPromptValues sets which OpenID Connect prompt values the server supports. Defaults to []string{"login", "none", "consent", "select_account"}.
    AllowedPromptValues []string

    // TokenURL is the the URL of the Authorization Server's Token Endpoint. If the authorization server is intended
    // to be compatible with the private_key_jwt client authentication method (see http://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth),
    // this value MUST be set.
    TokenURL string

    // JWKSFetcherStrategy is responsible for fetching JSON Web Keys from remote URLs. This is required when the private_key_jwt
    // client authentication method is used. Defaults to fosite.DefaultJWKSFetcherStrategy.
    JWKSFetcher fosite.JWKSFetcherStrategy

    // TokenEntropy indicates the entropy of the random string, used as the "message" part of the HMAC token.
    // Defaults to 32.
    TokenEntropy int

    // RedirectSecureChecker is a function that returns true if the provided URL can be securely used as a redirect URL.
    RedirectSecureChecker func(*url.URL) bool

    // RefreshTokenScopes defines which OAuth scopes will be given refresh tokens during the authorization code grant exchange. This defaults to "offline" and "offline_access". When set to an empty array, all exchanges will be given refresh tokens.
    RefreshTokenScopes []string
}

func (*Config) GetAccessTokenLifespan Uses

func (c *Config) GetAccessTokenLifespan() time.Duration

GetAccessTokenLifespan returns how long an access token should be valid. Defaults to one hour.

func (*Config) GetAudienceStrategy Uses

func (c *Config) GetAudienceStrategy() fosite.AudienceMatchingStrategy

GetAudienceStrategy returns the scope strategy to be used. Defaults to glob scope strategy.

func (*Config) GetAuthorizeCodeLifespan Uses

func (c *Config) GetAuthorizeCodeLifespan() time.Duration

GetAuthorizeCodeLifespan returns how long an authorize code should be valid. Defaults to one fifteen minutes.

func (*Config) GetHashCost Uses

func (c *Config) GetHashCost() int

GetHashCost returns the bcrypt cost factor. Defaults to 12.

func (*Config) GetIDTokenLifespan Uses

func (c *Config) GetIDTokenLifespan() time.Duration

GeIDTokenLifespan returns how long an id token should be valid. Defaults to one hour.

func (*Config) GetJWKSFetcherStrategy Uses

func (c *Config) GetJWKSFetcherStrategy() fosite.JWKSFetcherStrategy

GetJWKSFetcherStrategy returns the JWKSFetcherStrategy.

func (*Config) GetRedirectSecureChecker Uses

func (c *Config) GetRedirectSecureChecker() func(*url.URL) bool

GetTokenEntropy returns the entropy of the "message" part of a HMAC Token. Defaults to 32.

func (*Config) GetRefreshTokenLifespan Uses

func (c *Config) GetRefreshTokenLifespan() time.Duration

GetRefreshTokenLifespan sets how long a refresh token is going to be valid. Defaults to 30 days. Set to -1 for refresh tokens that never expire.

func (*Config) GetRefreshTokenScopes Uses

func (c *Config) GetRefreshTokenScopes() []string

GetRefreshTokenScopes returns which scopes will provide refresh tokens.

func (*Config) GetScopeStrategy Uses

func (c *Config) GetScopeStrategy() fosite.ScopeStrategy

GetScopeStrategy returns the scope strategy to be used. Defaults to glob scope strategy.

func (*Config) GetTokenEntropy Uses

func (c *Config) GetTokenEntropy() int

GetTokenEntropy returns the entropy of the "message" part of a HMAC Token. Defaults to 32.

type Factory Uses

type Factory func(config *Config, storage interface{}, strategy interface{}) interface{}

Package compose imports 9 packages (graph) and is imported by 22 packages. Updated 2019-09-16. Refresh now. Tools for package owners.