auth

package
v0.83.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 16 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenAlreadyUsed = errors.New("JWT already used")
	ErrTokenExpired     = errors.New("JWT expired")
)

Functions

This section is empty.

Types

type Manager

type Manager interface {
	ValidateAndParseToken(ctx context.Context, value string) (auth.UserAuth, *jwt.Token, error)
	EnsureUserAccessByJWTGroups(ctx context.Context, userAuth auth.UserAuth, token *jwt.Token) (auth.UserAuth, error)
	MarkPATUsed(ctx context.Context, tokenID string) error
	GetPATInfo(ctx context.Context, token string) (user *types.User, pat *types.PersonalAccessToken, domain string, category string, err error)
}

func NewManager

func NewManager(store store.Store, issuer, audience, keysLocation, userIdClaim string, allAudiences []string, idpRefreshKeys bool, keyFetcher nbjwt.KeyFetcher) Manager

type MockManager

type MockManager struct {
	ValidateAndParseTokenFunc       func(ctx context.Context, value string) (auth.UserAuth, *jwt.Token, error)
	EnsureUserAccessByJWTGroupsFunc func(ctx context.Context, userAuth auth.UserAuth, token *jwt.Token) (auth.UserAuth, error)
	MarkPATUsedFunc                 func(ctx context.Context, tokenID string) error
	GetPATInfoFunc                  func(ctx context.Context, token string) (user *types.User, pat *types.PersonalAccessToken, domain string, category string, err error)
}

@note really dislike this mocking approach but rather than have to do additional test refactoring.

func (*MockManager) EnsureUserAccessByJWTGroups

func (m *MockManager) EnsureUserAccessByJWTGroups(ctx context.Context, userAuth auth.UserAuth, token *jwt.Token) (auth.UserAuth, error)

EnsureUserAccessByJWTGroups implements Manager.

func (*MockManager) GetPATInfo

func (m *MockManager) GetPATInfo(ctx context.Context, token string) (user *types.User, pat *types.PersonalAccessToken, domain string, category string, err error)

GetPATInfo implements Manager.

func (*MockManager) MarkPATUsed

func (m *MockManager) MarkPATUsed(ctx context.Context, tokenID string) error

MarkPATUsed implements Manager.

func (*MockManager) ValidateAndParseToken

func (m *MockManager) ValidateAndParseToken(ctx context.Context, value string) (auth.UserAuth, *jwt.Token, error)

ValidateAndParseToken implements Manager.

type SessionStore added in v0.70.3

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

func NewSessionStore added in v0.70.3

func NewSessionStore(cacheStore TokenCache) *SessionStore

func (*SessionStore) RegisterToken added in v0.70.3

func (s *SessionStore) RegisterToken(ctx context.Context, token string, expiresAt time.Time) error

RegisterToken records a JWT until its exp time and rejects reuse.

type TokenCache added in v0.79.0

type TokenCache interface {
	SetNX(ctx context.Context, key, value string, ttl time.Duration) (bool, error)
}

TokenCache atomically records used JWTs until their expiration.

Jump to

Keyboard shortcuts

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