auth

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseEncryptionKeyBase64

func ParseEncryptionKeyBase64(b64Data string) ([]byte, error)

func ParseSigningKeyPEM

func ParseSigningKeyPEM(pemData []byte) (*ecdsa.PrivateKey, error)

Types

type DriverStore

type DriverStore interface {
	GetDriver(ctx context.Context, driverID int64) (*store.Driver, error)
	InsertDriver(ctx context.Context, driver store.Driver) error
	RecordLogin(ctx context.Context, driverID int64, loginTime time.Time) error
}

type EncryptedClaims

type EncryptedClaims struct {
	EncryptedData string `json:"enc"`
	Nonce         string `json:"nonce"`
}

type IDGenerator

type IDGenerator func() string

type JWTCreator

type JWTCreator interface {
	CreateToken(ctx context.Context, userID int64, userName string, entitlements []string, accessToken, refreshToken string, tokenExpiry time.Time) (string, error)
}

type JWTService

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

func NewJWTService

func NewJWTService(signingKey *ecdsa.PrivateKey, encryptionKey []byte, idGenerator IDGenerator, issuer string, tokenExpiry time.Duration) (*JWTService, error)

func (*JWTService) CreateToken

func (s *JWTService) CreateToken(_ context.Context, userID int64, userName string, entitlements []string, accessToken, refreshToken string, tokenExpiry time.Time) (string, error)

func (*JWTService) ValidateToken

func (s *JWTService) ValidateToken(_ context.Context, tokenString string) (*SessionClaims, *SensitiveClaims, error)

type OAuthClient

type OAuthClient interface {
	ExchangeCode(ctx context.Context, code, codeVerifier, redirectURI string) (*iracing.TokenResponse, error)
	RefreshToken(ctx context.Context, refreshToken string) (*iracing.TokenResponse, error)
}

type Result

type Result struct {
	Token     string
	ExpiresAt time.Time
	UserID    int64
	UserName  string
}

type SensitiveClaims

type SensitiveClaims struct {
	IRacingAccessToken  string `json:"irt"`
	IRacingRefreshToken string `json:"irrt"`
	IRacingTokenExpiry  int64  `json:"irte"`
}

type Service

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

func NewService

func NewService(oauthClient OAuthClient, jwtCreator JWTCreator, userInfoProvider UserInfoProvider, driverStore DriverStore) *Service

func (*Service) HandleCallback

func (s *Service) HandleCallback(ctx context.Context, code, codeVerifier, redirectURI string) (*Result, error)

HandleCallback processes an OAuth callback from iRacing after a user has authenticated is returning to our site

func (*Service) HandleRefresh

func (s *Service) HandleRefresh(ctx context.Context, userID int64, userName string, entitlements []string, refreshToken string) (*Result, error)

HandleRefresh refreshes the iRacing tokens and issues a new JWT

type SessionClaims

type SessionClaims struct {
	jwt.RegisteredClaims
	SessionID       string          `json:"sid"`
	IRacingUserID   int64           `json:"ir_uid"`
	IRacingUserName string          `json:"ir_name"`
	Entitlements    []string        `json:"ent,omitempty"`
	Encrypted       EncryptedClaims `json:"encrypted"`
}

type UserInfoProvider

type UserInfoProvider interface {
	GetUserInfo(ctx context.Context, accessToken string) (*iracing.UserInfo, error)
}

Jump to

Keyboard shortcuts

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