auth

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const JWTSigningKeyID = "jwt_signing_key"

Variables

View Source
var (
	ErrNotFound = errors.New("key not found")
	ErrDB       = errors.New("database error")
)

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Roles       []string               `json:"roles"`
	Permissions []string               `json:"permissions"`
	Preferences map[string]interface{} `json:"preferences,omitempty"`
	jwt.RegisteredClaims
}

type OAuthManager

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

func NewOAuthManager

func NewOAuthManager() *OAuthManager

func (*OAuthManager) GetProvider

func (m *OAuthManager) GetProvider(providerType string) (OAuthProvider, bool)

func (*OAuthManager) RegisterProvider

func (m *OAuthManager) RegisterProvider(provider OAuthProvider)

type OAuthProvider

type OAuthProvider interface {
	GetAuthURL(state string) string
	HandleCallback(ctx context.Context, code string) (*user.User, error)
	Name() string
	Type() string
}

type OktaProvider

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

OktaProvider represents the OAuth provider for Okta.

func NewOktaProvider

func NewOktaProvider(cfg *config.Config, userService user.Service, authService Service, teamService *team.Service) *OktaProvider

NewOktaProvider creates a new OktaProvider.

func (*OktaProvider) GetAuthURL

func (p *OktaProvider) GetAuthURL(state string) string

func (*OktaProvider) HandleCallback

func (p *OktaProvider) HandleCallback(ctx context.Context, code string) (*user.User, error)

func (*OktaProvider) Name

func (p *OktaProvider) Name() string

Name returns the name of the provider.

func (*OktaProvider) Type

func (p *OktaProvider) Type() string

Type returns the type of the provider.

type Repository

type Repository interface {
	GetSigningKey(ctx context.Context, key string) (string, error)
	StoreSigningKey(ctx context.Context, key, value string) error
}

func NewPostgresRepository

func NewPostgresRepository(db *pgxpool.Pool) Repository

type Service

type Service interface {
	GenerateToken(ctx context.Context, user *user.User, preferencesClaims map[string]interface{}) (string, error)
	ValidateToken(ctx context.Context, tokenString string) (*Claims, error)
	GetSigningKey(ctx context.Context) ([]byte, error)
}

func NewService

func NewService(repo Repository, userService user.Service) Service

Jump to

Keyboard shortcuts

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