compose

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package compose provides various objects which can be used to instantiate OAuth2Providers with different functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compose

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

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

 import "github.com/pocket-id/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 *fosite.Config, storage fosite.Storage, key interface{}) fosite.OAuth2Provider

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

func NewDeviceStrategy

func NewDeviceStrategy(config fosite.Configurator) *rfc8628.DefaultDeviceStrategy

func NewOAuth2JWTStrategy

func NewOAuth2JWTStrategy(keyGetter func(context.Context) (interface{}, error), config fosite.Configurator) *oauth2.DefaultJWTStrategy

func NewOAuth2RFC9068JWTStrategy

func NewOAuth2RFC9068JWTStrategy(keyGetter func(context.Context) (interface{}, error), config fosite.Configurator) *oauth2.RFC9068JWTStrategy

NewOAuth2RFC9068JWTStrategy creates an access token strategy that issues RFC 9068 access tokens. Set it as CommonStrategyProvider.AccessTokenStrat so refresh tokens and authorization codes remain opaque.

func NewOpenIDConnectStrategy

func NewOpenIDConnectStrategy(keyGetter func(context.Context) (interface{}, error), config fosite.Configurator) *openid.DefaultStrategy

func OAuth2AuthorizeExplicitFactory

func OAuth2AuthorizeExplicitFactory(config fosite.Configurator, storage fosite.Storage, 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 fosite.Configurator, storage fosite.Storage, 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 fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

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

func OAuth2PKCEFactory

func OAuth2PKCEFactory(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

OAuth2PKCEFactory creates a PKCE handler.

func OAuth2RefreshTokenGrantFactory

func OAuth2RefreshTokenGrantFactory(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

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

func OAuth2ResourceOwnerPasswordCredentialsFactory deprecated

func OAuth2ResourceOwnerPasswordCredentialsFactory(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

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

Deprecated: This factory is deprecated as a means to communicate that the ROPC grant type is widely discouraged and is at the time of this writing going to be omitted in the OAuth 2.1 spec. For more information on why this grant type is discouraged see: https://www.scottbrady91.com/oauth/why-the-resource-owner-password-credentials-grant-type-is-not-authentication-nor-suitable-for-modern-applications

func OAuth2StatelessJWTIntrospectionFactory

func OAuth2StatelessJWTIntrospectionFactory(config fosite.Configurator, _ fosite.Storage, 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

func OAuth2TokenIntrospectionFactory(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

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

func OAuth2TokenRevocationFactory

func OAuth2TokenRevocationFactory(_ fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

OAuth2TokenRevocationFactory creates an OAuth2 token revocation handler.

func OIDCUserinfoVerifiableCredentialFactory

func OIDCUserinfoVerifiableCredentialFactory(config fosite.Configurator, storage fosite.Storage, strategy any) any

OIDCUserinfoVerifiableCredentialFactory creates a verifiable credentials handler.

func OpenIDConnectDeviceFactory

func OpenIDConnectDeviceFactory(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

OpenIDConnectDeviceFactory creates an OpenID Connect device ("device code flow") grant handler.

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

func OpenIDConnectExplicitFactory

func OpenIDConnectExplicitFactory(config fosite.Configurator, storage fosite.Storage, 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

func OpenIDConnectHybridFactory(config fosite.Configurator, storage fosite.Storage, 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

func OpenIDConnectImplicitFactory(config fosite.Configurator, storage fosite.Storage, 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

func OpenIDConnectRefreshFactory(config fosite.Configurator, _ fosite.Storage, 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!

func PushedAuthorizeHandlerFactory

func PushedAuthorizeHandlerFactory(config fosite.Configurator, storage fosite.Storage, _ interface{}) interface{}

PushedAuthorizeHandlerFactory creates the basic PAR handler

func RFC7523AssertionGrantFactory

func RFC7523AssertionGrantFactory(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

RFC7523AssertionGrantFactory creates an OAuth2 Authorize JWT Grant (using JWTs as Authorization Grants) handler and registers an access token, refresh token and authorize code validator.

func RFC8628DeviceAuthorizationTokenFactory

func RFC8628DeviceAuthorizationTokenFactory(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

RFC8628DeviceAuthorizationTokenFactory creates an OAuth2 device authorization grant ("Device Authorization Grant") handler and registers an access token, refresh token and authorize code validator.

func RFC8628DeviceFactory

func RFC8628DeviceFactory(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

RFC8628DeviceFactory creates an OAuth2 device code grant ("Device Authorization Grant") handler and registers a user code, device code, access token and a refresh token validator.

Types

type CommonStrategyProvider

type CommonStrategyProvider struct {
	CoreStrategy      oauth2.CoreStrategy
	AccessTokenStrat  oauth2.AccessTokenStrategy
	DeviceStrategy    *rfc8628.DefaultDeviceStrategy
	OIDCTokenStrategy openid.OpenIDConnectTokenStrategy
	jwt.Signer
}

func (*CommonStrategyProvider) AccessTokenStrategy

func (s *CommonStrategyProvider) AccessTokenStrategy() oauth2.AccessTokenStrategy

func (*CommonStrategyProvider) AuthorizeCodeStrategy

func (s *CommonStrategyProvider) AuthorizeCodeStrategy() oauth2.AuthorizeCodeStrategy

func (*CommonStrategyProvider) DeviceCodeStrategy

func (s *CommonStrategyProvider) DeviceCodeStrategy() rfc8628.DeviceCodeStrategy

func (*CommonStrategyProvider) DeviceRateLimitStrategy

func (s *CommonStrategyProvider) DeviceRateLimitStrategy() rfc8628.DeviceRateLimitStrategy

func (*CommonStrategyProvider) OpenIDConnectTokenStrategy

func (s *CommonStrategyProvider) OpenIDConnectTokenStrategy() openid.OpenIDConnectTokenStrategy

func (*CommonStrategyProvider) RefreshTokenStrategy

func (s *CommonStrategyProvider) RefreshTokenStrategy() oauth2.RefreshTokenStrategy

func (*CommonStrategyProvider) UserCodeStrategy

func (s *CommonStrategyProvider) UserCodeStrategy() rfc8628.UserCodeStrategy

type Factory

type Factory func(config fosite.Configurator, storage fosite.Storage, strategy interface{}) interface{}

Jump to

Keyboard shortcuts

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