Documentation
¶
Index ¶
- Variables
- func GenerateRefreshToken() (string, error)
- func HashToken(raw string) string
- func UserIDFromContext(ctx context.Context) (string, bool)
- type Blocklist
- type Claims
- type MySQLStore
- func (s *MySQLStore) DeleteAllRefreshTokens(ctx context.Context, userId string) error
- func (s *MySQLStore) DeleteRefreshToken(ctx context.Context, hash string) error
- func (s *MySQLStore) GetRefreshToken(ctx context.Context, hash string) (*RefreshToken, error)
- func (s *MySQLStore) SaveRefreshToken(ctx context.Context, token RefreshToken) error
- type PostgresStore
- func (s *PostgresStore) DeleteAllRefreshTokens(ctx context.Context, userId string) error
- func (s *PostgresStore) DeleteRefreshToken(ctx context.Context, hash string) error
- func (s *PostgresStore) GetRefreshToken(ctx context.Context, hash string) (*RefreshToken, error)
- func (s *PostgresStore) SaveRefreshToken(ctx context.Context, token RefreshToken) error
- type RedisBlocklist
- type RedisStore
- func (s *RedisStore) DeleteAllRefreshTokens(ctx context.Context, userId string) error
- func (s *RedisStore) DeleteRefreshToken(ctx context.Context, hash string) error
- func (s *RedisStore) GetRefreshToken(ctx context.Context, hash string) (*RefreshToken, error)
- func (s *RedisStore) SaveRefreshToken(ctx context.Context, token RefreshToken) error
- type RefreshToken
- type SQLiteStore
- func (s *SQLiteStore) DeleteAllRefreshTokens(ctx context.Context, userId string) error
- func (s *SQLiteStore) DeleteRefreshToken(ctx context.Context, hash string) error
- func (s *SQLiteStore) GetRefreshToken(ctx context.Context, hash string) (*RefreshToken, error)
- func (s *SQLiteStore) SaveRefreshToken(ctx context.Context, token RefreshToken) error
- type Seal
- func (s *Seal) ExtractJTI(tokenString string) (jti string, remaining time.Duration, err error)
- func (s *Seal) GenerateAccessToken(userID string) (string, error)
- func (s *Seal) IssueTokens(ctx context.Context, userID string) (accessToken string, refreshToken string, err error)
- func (s *Seal) Logout(ctx context.Context, userID string, rawToken string) error
- func (s *Seal) Middleware() func(next http.Handler) http.Handler
- func (s *Seal) ParseToken(tokenString string) (userID string, jti string, err error)
- func (s *Seal) RefreshTokens(ctx context.Context, rawToken string) (accessToken string, refreshToken string, err error)
- func (s *Seal) RevokeAll(ctx context.Context, userID string) error
- func (s *Seal) RevokeToken(ctx context.Context, rawToken string) error
- func (s *Seal) ValidateAccessToken(tokenString string) (userID string, jti string, err error)
- type SealConfig
- type SealError
- type Store
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidCredentials = NewSealError("invalid_credentials", "Invalid username or password") ErrTokenExpired = NewSealError("token_expired", "The token has expired") ErrTokenInvalid = NewSealError("token_invalid", "The token is invalid") ErrInternalServer = NewSealError("internal_server_error", "An internal server error occurred") ErrTokenNotFound = NewSealError("token_not_found", "Refresh token not found") ErrUserNotFound = NewSealError("user_not_found", "User not found") ErrUserExists = NewSealError("user_exists", "User already exists") ErrTokenRevoked = NewSealError("token_revoked", "Token has been revoked") )
Functions ¶
func GenerateRefreshToken ¶
Types ¶
type Claims ¶
type Claims struct {
UserID string `json:"user_id"`
jwt.RegisteredClaims
}
type MySQLStore ¶
type MySQLStore struct {
// contains filtered or unexported fields
}
func NewMySQLStore ¶
func NewMySQLStore(db *sql.DB) *MySQLStore
func (*MySQLStore) DeleteAllRefreshTokens ¶
func (s *MySQLStore) DeleteAllRefreshTokens(ctx context.Context, userId string) error
func (*MySQLStore) DeleteRefreshToken ¶
func (s *MySQLStore) DeleteRefreshToken(ctx context.Context, hash string) error
func (*MySQLStore) GetRefreshToken ¶
func (s *MySQLStore) GetRefreshToken(ctx context.Context, hash string) (*RefreshToken, error)
func (*MySQLStore) SaveRefreshToken ¶
func (s *MySQLStore) SaveRefreshToken(ctx context.Context, token RefreshToken) error
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
func NewPostgresStore ¶
func NewPostgresStore(db *pgxpool.Pool) *PostgresStore
func (*PostgresStore) DeleteAllRefreshTokens ¶
func (s *PostgresStore) DeleteAllRefreshTokens(ctx context.Context, userId string) error
func (*PostgresStore) DeleteRefreshToken ¶
func (s *PostgresStore) DeleteRefreshToken(ctx context.Context, hash string) error
func (*PostgresStore) GetRefreshToken ¶
func (s *PostgresStore) GetRefreshToken(ctx context.Context, hash string) (*RefreshToken, error)
func (*PostgresStore) SaveRefreshToken ¶
func (s *PostgresStore) SaveRefreshToken(ctx context.Context, token RefreshToken) error
type RedisBlocklist ¶
type RedisBlocklist struct {
// contains filtered or unexported fields
}
func NewRedisBlocklist ¶
func NewRedisBlocklist(client *redis.Client) *RedisBlocklist
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func NewRedisStore ¶
func NewRedisStore(client *redis.Client) *RedisStore
func (*RedisStore) DeleteAllRefreshTokens ¶
func (s *RedisStore) DeleteAllRefreshTokens(ctx context.Context, userId string) error
func (*RedisStore) DeleteRefreshToken ¶
func (s *RedisStore) DeleteRefreshToken(ctx context.Context, hash string) error
func (*RedisStore) GetRefreshToken ¶
func (s *RedisStore) GetRefreshToken(ctx context.Context, hash string) (*RefreshToken, error)
func (*RedisStore) SaveRefreshToken ¶
func (s *RedisStore) SaveRefreshToken(ctx context.Context, token RefreshToken) error
type RefreshToken ¶
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
func NewSQLiteStore ¶
func NewSQLiteStore(db *sql.DB) *SQLiteStore
func (*SQLiteStore) DeleteAllRefreshTokens ¶
func (s *SQLiteStore) DeleteAllRefreshTokens(ctx context.Context, userId string) error
func (*SQLiteStore) DeleteRefreshToken ¶
func (s *SQLiteStore) DeleteRefreshToken(ctx context.Context, hash string) error
func (*SQLiteStore) GetRefreshToken ¶
func (s *SQLiteStore) GetRefreshToken(ctx context.Context, hash string) (*RefreshToken, error)
func (*SQLiteStore) SaveRefreshToken ¶
func (s *SQLiteStore) SaveRefreshToken(ctx context.Context, token RefreshToken) error
type Seal ¶
type Seal struct {
// contains filtered or unexported fields
}
func NewSeal ¶
func NewSeal(config *SealConfig) *Seal
func (*Seal) ExtractJTI ¶
func (*Seal) GenerateAccessToken ¶
func (*Seal) IssueTokens ¶
func (*Seal) ParseToken ¶
func (*Seal) RefreshTokens ¶
type SealConfig ¶
type SealError ¶
func NewSealError ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.