store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRefreshToken

func GenerateRefreshToken() (string, error)

Types

type Client

type Client struct {
	ClientID          string   `json:"clientId"`
	ClientName        string   `json:"clientName"`
	SecretHash        string   `json:"secretHash,omitempty"`
	Confidential      bool     `json:"confidential"`
	RedirectURIs      []string `json:"redirectURIs"`
	AllowedGrantTypes []string `json:"allowedGrantTypes"`
	CreatedAt         string   `json:"createdAt"`
}

func (*Client) HasGrantType

func (c *Client) HasGrantType(gt string) bool

ClientHasGrantType checks if a client is allowed a grant type

func (*Client) IsValidRedirectURI

func (c *Client) IsValidRedirectURI(uri string) bool

IsValidRedirectURI checks if a redirect URI is allowed for a client

type RefreshToken

type RefreshToken struct {
	ID        string
	TokenHash string
	UserID    string
	ClientID  string
	IssuedAt  time.Time
	ExpiresAt time.Time
	Revoked   bool
}

type Store

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

func New

func New(dsn string) (*Store, error)

func (*Store) AddClient

func (s *Store) AddClient(clientID, clientName, secretPlain string, confidential bool, redirectURIs, grantTypes []string) error

func (*Store) AddRole

func (s *Store) AddRole(username, role string) error

func (*Store) AddUser

func (s *Store) AddUser(username, password, email, displayName string) error

func (*Store) Authenticate

func (s *Store) Authenticate(username, password string) (*User, error)

func (*Store) AuthenticateClient

func (s *Store) AuthenticateClient(clientID, secret string) (*Client, error)

AuthenticateClient checks client_id + secret for confidential clients

func (*Store) CleanupExpiredRefreshTokens

func (s *Store) CleanupExpiredRefreshTokens(olderThan time.Duration) (int64, error)

func (*Store) CleanupRateLimits

func (s *Store) CleanupRateLimits(olderThan time.Duration) (int64, error)

CleanupRateLimits removes old rate limit entries

func (*Store) CleanupTokenRevocations

func (s *Store) CleanupTokenRevocations() (int64, error)

func (*Store) ClientCount

func (s *Store) ClientCount() (int, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) ConsumeRefreshToken

func (s *Store) ConsumeRefreshToken(rawToken string) (string, string, error)

func (*Store) CountAttempts

func (s *Store) CountAttempts(key string, window time.Duration) (int, error)

CountAttempts counts attempts for a key within a window

func (*Store) DB

func (s *Store) DB() *sql.DB

func (*Store) DeleteClient

func (s *Store) DeleteClient(clientID string) error

func (*Store) DeleteConfig

func (s *Store) DeleteConfig(key string) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(username string) error

func (*Store) GetAllConfig

func (s *Store) GetAllConfig() (map[string]string, error)

func (*Store) GetClient

func (s *Store) GetClient(clientID string) (*Client, error)

func (*Store) GetConfig

func (s *Store) GetConfig(key string) (string, error)

func (*Store) GetConfigMap

func (s *Store) GetConfigMap(key string) (map[string]string, error)

func (*Store) GetConfigStringSlice

func (s *Store) GetConfigStringSlice(key string) ([]string, error)

func (*Store) GetUser

func (s *Store) GetUser(username string) (*User, error)

func (*Store) GetUserByID

func (s *Store) GetUserByID(id string) (*User, error)

func (*Store) IsAccessTokenRevoked

func (s *Store) IsAccessTokenRevoked(tokenHash string) bool

func (*Store) ListClients

func (s *Store) ListClients() []Client

func (*Store) ListRoles

func (s *Store) ListRoles(username string) ([]string, error)

func (*Store) ListUsers

func (s *Store) ListUsers() []User

func (*Store) RecordAttempt

func (s *Store) RecordAttempt(key string) error

RecordAttempt records a rate limit attempt

func (*Store) RemoveRole

func (s *Store) RemoveRole(username, role string) error

func (*Store) ResetPassword

func (s *Store) ResetPassword(username, password string) error

func (*Store) RevokeAccessToken

func (s *Store) RevokeAccessToken(tokenHash string, expiresAt time.Time) error

func (*Store) RevokeRefreshToken

func (s *Store) RevokeRefreshToken(rawToken string) error

func (*Store) RevokeRefreshTokensForUser

func (s *Store) RevokeRefreshTokensForUser(userID string) error

func (*Store) SetConfig

func (s *Store) SetConfig(key, value string) error

func (*Store) SetConfigMap

func (s *Store) SetConfigMap(key string, m map[string]string) error

func (*Store) SetConfigStringSlice

func (s *Store) SetConfigStringSlice(key string, values []string) error

func (*Store) StoreRefreshToken

func (s *Store) StoreRefreshToken(rawToken, userID, clientID string, lifetime time.Duration) (string, error)

func (*Store) UpdateClient

func (s *Store) UpdateClient(clientID, clientName string, redirectURIs, grantTypes []string) error

func (*Store) UpdateUser

func (s *Store) UpdateUser(username, email, displayName string) error

func (*Store) UserCount

func (s *Store) UserCount() (int, error)

type User

type User struct {
	ID           string   `json:"id"`
	Username     string   `json:"username"`
	Email        string   `json:"email"`
	DisplayName  string   `json:"displayName"`
	PasswordHash string   `json:"passwordHash"`
	Roles        []string `json:"roles"`
}

Jump to

Keyboard shortcuts

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