Documentation
¶
Index ¶
- Variables
- func StringPtr(s string) *string
- func TimePtr(t time.Time) *time.Time
- type AccountType
- type Adapter
- type GothAccount
- type GothSession
- type GothUser
- type GothVerificationToken
- type UnimplementedAdapter
- func (a *UnimplementedAdapter) CreateSession(_ context.Context, userID uuid.UUID, expires time.Time) (GothSession, error)
- func (a *UnimplementedAdapter) CreateUser(_ context.Context, user GothUser) (GothUser, error)
- func (a *UnimplementedAdapter) CreateVerificationToken(_ context.Context, erficationToken GothVerificationToken) (GothVerificationToken, error)
- func (a *UnimplementedAdapter) DeleteSession(_ context.Context, sessionToken string) error
- func (a *UnimplementedAdapter) DeleteUser(_ context.Context, id uuid.UUID) error
- func (a *UnimplementedAdapter) GetSession(_ context.Context, sessionToken string) (GothSession, error)
- func (a *UnimplementedAdapter) GetUser(_ context.Context, id uuid.UUID) (GothUser, error)
- func (a *UnimplementedAdapter) GetUserByAccount(_ context.Context, provider string, providerAccountID string) (GothUser, error)
- func (a *UnimplementedAdapter) GetUserByEmail(_ context.Context, email string) (GothUser, error)
- func (a *UnimplementedAdapter) LinkAccount(_ context.Context, accountID, userID uuid.UUID) error
- func (a *UnimplementedAdapter) RefreshSession(_ context.Context, session GothSession) (GothSession, error)
- func (a *UnimplementedAdapter) UnlinkAccount(_ context.Context, accountID, userID uuid.UUID) error
- func (a *UnimplementedAdapter) UpdateSession(_ context.Context, session GothSession) (GothSession, error)
- func (a *UnimplementedAdapter) UpdateUser(_ context.Context, user GothUser) (GothUser, error)
- func (a *UnimplementedAdapter) UseVerficationToken(_ context.Context, identifier string, token string) (GothVerificationToken, error)
Constants ¶
This section is empty.
Variables ¶
var ErrUnimplemented = errors.New("not implemented")
ErrUnimplemented is returned when a method is not implemented.
Functions ¶
Types ¶
type AccountType ¶
type AccountType string
AccountType represents the type of an account.
const ( // AccountTypeOAuth2 represents an OAuth2 account type. AccountTypeOAuth2 AccountType = "oauth2" // AccountTypeOIDC represents an OIDC account type. AccountTypeOIDC AccountType = "oidc" // AccountTypeSAML represents a SAML account type. AccountTypeSAML AccountType = "saml" // AccountTypeEmail represents an email account type. AccountTypeEmail AccountType = "email" // AccountTypeWebAuthn represents a WebAuthn account type. AccountTypeWebAuthn AccountType = "webauthn" )
type Adapter ¶
type Adapter interface { // CreateUser creates a new user. CreateUser(ctx context.Context, user GothUser) (GothUser, error) // GetUser retrieves a user by ID. GetUser(ctx context.Context, id uuid.UUID) (GothUser, error) // GetUserByEmail retrieves a user by email. GetUserByEmail(ctx context.Context, email string) (GothUser, error) // UpdateUser updates a user. UpdateUser(ctx context.Context, user GothUser) (GothUser, error) // DeleteUser deletes a user by ID. DeleteUser(ctx context.Context, id uuid.UUID) error // LinkAccount links an account to a user. LinkAccount(ctx context.Context, accountID, userID uuid.UUID) error // UnlinkAccount unlinks an account from a user. UnlinkAccount(ctx context.Context, accountID, userID uuid.UUID) error // CreateSession creates a new session. CreateSession(ctx context.Context, userID uuid.UUID, expires time.Time) (GothSession, error) // GetSession retrieves a session by session token. GetSession(ctx context.Context, sessionToken string) (GothSession, error) // UpdateSession updates a session. UpdateSession(ctx context.Context, session GothSession) (GothSession, error) // RefreshSession refreshes a session. RefreshSession(ctx context.Context, session GothSession) (GothSession, error) // DeleteSession deletes a session by session token. DeleteSession(ctx context.Context, sessionToken string) error // CreateVerificationToken creates a new verification token. CreateVerificationToken(ctx context.Context, verficationToken GothVerificationToken) (GothVerificationToken, error) // UseVerficationToken uses a verification token. UseVerficationToken(ctx context.Context, identifier string, token string) (GothVerificationToken, error) }
Adapter is an interface that defines the methods for interacting with the underlying data storage.
type GothAccount ¶ added in v1.2.1
type GothAccount struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;column:id;default:gen_random_uuid();"` Type AccountType `json:"type" validate:"required"` Provider string `json:"provider" validate:"required"` ProviderAccountID *string `json:"provider_account_id"` RefreshToken *string `json:"refresh_token"` AccessToken *string `json:"access_token"` ExpiresAt *time.Time `json:"expires_at"` TokenType *string `json:"token_type"` Scope *string `json:"scope"` IDToken *string `json:"id_token"` SessionState string `json:"session_state"` UserID *uuid.UUID `json:"user_id"` User GothUser `json:"user" gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
GothAccount represents an account in a third-party identity provider.
type GothSession ¶ added in v1.2.1
type GothSession struct { ID uuid.UUID `json:"id" gorm:"primaryKey;unique;type:uuid;column:id;default:gen_random_uuid()"` ExpiresAt time.Time `json:"expires_at"` SessionToken string `json:"session_token"` UserID uuid.UUID `json:"user_id"` User GothUser `json:"user"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
GothSession is a session for a user.
func (*GothSession) IsValid ¶ added in v1.2.1
func (s *GothSession) IsValid() bool
IsValid returns true if the session is valid.
type GothUser ¶ added in v1.2.1
type GothUser struct { ID uuid.UUID `json:"id" gorm:"primaryKey;unique;type:uuid;column:id;default:gen_random_uuid()"` Name string `json:"name" validate:"required,max=255"` Email string `json:"email" gorm:"uniqueIndex" validate:"required,email"` EmailVerified *bool `json:"email_verified"` Image *string `json:"image" validate:"url"` Accounts []GothAccount `json:"accounts" gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"` Sessions []GothSession `json:"sessions" gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
GothUser is a user of the application.
type GothVerificationToken ¶ added in v1.2.1
type GothVerificationToken struct { Token string `json:"token" gorm:"primaryKey"` Identifier string `json:"identifier"` ExpiresAt time.Time `json:"expires_at"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
GothVerificationToken is a verification token for a user
type UnimplementedAdapter ¶
type UnimplementedAdapter struct{}
UnimplementedAdapter is an adapter that does not implement any of the methods.
func (*UnimplementedAdapter) CreateSession ¶
func (a *UnimplementedAdapter) CreateSession(_ context.Context, userID uuid.UUID, expires time.Time) (GothSession, error)
CreateSession creates a new session.
func (*UnimplementedAdapter) CreateUser ¶
CreateUser creates a new user.
func (*UnimplementedAdapter) CreateVerificationToken ¶
func (a *UnimplementedAdapter) CreateVerificationToken(_ context.Context, erficationToken GothVerificationToken) (GothVerificationToken, error)
CreateVerificationToken creates a new verification token.
func (*UnimplementedAdapter) DeleteSession ¶
func (a *UnimplementedAdapter) DeleteSession(_ context.Context, sessionToken string) error
DeleteSession deletes a session by session token.
func (*UnimplementedAdapter) DeleteUser ¶
DeleteUser deletes a user by ID.
func (*UnimplementedAdapter) GetSession ¶
func (a *UnimplementedAdapter) GetSession(_ context.Context, sessionToken string) (GothSession, error)
GetSession retrieves a session by session token.
func (*UnimplementedAdapter) GetUserByAccount ¶
func (a *UnimplementedAdapter) GetUserByAccount(_ context.Context, provider string, providerAccountID string) (GothUser, error)
GetUserByAccount retrieves a user by account.
func (*UnimplementedAdapter) GetUserByEmail ¶
GetUserByEmail retrieves a user by email.
func (*UnimplementedAdapter) LinkAccount ¶
LinkAccount links an account to a user.
func (*UnimplementedAdapter) RefreshSession ¶
func (a *UnimplementedAdapter) RefreshSession(_ context.Context, session GothSession) (GothSession, error)
RefreshSession refreshes a session.
func (*UnimplementedAdapter) UnlinkAccount ¶
UnlinkAccount unlinks an account from a user.
func (*UnimplementedAdapter) UpdateSession ¶
func (a *UnimplementedAdapter) UpdateSession(_ context.Context, session GothSession) (GothSession, error)
UpdateSession updates a session.
func (*UnimplementedAdapter) UpdateUser ¶
UpdateUser updates a user.
func (*UnimplementedAdapter) UseVerficationToken ¶
func (a *UnimplementedAdapter) UseVerficationToken(_ context.Context, identifier string, token string) (GothVerificationToken, error)
UseVerficationToken uses a verification token.