Documentation ¶
Index ¶
- Variables
- func StringPtr(s string) *string
- func TimePtr(t time.Time) *time.Time
- type Account
- type AccountType
- type Adapter
- type Session
- type UnimplementedAdapter
- func (a *UnimplementedAdapter) CreateSession(_ context.Context, userID uuid.UUID, expires time.Time) (Session, error)
- func (a *UnimplementedAdapter) CreateUser(_ context.Context, user User) (User, error)
- func (a *UnimplementedAdapter) CreateVerificationToken(_ context.Context, erficationToken VerificationToken) (VerificationToken, 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) (Session, error)
- func (a *UnimplementedAdapter) GetUser(_ context.Context, id uuid.UUID) (User, error)
- func (a *UnimplementedAdapter) GetUserByAccount(_ context.Context, provider string, providerAccountID string) (User, error)
- func (a *UnimplementedAdapter) GetUserByEmail(_ context.Context, email string) (User, error)
- func (a *UnimplementedAdapter) LinkAccount(_ context.Context, accountID, userID uuid.UUID) error
- func (a *UnimplementedAdapter) RefreshSession(_ context.Context, session Session) (Session, error)
- func (a *UnimplementedAdapter) UnlinkAccount(_ context.Context, accountID, userID uuid.UUID) error
- func (a *UnimplementedAdapter) UpdateSession(_ context.Context, session Session) (Session, error)
- func (a *UnimplementedAdapter) UpdateUser(_ context.Context, user User) (User, error)
- func (a *UnimplementedAdapter) UseVerficationToken(_ context.Context, identifier string, token string) (VerificationToken, error)
- type User
- type VerificationToken
Constants ¶
This section is empty.
Variables ¶
var ErrUnimplemented = errors.New("not implemented")
ErrUnimplemented is returned when a method is not implemented.
Functions ¶
Types ¶
type Account ¶
type Account 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 User `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"` }
Account represents an account in a third-party identity provider.
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 User) (User, error) // GetUser retrieves a user by ID. GetUser(ctx context.Context, id uuid.UUID) (User, error) // GetUserByEmail retrieves a user by email. GetUserByEmail(ctx context.Context, email string) (User, error) // UpdateUser updates a user. UpdateUser(ctx context.Context, user User) (User, 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) (Session, error) // GetSession retrieves a session by session token. GetSession(ctx context.Context, sessionToken string) (Session, error) // UpdateSession updates a session. UpdateSession(ctx context.Context, session Session) (Session, error) // RefreshSession refreshes a session. RefreshSession(ctx context.Context, session Session) (Session, 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 VerificationToken) (VerificationToken, error) // UseVerficationToken uses a verification token. UseVerficationToken(ctx context.Context, identifier string, token string) (VerificationToken, error) }
Adapter is an interface that defines the methods for interacting with the underlying data storage.
type Session ¶
type Session 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 User `json:"user"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at"` }
Session ...
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) (Session, error)
CreateSession creates a new session.
func (*UnimplementedAdapter) CreateUser ¶
CreateUser creates a new user.
func (*UnimplementedAdapter) CreateVerificationToken ¶
func (a *UnimplementedAdapter) CreateVerificationToken(_ context.Context, erficationToken VerificationToken) (VerificationToken, 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 ¶
GetSession retrieves a session by session token.
func (*UnimplementedAdapter) GetUserByAccount ¶
func (a *UnimplementedAdapter) GetUserByAccount(_ context.Context, provider string, providerAccountID string) (User, 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 ¶
RefreshSession refreshes a session.
func (*UnimplementedAdapter) UnlinkAccount ¶
UnlinkAccount unlinks an account from a user.
func (*UnimplementedAdapter) UpdateSession ¶
UpdateSession updates a session.
func (*UnimplementedAdapter) UpdateUser ¶
UpdateUser updates a user.
func (*UnimplementedAdapter) UseVerficationToken ¶
func (a *UnimplementedAdapter) UseVerficationToken(_ context.Context, identifier string, token string) (VerificationToken, error)
UseVerficationToken uses a verification token.
type User ¶
type User 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 []Account `json:"accounts" gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"` Sessions []Session `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"` }
User is a user of the application.
type VerificationToken ¶
type VerificationToken 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"` }
VerificationToken ...