auth

package
v1.1.26 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveSession

type ActiveSession struct {
	SessionID string   `json:"sessionID"`
	UserID    string   `json:"userID"`
	Roles     []string `json:"roles"`
	Verified  bool     `json:"verified"`
	ExpireAt  string   `json:"expireAt"`
}

ActiveSession represents a session in a list.

type AdminCreateSessionRequest

type AdminCreateSessionRequest struct {
	Kind string `json:"kind"`
}

AdminCreateSessionRequest is the body for admin session creation.

type AdminCreateSessionResponse

type AdminCreateSessionResponse struct {
	Bearer    string `json:"bearer"`
	SessionID string `json:"sessionID"`
}

AdminCreateSessionResponse is returned when an admin creates a session.

type AdminCreateUserRequest

type AdminCreateUserRequest struct {
	Email     string   `json:"email"`
	FullName  string   `json:"fullName"`
	Alias     string   `json:"alias"`
	Roles     []string `json:"roles"`
	PortalURL string   `json:"portalURL"`
	Notify    bool     `json:"notify"`
}

AdminCreateUserRequest is the body for partner user creation.

type AdminCreateUserResponse

type AdminCreateUserResponse struct {
	UserID string `json:"userID"`
}

AdminCreateUserResponse is returned when a partner creates a user.

type AdminListKeyPairsResponse

type AdminListKeyPairsResponse struct {
	Pages    int       `json:"pages"`
	Items    int       `json:"items"`
	KeyPairs []KeyPair `json:"keyPairs"`
}

AdminListKeyPairsResponse is the paginated response for admin key pair listing.

type AdminListSessionsResponse

type AdminListSessionsResponse struct {
	Pages    int             `json:"pages"`
	Items    int             `json:"items"`
	Sessions []ActiveSession `json:"sessions"`
}

AdminListSessionsResponse is the paginated response for admin session listing.

type AdminSetPreferredEmailRequest

type AdminSetPreferredEmailRequest struct {
	EmailID string `json:"emailID"`
}

AdminSetPreferredEmailRequest is the body for admin setting preferred email.

type AdminUserDetailResponse

type AdminUserDetailResponse struct {
	ID       string   `json:"id"`
	Emails   []Email  `json:"emails"`
	Roles    []string `json:"roles"`
	Verified bool     `json:"verified"`
}

AdminUserDetailResponse is returned when fetching a user detail as admin.

type AdminVerificationResponse

type AdminVerificationResponse struct {
	Status    string `json:"status"`
	ExpiresAt string `json:"expiresAt"`
}

AdminVerificationResponse is returned when fetching admin verification status.

type AssignRoleRequest

type AssignRoleRequest struct {
	Role   string `json:"role"`
	UserID string `json:"userID"`
}

AssignRoleRequest is the body for assigning a role to a user.

type AssignRoleResponse

type AssignRoleResponse struct {
	UserID string `json:"userID"`
	Role   string `json:"role"`
}

AssignRoleResponse is returned when a role is assigned.

type CheckKeyPairResponse

type CheckKeyPairResponse struct {
	APIKey   string   `json:"apiKey"`
	KeyID    string   `json:"keyID"`
	Roles    []string `json:"roles"`
	Groups   []string `json:"groups"`
	Verified bool     `json:"verified"`
	ExpireAt string   `json:"expireAt"`
}

CheckKeyPairResponse is returned when checking the current key pair.

type Client

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

Client provides access to the Auth API endpoints.

func NewClient

func NewClient(d doFunc) *Client

NewClient creates a new Auth client backed by the root SDK client's do function.

func (*Client) AdminAssignRole

func (c *Client) AdminAssignRole(ctx context.Context, userID string, req AssignRoleRequest) (*AssignRoleResponse, error)

AdminAssignRole assigns a role to a user.

func (*Client) AdminCreateEmail

func (c *Client) AdminCreateEmail(ctx context.Context, userID string) error

AdminCreateEmail creates an email for a user as admin.

func (*Client) AdminCreateKeyPair

func (c *Client) AdminCreateKeyPair(ctx context.Context, userID string) error

AdminCreateKeyPair creates a key pair for a user as admin.

func (*Client) AdminCreateSession

func (c *Client) AdminCreateSession(ctx context.Context, userID string, req AdminCreateSessionRequest) (*AdminCreateSessionResponse, error)

AdminCreateSession creates a session for a user as admin.

func (*Client) AdminDeleteEmail

func (c *Client) AdminDeleteEmail(ctx context.Context, emailID string) error

AdminDeleteEmail deletes an email as admin.

func (*Client) AdminDeleteKeyPair

func (c *Client) AdminDeleteKeyPair(ctx context.Context, keyID string) error

AdminDeleteKeyPair deletes a key pair as admin.

func (*Client) AdminDeleteSession

func (c *Client) AdminDeleteSession(ctx context.Context, sessionID string) error

AdminDeleteSession deletes a session as admin.

func (*Client) AdminDeleteUser

func (c *Client) AdminDeleteUser(ctx context.Context, userID string) error

AdminDeleteUser deletes a user by ID.

func (*Client) AdminDisableUser

func (c *Client) AdminDisableUser(ctx context.Context, userID string) error

AdminDisableUser disables a user.

func (*Client) AdminEnableUser

func (c *Client) AdminEnableUser(ctx context.Context, userID string) error

AdminEnableUser enables a user.

func (*Client) AdminGetUser

func (c *Client) AdminGetUser(ctx context.Context, userID string) (*AdminUserDetailResponse, error)

AdminGetUser fetches a user by ID as admin.

func (*Client) AdminGetVerification

func (c *Client) AdminGetVerification(ctx context.Context, userID string) (*AdminVerificationResponse, error)

AdminGetVerification gets verification status for a user as admin.

func (*Client) AdminListKeyPairs

func (c *Client) AdminListKeyPairs(ctx context.Context, opts *ListOpts) (*AdminListKeyPairsResponse, error)

AdminListKeyPairs lists all key pairs as admin.

func (*Client) AdminListRoles

func (c *Client) AdminListRoles(ctx context.Context, userID string) (*ListRolesResponse, error)

AdminListRoles lists roles for a user.

func (*Client) AdminListSessions

func (c *Client) AdminListSessions(ctx context.Context, opts *ListOpts) (*AdminListSessionsResponse, error)

AdminListSessions lists all sessions as admin.

func (*Client) AdminListUsers

func (c *Client) AdminListUsers(ctx context.Context, opts *ListUsersOptions) (*ListUsersResponse, error)

AdminListUsers lists users with optional filtering.

func (*Client) AdminRemoveRole

func (c *Client) AdminRemoveRole(ctx context.Context, userID, roleName string) error

AdminRemoveRole removes a role from a user.

func (*Client) AdminResetVerification

func (c *Client) AdminResetVerification(ctx context.Context, userID string) (*Verification, error)

AdminResetVerification resets verification for a user as admin.

func (*Client) AdminRevokeVerification

func (c *Client) AdminRevokeVerification(ctx context.Context, userID string) (*Verification, error)

AdminRevokeVerification revokes verification for a user as admin.

func (*Client) AdminSetPreferredEmail

func (c *Client) AdminSetPreferredEmail(ctx context.Context, req AdminSetPreferredEmailRequest) error

AdminSetPreferredEmail sets the preferred email as admin.

func (*Client) AdminUnverifyUser

func (c *Client) AdminUnverifyUser(ctx context.Context, userID string) error

AdminUnverifyUser un-verifies a user.

func (*Client) AdminVerifyEmail

func (c *Client) AdminVerifyEmail(ctx context.Context, emailID string) error

AdminVerifyEmail verifies an email as admin.

func (*Client) AdminVerifyKeyPair

func (c *Client) AdminVerifyKeyPair(ctx context.Context, keyID string) error

AdminVerifyKeyPair verifies a key pair as admin.

func (*Client) AdminVerifySession

func (c *Client) AdminVerifySession(ctx context.Context, sessionID string) error

AdminVerifySession verifies a session as admin.

func (*Client) AdminVerifyUser

func (c *Client) AdminVerifyUser(ctx context.Context, userID string) error

AdminVerifyUser verifies a user.

func (*Client) CheckKeyPair

func (c *Client) CheckKeyPair(ctx context.Context) (*CheckKeyPairResponse, error)

CheckKeyPair returns the current key pair details.

func (*Client) CreateEmail

func (c *Client) CreateEmail(ctx context.Context, req CreateEmailRequest) (*CreateEmailResponse, error)

CreateEmail creates a new email address for the user.

func (*Client) CreateKeyPair

func (c *Client) CreateKeyPair(ctx context.Context, req CreateKeyPairRequest) (*CreateKeyPairResponse, error)

CreateKeyPair creates a new API key pair.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, req CreateSessionRequest) (*CreateSessionResponse, error)

CreateSession creates a new session.

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, req CreateUserRequest) (*CreateSessionResponse, error)

CreateUser creates a new user account.

func (*Client) CreateVerification

func (c *Client) CreateVerification(ctx context.Context) (*CreateVerificationResponse, error)

CreateVerification creates a new identity verification.

func (*Client) DeleteEmail

func (c *Client) DeleteEmail(ctx context.Context, emailID string) error

DeleteEmail deletes an email address by ID.

func (*Client) DeleteKeyPair

func (c *Client) DeleteKeyPair(ctx context.Context, keyID string) error

DeleteKeyPair deletes a key pair by ID.

func (*Client) DeleteSession

func (c *Client) DeleteSession(ctx context.Context, sessionID string) error

DeleteSession deletes a session by ID.

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context) error

DeleteUser deletes the current user account.

func (*Client) ExtendSession

func (c *Client) ExtendSession(ctx context.Context) error

ExtendSession extends the current session TTL.

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context) (*GetSessionResponse, error)

GetSession returns the current session.

func (*Client) GetUserByEmail

func (c *Client) GetUserByEmail(ctx context.Context, email string) (*GetUserByEmailResponse, error)

GetUserByEmail fetches a user by their email address.

func (*Client) GetUserByID

func (c *Client) GetUserByID(ctx context.Context, userID string) (*GetUserResponse, error)

GetUserByID fetches a user by their ID.

func (*Client) GetVerificationStatus

func (c *Client) GetVerificationStatus(ctx context.Context) (*VerificationStatusResponse, error)

GetVerificationStatus returns the current identity verification status.

func (*Client) ListEmails

func (c *Client) ListEmails(ctx context.Context) ([]Email, error)

ListEmails lists all email addresses for the user.

func (*Client) ListKeyPairs

func (c *Client) ListKeyPairs(ctx context.Context) ([]KeyPair, error)

ListKeyPairs lists all key pairs for the user.

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context) ([]ActiveSession, error)

ListSessions lists all active sessions for the current user.

func (*Client) PartnerCreateUser

func (c *Client) PartnerCreateUser(ctx context.Context, req AdminCreateUserRequest) (*AdminCreateUserResponse, error)

PartnerCreateUser creates a new user on behalf of a partner.

func (*Client) SetPreferredEmail

func (c *Client) SetPreferredEmail(ctx context.Context, req SetPreferredEmailRequest) error

SetPreferredEmail sets the preferred email address.

func (*Client) VerifyEmail

func (c *Client) VerifyEmail(ctx context.Context, req VerifyEmailRequest) error

VerifyEmail verifies an email address with the provided code.

func (*Client) VerifyKeyPair

func (c *Client) VerifyKeyPair(ctx context.Context, req VerifyKeyPairRequest) error

VerifyKeyPair verifies a key pair with the provided code.

func (*Client) VerifySession

func (c *Client) VerifySession(ctx context.Context, req VerifySessionRequest) error

VerifySession verifies a session with the provided code.

type CreateEmailRequest

type CreateEmailRequest struct {
	Address string `json:"address"`
}

CreateEmailRequest is the body for creating a new email address.

type CreateEmailResponse

type CreateEmailResponse struct {
	VerificationCodeID string `json:"verificationCodeID"`
}

CreateEmailResponse is returned when an email is created.

type CreateKeyPairRequest

type CreateKeyPairRequest struct {
	Name string `json:"name"`
	Days int    `json:"days"`
}

CreateKeyPairRequest is the body for creating a new API key pair.

type CreateKeyPairResponse

type CreateKeyPairResponse struct {
	APIKey             string `json:"apiKey"`
	APISecret          string `json:"apiSecret"`
	KeyID              string `json:"keyID"`
	ExpireAt           string `json:"expireAt"`
	Verified           bool   `json:"verified"`
	VerificationCodeID string `json:"verificationCodeID"`
}

CreateKeyPairResponse is returned when a key pair is created.

type CreateSessionRequest

type CreateSessionRequest struct {
	Email string `json:"email"`
	Kind  string `json:"kind"`
}

CreateSessionRequest is the body for creating a new session.

type CreateSessionResponse

type CreateSessionResponse struct {
	Bearer             string `json:"bearer"`
	SessionID          string `json:"sessionID"`
	ExpireAt           string `json:"expireAt"`
	VerificationCodeID string `json:"verificationCodeID"`
}

CreateSessionResponse is returned when a session is created.

type CreateUserRequest

type CreateUserRequest struct {
	Email    string `json:"email"`
	FullName string `json:"fullName"`
	Alias    string `json:"alias"`
}

CreateUserRequest is the body for creating a new user.

type CreateVerificationResponse

type CreateVerificationResponse struct {
	URL          string `json:"url"`
	SessionID    string `json:"sessionId"`
	ClientSecret string `json:"clientSecret"`
	Status       string `json:"status"`
}

CreateVerificationResponse is returned when creating an identity verification.

type Email

type Email struct {
	ID        string `json:"id"`
	Address   string `json:"address"`
	Verified  bool   `json:"verified"`
	Preferred bool   `json:"preferred"`
}

Email represents a user's email address.

type GetSessionResponse

type GetSessionResponse struct {
	SessionID string   `json:"sessionID"`
	UserID    string   `json:"userID"`
	Roles     []string `json:"roles"`
	Groups    []string `json:"groups"`
	Verified  bool     `json:"verified"`
	ExpireAt  string   `json:"expireAt"`
}

GetSessionResponse is returned when fetching the current session.

type GetUserByEmailResponse

type GetUserByEmailResponse struct {
	UserID string `json:"userID"`
}

GetUserByEmailResponse is returned when fetching a user by email.

type GetUserResponse

type GetUserResponse struct {
	Alias string `json:"alias"`
}

GetUserResponse is returned when fetching a user by ID.

type KeyPair

type KeyPair struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Verified bool   `json:"verified"`
	ExpireAt string `json:"expireAt"`
}

KeyPair represents a user's API key pair.

type ListOpts

type ListOpts struct {
	Limit int
	Page  int
}

ListOpts holds pagination parameters for admin list endpoints.

type ListRolesResponse

type ListRolesResponse struct {
	UserID string   `json:"userID"`
	Roles  []string `json:"roles"`
}

ListRolesResponse is returned when listing roles for a user.

type ListUsersOptions

type ListUsersOptions struct {
	Limit   int    `url:"limit,omitempty"`
	Page    int    `url:"page,omitempty"`
	Enabled *bool  `url:"enabled,omitempty"`
	Role    string `url:"role,omitempty"`
}

ListUsersOptions provides filtering for the admin user list endpoint.

type ListUsersResponse

type ListUsersResponse struct {
	Pages int            `json:"pages"`
	Items int            `json:"items"`
	Users []UserResponse `json:"users"`
}

ListUsersResponse is the paginated response for listing users.

type SetPreferredEmailRequest

type SetPreferredEmailRequest struct {
	EmailID string `json:"emailID"`
}

SetPreferredEmailRequest is the body for setting a preferred email.

type UserResponse

type UserResponse struct {
	ID       string   `json:"id"`
	Emails   []Email  `json:"emails"`
	Roles    []string `json:"roles"`
	Verified bool     `json:"verified"`
	Enabled  bool     `json:"enabled"`
}

UserResponse is a user in a paginated list.

type Verification

type Verification struct {
	Status    string `json:"status"`
	ExpiresAt string `json:"expiresAt"`
}

Verification represents a verification record.

type VerificationStatusResponse

type VerificationStatusResponse struct {
	Status      string `json:"status"`
	ExpiresAt   string `json:"expiresAt"`
	Attempts    int    `json:"attempts"`
	MaxAttempts int    `json:"maxAttempts"`
}

VerificationStatusResponse is returned when checking verification status.

type VerifyEmailRequest

type VerifyEmailRequest struct {
	Code               string `json:"code"`
	VerificationCodeID string `json:"verificationCodeID"`
}

VerifyEmailRequest is the body for verifying an email address.

type VerifyKeyPairRequest

type VerifyKeyPairRequest struct {
	Code               string `json:"code"`
	VerificationCodeID string `json:"verificationCodeID"`
}

VerifyKeyPairRequest is the body for verifying a key pair.

type VerifySessionRequest

type VerifySessionRequest struct {
	Code               string `json:"code"`
	VerificationCodeID string `json:"verificationCodeID"`
}

VerifySessionRequest is the body for verifying a session.

Jump to

Keyboard shortcuts

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