Help us shape the future of Go! Take the 2026 Go Developer Survey

authentication

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentCreatorScope = "write:content"
	ContentEditorScope  = "edit:content"
	ContentDeleteScope  = "delete:content"
)

Variables

View Source
var ErrAuthDisabled = errors.New("authentication is disabled")

ErrAuthDisabled is returned by every NoopClient method. It surfaces as a regular GraphQL error for resolvers that need the Logto management API, which is the intended behavior when the server runs with auth disabled.

Functions

func CheckReadUser

func CheckReadUser(ctx context.Context) error

func ValidateContent

func ValidateContent(
	ctx context.Context,
	scopeSlot string,
	expectedScope string,
) error

Types

type APIUsersPatchCustomData

type APIUsersPatchCustomData struct {
	CustomData AdditionalUserInformation `json:"customData"`
}

type APIUsersPostReq

type APIUsersPostReq struct {
	PrimaryPhone string `json:"primaryPhone"`
	PrimaryEmail string `json:"primaryEmail"`
	Username     string `json:"username"`
	Password     string `json:"password"`
	Name         string `json:"name"`
}

type APIUsersPostRes

type APIUsersPostRes struct {
	ID string `json:"id"`
}

type APIUsersSearchRes

type APIUsersSearchRes struct {
	Email    string `json:"primaryEmail"`
	ID       string `json:"id"`
	UserName string `json:"username"`
}

type AccessTokenResp

type AccessTokenResp struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	TokenType   string `json:"token_type"`
}

type AdditionalUserInformation

type AdditionalUserInformation struct {
	Profession       string `json:"profession"`
	JobTitle         string `json:"job_title"`
	Institution      string `json:"institution"`
	Address          string `json:"address"`
	SecondaryAddress string `json:"secondary_address"`
	City             string `json:"city"`
	State            string `json:"state"`
	Region           string `json:"region"`
	Country          string `json:"country"`
	Zipcode          string `json:"zipcode"`
	Subscribed       bool   `json:"subscribed"`
	ResearchInterest string `json:"research_interest"`
	Phone            string `json:"phone"`
}

type CustomTime

type CustomTime struct {
	time.Time
}

func (*CustomTime) UnmarshalJSON

func (ct *CustomTime) UnmarshalJSON(input []byte) error

type LogtoClient

type LogtoClient interface {
	AccessToken() (*AccessTokenResp, error)
	CheckUserWithUserName(string) (bool, string, error)
	UserWithEmail(string) (*UserResp, error)
	CheckUser(string) (bool, string, error)
	AddCustomUserInformation(string, string, *APIUsersPatchCustomData) error
	User(string) (*UserResp, error)
	Roles(string) ([]*RoleResp, error)
	Permissions(string) ([]*PermissionResp, error)
	CreateUser(string, *APIUsersPostReq) (string, error)
}

func NewClient

func NewClient(params *LogtoClientParams) LogtoClient

NewClient creates a new instance of the Client struct. It takes an endpoint string as a parameter and returns a pointer to the Client struct.

type LogtoClientParams

type LogtoClientParams struct {
	URL, AppID, AppSecret, APIResource, Key string
	TokenCache                              repository.Repository
}

type NoopClient

type NoopClient struct{}

NoopClient is a stub LogtoClient registered in place of the real Logto management client when the graphql-server runs with --auth-enabled=false. It satisfies the LogtoClient interface so that the registry and resolvers need no conditional logic; calls simply fail with ErrAuthDisabled.

func (NoopClient) AccessToken

func (NoopClient) AccessToken() (*AccessTokenResp, error)

func (NoopClient) AddCustomUserInformation

func (NoopClient) AddCustomUserInformation(
	string,
	string,
	*APIUsersPatchCustomData,
) error

func (NoopClient) CheckUser

func (NoopClient) CheckUser(string) (bool, string, error)

func (NoopClient) CheckUserWithUserName

func (NoopClient) CheckUserWithUserName(string) (bool, string, error)

func (NoopClient) CreateUser

func (NoopClient) CreateUser(string, *APIUsersPostReq) (string, error)

func (NoopClient) Permissions

func (NoopClient) Permissions(string) ([]*PermissionResp, error)

func (NoopClient) Roles

func (NoopClient) Roles(string) ([]*RoleResp, error)

func (NoopClient) User

func (NoopClient) User(string) (*UserResp, error)

func (NoopClient) UserWithEmail

func (NoopClient) UserWithEmail(string) (*UserResp, error)

type PermissionResp

type PermissionResp struct {
	TenantID    string    `json:"tenantId"`
	ID          string    `json:"id"`
	ResourceID  string    `json:"resourceId"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
	Resource    struct {
		TenantID       string `json:"tenantId"`
		ID             string `json:"id"`
		Name           string `json:"name"`
		Indicator      string `json:"indicator"`
		IsDefault      bool   `json:"isDefault"`
		AccessTokenTTL int    `json:"accessTokenTtl"`
	} `json:"resource"`
}

type RoleResp

type RoleResp struct {
	TenantID    string `json:"tenantId"`
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Rtype       string `json:"type"`
}

type UserResp

type UserResp struct {
	ID           string `json:"id"`
	Username     string `json:"username"`
	PrimaryEmail string `json:"primaryEmail"`
	PrimaryPhone string `json:"primaryPhone"`
	Name         string `json:"name"`
	Avatar       any    `json:"avatar,omitempty"`
	CustomData   struct {
		City             string `json:"city,omitempty"`
		Phone            string `json:"phone,omitempty"`
		State            string `json:"state,omitempty"`
		Region           string `json:"region,omitempty"`
		Address          string `json:"address,omitempty"`
		Country          string `json:"country,omitempty"`
		Zipcode          string `json:"zipcode,omitempty"`
		JobTitle         string `json:"job_title,omitempty"`
		Profession       string `json:"profession,omitempty"`
		Subscribed       bool   `json:"subscribed,omitempty"`
		Institution      string `json:"institution,omitempty"`
		ResearchInterest string `json:"research_interest,omitempty"`
		SecondaryAddress string `json:"secondary_address,omitempty"`
	} `json:"customData"`
	Identities    struct{}   `json:"identities"`
	CreatedAt     CustomTime `json:"createdAt"`
	ApplicationID any        `json:"applicationId,omitempty"`
	IsSuspended   bool       `json:"isSuspended,omitempty"`
}

Jump to

Keyboard shortcuts

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