compose

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2016 License: Apache-2.0 Imports: 9 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{}, handlers ...handler) fosite.OAuth2Provider

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

 import "github.com/ory-am/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
 )

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 OpenIDConnectExplicit

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

OpenIDConnectExplicit 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 OpenIDConnectHybrid

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

OpenIDConnectHybrid 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 OpenIDConnectImplicit

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

OpenIDConnectImplicit 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 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

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.

Jump to

Keyboard shortcuts

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