oauth2

package
v0.0.0-...-51c1a95 Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: Apache-2.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AudienceCustomClaims

type AudienceCustomClaims struct {
	Scope string `json:"scope"` // This is a mandatory claim that MUST be present in the token
	// contains filtered or unexported fields
}

func (*AudienceCustomClaims) Validate

func (a *AudienceCustomClaims) Validate(ctx context.Context) error

type Config

type Config struct {
	AuthServerURL       string        // URL of the Auth server (e.g. http://oauthserver:8080/realms/sfn.nef for KeyCloak)
	IssuerURL           string        // In case when Auth Server exposes an external or different IssuerURL. If empty AuthServerURL will be used
	PubKeyCacheDuration time.Duration // Duration to store the RSA Pubic Key
	Audience            []string      // The intended Audience the AccessToken should have (as configured in AuthServer)
	AuthorizedScope     []string      // Allowed scopes to be validated against. At this point they MUST have http.Methods to be validated with route
}

Config related to JWT based OAuth2 Authorization

type OAuth2Provider

type OAuth2Provider struct {
	Conf Config
}

func New

func New(conf *Config) (*OAuth2Provider, error)

func (*OAuth2Provider) AuthorizationMiddleware

func (o *OAuth2Provider) AuthorizationMiddleware() (gin.HandlerFunc, error)

This can be used as a Middleware or a GinHandlerFunc for a specific route

Jump to

Keyboard shortcuts

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