oidc

package
v0.0.0-...-7555876 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowEmptyCookie

func AllowEmptyCookie() func(*MiddlewareConfig)

func FromConfig

func FromConfig(cfg config.Oidc) func(*MiddlewareConfig)

func NewOauthMiddleware

func NewOauthMiddleware(svc UserService, options ...func(*MiddlewareConfig)) fiber.Handler

Types

type JSONWebToken

type JSONWebToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	IDToken      string `json:"id_token"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
	Type         string `json:"token_type"`
	Provider     string `json:"provider"`
}

func DecodeToken

func DecodeToken(value string) (*JSONWebToken, error)

DecodeToken decode given base64 url encoded JSONWebToken.

func (*JSONWebToken) Encode

func (t *JSONWebToken) Encode() (string, error)

type MiddlewareConfig

type MiddlewareConfig struct {
	Extractor        func(*fiber.Ctx, string) (*auth.User, error)
	Key              string
	AllowEmptyCookie bool
}

type Provider

type Provider interface {
	GetName() string
	GetAuthURL(state string, redirectURL string) string
	ExchangeCode(ctx context.Context, authCode string, redirectURI string) (*claims, *JSONWebToken, error)
	ValidateToken(ctx context.Context, token *JSONWebToken) (*claims, error)
	RevokeToken(ctx context.Context, token string) error
}

func FromConfiguration

func FromConfiguration(cfg config.Oidc, client *http.Client) ([]Provider, error)

func TestProvider

func TestProvider(cfg config.Provider, client *http.Client) Provider

type RedirectURL

type RedirectURL struct {
	URL   string
	State string
}

func NewRedirectURL

func NewRedirectURL(p Provider, redirectURI string) (*RedirectURL, error)

type Service

type Service interface {
	UserService
	GetAuthURL(provider string) (*RedirectURL, error)
	Authenticate(provider string, code string) (*auth.User, *JSONWebToken, error)
	Logout(token *JSONWebToken) error
}

func New

func New(cfg config.Oidc, provider []Provider) Service

type State

type State struct {
	ID       string `json:"id"`
	Provider string `json:"provider"`
}

func DecodeState

func DecodeState(value string) (*State, error)

DecodeState decode given base64 url encoded State.

func NewState

func NewState(provider string) *State

func (*State) Encode

func (s *State) Encode() (string, error)

type UserService

type UserService interface {
	GetAuthenticatedUser(provider string, token *JSONWebToken) (*auth.User, error)
}

Jump to

Keyboard shortcuts

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