auth

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(subject string, siteID string, ip, ua string) (string, string, error)

func GetMe added in v1.4.0

func GetMe() gin.HandlerFunc

GetMe returns the current authenticated user's profile

func GetMySessions added in v1.6.0

func GetMySessions() gin.HandlerFunc

GetMySessions returns the sessions of the currently authenticated user

func GetProviderLogoutURL added in v1.6.0

func GetProviderLogoutURL(session *database.ExternalSession) string

func IssueNewTokens

func IssueNewTokens(refreshToken string, claims *platjwt.Claims, ip, ua string) (string, string, error)

func ListPublicAuthProviders added in v1.6.0

func ListPublicAuthProviders() gin.HandlerFunc

func Login

func Login() gin.HandlerFunc

func Logout added in v1.3.0

func Logout() gin.HandlerFunc

func OAuth2Callback added in v1.3.0

func OAuth2Callback(provider string) gin.HandlerFunc

func OAuth2Login added in v1.3.0

func OAuth2Login(provider string) gin.HandlerFunc

func RefreshToken

func RefreshToken() gin.HandlerFunc

func RevokeProviderToken added in v1.6.0

func RevokeProviderToken(session *database.ExternalSession) error

func TerminateMySession added in v1.6.0

func TerminateMySession() gin.HandlerFunc

TerminateMySession allows a user to close one of their own sessions

func ValidateRefreshToken

func ValidateRefreshToken(refreshToken string) (*platjwt.Claims, error)

Types

type AppleClaims added in v1.6.0

type AppleClaims struct {
	jwt.RegisteredClaims
	Email         string      `json:"email"`
	EmailVerified interface{} `json:"email_verified"` // Can be bool or string
}

type Claims

type Claims = platjwt.Claims

type LoginResponse added in v1.4.0

type LoginResponse struct {
	Message  string  `json:"message"`
	User     UserDTO `json:"user"`
	Provider string  `json:"provider,omitempty"`
}

LoginResponse defines the structure for a successful login

func BuildLoginResponse added in v1.4.0

func BuildLoginResponse(user database.User, provider string) LoginResponse

BuildLoginResponse creates a standardized login response

type ProviderUserInfo added in v1.3.0

type ProviderUserInfo struct {
	ID    string
	Email string
	Name  string
	Raw   interface{}
}

ProviderUserInfo defines a common structure for user info across providers

type UserDTO added in v1.4.0

type UserDTO struct {
	ID          string      `json:"id"`
	Username    string      `json:"username"`
	Role        string      `json:"role"`
	Status      string      `json:"status"`
	SiteID      *string     `json:"site_id"`
	SiteKey     *string     `json:"site_key,omitempty"`
	Theme       interface{} `json:"theme,omitempty"`
	Permissions interface{} `json:"permissions,omitempty"`
	CreatedAt   *time.Time  `json:"created_at,omitempty"`
	UpdatedAt   *time.Time  `json:"updated_at,omitempty"`
}

UserDTO represents the public user information

func MapUserToDTO added in v1.4.0

func MapUserToDTO(u database.User) UserDTO

MapUserToDTO converts a database user entity to a DTO

Jump to

Keyboard shortcuts

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