compose

package
Version: v0.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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, strategy *oauth2.HMACSHAStrategy) *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.

**Important note:** 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.

**Important note:** You must add this handler *after* you have added an OAuth2 authorize code 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.

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

func OpenIDConnectRefreshFactory added in v0.11.0

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!

Types

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

	ScopeStrategy fosite.ScopeStrategy
}

func (*Config) GetAccessTokenLifespan

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

GetAccessTokenLifespan returns how long a refresh token should be valid. Defaults to one hour.

func (*Config) GetAuthorizeCodeLifespan

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

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

func (*Config) GetHashCost

func (c *Config) GetHashCost() int

GetAccessTokenLifespan returns how long a refresh token should be valid. Defaults to one hour.

func (*Config) GetIDTokenLifespan

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

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

func (*Config) GetScopeStrategy added in v0.11.0

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

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

type Factory added in v0.6.17

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL