Documentation ¶
Index ¶
- func Compose(config *Config, storage interface{}, strategy interface{}, ...) fosite.OAuth2Provider
- func ComposeAllEnabled(config *Config, storage interface{}, secret []byte, key *rsa.PrivateKey) fosite.OAuth2Provider
- func NewOAuth2HMACStrategy(config *Config, secret []byte) *oauth2.HMACSHAStrategy
- func NewOAuth2JWTStrategy(key *rsa.PrivateKey) *oauth2.RS256JWTStrategy
- func NewOpenIDConnectStrategy(key *rsa.PrivateKey) *openid.DefaultStrategy
- func OAuth2AuthorizeExplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OAuth2AuthorizeImplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OAuth2ClientCredentialsGrantFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OAuth2RefreshTokenGrantFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OAuth2ResourceOwnerPasswordCredentialsFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OAuth2StatelessJWTIntrospectionFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OAuth2TokenIntrospectionFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OAuth2TokenRevocationFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OpenIDConnectExplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OpenIDConnectHybridFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- func OpenIDConnectImplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}
- type CommonStrategy
- type Config
- type Factory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compose ¶
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 ¶
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 ¶
func NewOAuth2HMACStrategy(config *Config, secret []byte) *oauth2.HMACSHAStrategy
func NewOAuth2JWTStrategy ¶
func NewOAuth2JWTStrategy(key *rsa.PrivateKey) *oauth2.RS256JWTStrategy
func NewOpenIDConnectStrategy ¶
func NewOpenIDConnectStrategy(key *rsa.PrivateKey) *openid.DefaultStrategy
func OAuth2AuthorizeExplicitFactory ¶
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 ¶
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 ¶
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 OAuth2RefreshTokenGrantFactory ¶
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 ¶
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 ¶ added in v0.6.17
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 ¶ added in v0.5.0
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 ¶ added in v0.4.0
func OAuth2TokenRevocationFactory(config *Config, storage interface{}, strategy interface{}) interface{}
OAuth2TokenRevocationFactory creates an OAuth2 token revocation handler.
func OpenIDConnectExplicitFactory ¶ added in v0.5.0
func OpenIDConnectExplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}
OpenIDConnectExplicitFactory creates an OpenID Connect explicit ("authorize code flow") grant handler. You must add this handler *after* you have added an OAuth2 authorize code handler!
func OpenIDConnectHybridFactory ¶ added in v0.5.0
func OpenIDConnectHybridFactory(config *Config, storage interface{}, strategy interface{}) interface{}
OpenIDConnectHybridFactory creates an OpenID Connect hybrid grant handler. You must add this handler *after* you have added an OAuth2 authorize code and implicit authorize handler!
func OpenIDConnectImplicitFactory ¶ added in v0.5.0
func OpenIDConnectImplicitFactory(config *Config, storage interface{}, strategy interface{}) interface{}
OpenIDConnectImplicitFactory creates an OpenID Connect implicit ("implicit flow") grant handler. You must add this handler *after* you have added an OAuth2 authorize implicit handler!
Types ¶
type CommonStrategy ¶
type CommonStrategy struct { oauth2.CoreStrategy openid.OpenIDConnectTokenStrategy }
type Config ¶
type Config struct { // AccessTokenLifespan sets how long an access token is going to be valid. Defaults to one hour. AccessTokenLifespan time.Duration // AuthorizeCodeLifespan sets how long an authorize code is going to be valid. Defaults to fifteen minutes. AuthorizeCodeLifespan time.Duration // IDTokenLifespan sets how long an id token is going to be valid. Defaults to one hour. IDTokenLifespan time.Duration // HashCost sets the cost of the password hashing cost. Defaults to 12. HashCost int }
func (*Config) GetAccessTokenLifespan ¶
GetAccessTokenLifespan returns how long a refresh token should be valid. Defaults to one hour.
func (*Config) GetAuthorizeCodeLifespan ¶
GetAuthorizeCodeLifespan returns how long an authorize code should be valid. Defaults to one fifteen minutes.
func (*Config) GetHashCost ¶
GetAccessTokenLifespan returns how long a refresh token should be valid. Defaults to one hour.
func (*Config) GetIDTokenLifespan ¶
GeIDTokenLifespan returns how long an id token should be valid. Defaults to one hour.