oauth2

package
v0.0.0-...-a4f6240 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationVerifierStore

type AuthenticationVerifierStore = core.KeyValueStore[string, []byte]

type AuthorizationCodeTokenRequest

type AuthorizationCodeTokenRequest struct {
	RedirectUri  string `form:"redirect_uri"`
	Code         string `form:"code" binding:"required"`
	CodeVerifier string `form:"code_verifier"`
	// contains filtered or unexported fields
}

func (*AuthorizationCodeTokenRequest) GetGrantType

func (r *AuthorizationCodeTokenRequest) GetGrantType() string

type AuthorizationError

type AuthorizationError struct {
	RedirectUri string
	State       string
	Issuer      string
	ErrorType   string
	Description string
}

func (*AuthorizationError) BuildResponseURI

func (e *AuthorizationError) BuildResponseURI() string

func (*AuthorizationError) Error

func (e *AuthorizationError) Error() string

type AuthorizationGrant

type AuthorizationGrant struct {
	IssueRefreshToken bool      `json:"-"`
	ID                uuid.UUID `json:"-"`
	Scope             string    `json:"scope"`
	ClientId          string    `json:"client_id"`
	SubjectId         string    `json:"sub"`
	IssuedAt          timestamp `json:"iat"`
	ExpiresAt         timestamp `json:"exp"`
	NotBefore         timestamp `json:"nbf,omitempty"`
}

type AuthorizationRequest

type AuthorizationRequest struct {
	ClientId      string
	RedirectUri   string
	ResponseType  string
	Scope         string
	State         string
	CodeChallenge string
	CodeMethod    string
	// contains filtered or unexported fields
}

type AuthorizationResponse

type AuthorizationResponse struct {
	RedirectUri string
	State       string
	Issuer      string
	Code        string
}

func (*AuthorizationResponse) BuildResponseURI

func (r *AuthorizationResponse) BuildResponseURI() string

type AuthorizationService

type AuthorizationService struct {
	// contains filtered or unexported fields
}

func NewAuthorizationService

func NewAuthorizationService(authorizationStore AuthorizationStore, codeStore CodeStore, authenticationVerifierStore AuthenticationVerifierStore, clientService *ClientService, authorizationCodeInit metric.Int64Counter, authorizationCodeSuccess metric.Int64Counter) *AuthorizationService

func (*AuthorizationService) Authorize

func (*AuthorizationService) VerifyAuthentication

func (s *AuthorizationService) VerifyAuthentication(ctx context.Context, uuid string, authenticationVerifier string) ResponseUriBuilder

type Client

type Client struct {
	ID           string
	Scopes       []string
	RedirectURIs []string
}

func (*Client) RestrictScopes

func (c *Client) RestrictScopes(ctx context.Context, scopes []string) []string

func (*Client) ValidateRedirectURI

func (c *Client) ValidateRedirectURI(ctx context.Context, redirectURI string) bool

type ClientDTO

type ClientDTO struct {
	ID           string   `json:"id"`
	Scopes       []string `json:"scopes"`
	RedirectURIs []string `json:"redirectURIs"`
}

type ClientModel

type ClientModel struct {
	ID           string `gorm:"primaryKey"`
	Scopes       string
	RedirectURIs string
}

type ClientRepository

type ClientRepository = core.Repository[string, *ClientModel]

type ClientService

type ClientService struct {
	// contains filtered or unexported fields
}

func NewClientService

func NewClientService(repo ClientRepository) *ClientService

func (*ClientService) Create

func (s *ClientService) Create(ctx context.Context, dto ClientDTO) (*Client, error)

func (*ClientService) Delete

func (s *ClientService) Delete(ctx context.Context, id string) error

func (*ClientService) FindById

func (s *ClientService) FindById(ctx context.Context, id string) (*Client, error)

func (*ClientService) List

func (s *ClientService) List(ctx context.Context) ([]*Client, error)

func (*ClientService) Update

func (s *ClientService) Update(ctx context.Context, dto ClientDTO) (*Client, error)

type ClientWithSecretDTO

type ClientWithSecretDTO struct {
	ClientDTO
	Secret string `json:"secret"`
}

type OAuthTokenService

type OAuthTokenService struct {
	// contains filtered or unexported fields
}

func NewOAuthTokenService

func NewOAuthTokenService(codeStore CodeStore, accessTokenHandler TokenHandler, refreshTokenHandler TokenHandler, tokenRequestInstrument metric.Int64Counter) *OAuthTokenService

func (*OAuthTokenService) Token

func (*OAuthTokenService) Validate

func (s *OAuthTokenService) Validate(ctx context.Context, token string) (*AuthorizationGrant, error)

type RandomTokenHandler

type RandomTokenHandler struct {
	// contains filtered or unexported fields
}

func NewRandomTokenHandler

func NewRandomTokenHandler(tokenType string, tokenSize int, store TokenStore, tokensGenerated metric.Int64Counter) *RandomTokenHandler

func (*RandomTokenHandler) GenerateToken

func (h *RandomTokenHandler) GenerateToken(ctx context.Context, grant *AuthorizationGrant) (string, error)

func (*RandomTokenHandler) Validate

func (h *RandomTokenHandler) Validate(ctx context.Context, token string) (*AuthorizationGrant, error)

type RefreshTokenRequest

type RefreshTokenRequest struct {
	RefreshToken string `form:"refresh_token" binding:"required"`
	// contains filtered or unexported fields
}

func (*RefreshTokenRequest) GetGrantType

func (r *RefreshTokenRequest) GetGrantType() string

type ResponseUriBuilder

type ResponseUriBuilder interface {
	BuildResponseURI() string
}

type TokenError

type TokenError struct {
	ErrorType        string `json:"error" binding:"required"`
	ErrorDescription string `json:"error_description" binding:"required"`
}

func (*TokenError) Error

func (e *TokenError) Error() string

type TokenHandler

type TokenHandler interface {
	GenerateToken(ctx context.Context, grant *AuthorizationGrant) (string, error)
	Validate(ctx context.Context, token string) (*AuthorizationGrant, error)
}

type TokenRequest

type TokenRequest interface {
	GetGrantType() string
}

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token" binding:"required"`
	TokenType    string `json:"token_type" binding:"required"`
	ExpiresIn    int    `json:"expires_in" binding:"required"`
	Scope        string `json:"scope" binding:"required"`
	RefreshToken string `json:"refresh_token"`
}

Jump to

Keyboard shortcuts

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