auths

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const SessionCookieName = "walrus_session"

Variables

View Source
var (
	// MaxIdleDurationConfig holds the config of the max idle duration.
	MaxIdleDurationConfig = vars.SetOnce[time.Duration]{}

	// SecureConfig holds the config of securing.
	SecureConfig = vars.SetOnce[bool]{}

	// EncryptorConfig holds the config of the token encryptor.
	EncryptorConfig = vars.NewSetOnce[cryptox.Encryptor](cryptox.Null())
)

Functions

func CreateAccessToken

func CreateAccessToken(
	ctx context.Context,
	mc model.ClientSet,
	subjectID object.ID,
	kind, name string,
	expirationSeconds *int,
) (*model.Token, error)

CreateAccessToken creates a token with the given kind, name and expiration in seconds.

Types

type Account

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

func RequestAccount

func RequestAccount(mc model.ClientSet, withAuthn bool) Account

func (Account) Authorize

func (a Account) Authorize(c *gin.Context, p runtime.RouteProfile) int

Authorize implements the runtime.RouteAuthorizer interface.

func (Account) CreateToken

func (a Account) CreateToken(req CreateTokenRequest) (CreateTokenResponse, error)

CreateToken creates a new API token for the session subject.

func (Account) DeleteToken

func (a Account) DeleteToken(req DeleteTokenRequest) error

DeleteToken deletes a API token of the session subject.

func (Account) Filter

func (a Account) Filter(c *gin.Context)

Filter is a gin middleware that filters the request, and set the subject to the context.

func (Account) GetInfo

func (a Account) GetInfo(req GetInfoRequest) (GetInfoResponse, error)

GetInfo returns the session subject.

func (Account) GetTokens

func (a Account) GetTokens(req GetTokensRequest) (GetTokensResponse, int, error)

func (Account) Login

func (a Account) Login(req LoginRequest) (LoginResponse, error)

Login logins a subject with the given username and password.

func (Account) Logout

func (a Account) Logout(req LogoutRequest) error

Logout logouts the session subject.

func (Account) UpdateInfo

func (a Account) UpdateInfo(req UpdateInfoRequest) error

UpdateInfo updates the session subject.

type CreateTokenRequest

type CreateTokenRequest struct {
	Name              string `json:"name"`
	ExpirationSeconds *int   `json:"expirationSeconds,omitempty"`

	Context *gin.Context
	// contains filtered or unexported fields
}

func (*CreateTokenRequest) SetGinContext

func (r *CreateTokenRequest) SetGinContext(ctx *gin.Context)

func (*CreateTokenRequest) Validate

func (r *CreateTokenRequest) Validate() error

type CreateTokenResponse

type CreateTokenResponse = *model.TokenOutput

type DeleteTokenRequest

type DeleteTokenRequest struct {
	model.TokenDeleteInput `path:",inline"`
	// contains filtered or unexported fields
}

type GetInfoRequest

type GetInfoRequest struct {
	Context *gin.Context
	// contains filtered or unexported fields
}

func (*GetInfoRequest) SetGinContext

func (r *GetInfoRequest) SetGinContext(ctx *gin.Context)

type GetInfoResponse

type GetInfoResponse = *session.Subject

type GetTokensRequest

type GetTokensRequest struct {
	model.TokenQueryInputs `path:",inline" query:",inline"`

	runtime.RequestCollection[
		predicate.Token, token.OrderOption,
	] `query:",inline"`
	// contains filtered or unexported fields
}

type GetTokensResponse

type GetTokensResponse = []*model.TokenOutput

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`

	Context *gin.Context
	// contains filtered or unexported fields
}

func (*LoginRequest) SetGinContext

func (r *LoginRequest) SetGinContext(ctx *gin.Context)

func (*LoginRequest) Validate

func (r *LoginRequest) Validate() error

type LoginResponse

type LoginResponse = *session.Subject

type LogoutRequest

type LogoutRequest struct {
	Context *gin.Context
	// contains filtered or unexported fields
}

func (*LogoutRequest) SetGinContext

func (r *LogoutRequest) SetGinContext(ctx *gin.Context)

type UpdateInfoRequest

type UpdateInfoRequest struct {
	Password    string `json:"password,omitempty"`
	OldPassword string `json:"oldPassword,omitempty"`

	Context *gin.Context
	// contains filtered or unexported fields
}

func (*UpdateInfoRequest) SetGinContext

func (r *UpdateInfoRequest) SetGinContext(ctx *gin.Context)

func (*UpdateInfoRequest) Validate

func (r *UpdateInfoRequest) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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