tokens

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Websocket      = JwtScope("websocket")
	FileUpload     = JwtScope("file-upload")
	FileDownload   = JwtScope("file-download")
	BackupDownload = JwtScope("backup-download")
	ServerTransfer = JwtScope("transfer")
)

Variables

This section is empty.

Functions

func DenyForServer added in v1.3.0

func DenyForServer(s string, u string)

DenyForServer adds a user UUID to the denylist marking any existing JWTs issued to the user as being invalid. This is associated with the user.

func DenyJTI

func DenyJTI(jti string)

Adds a JTI to the denylist by marking any JWTs generated before the current time as being invalid if they use the same JTI.

func ParseToken

func ParseToken(token []byte, data TokenData) error

Validates the provided JWT against the known secret for the Daemon and returns the parsed data. This function DOES NOT validate that the token is valid for the connected server, nor does it ensure that the user providing the token is able to actually do things.

This simply returns a parsed token.

Types

type BackupPayload

type BackupPayload struct {
	jwt.Payload
	Scoped

	ServerUuid     string `json:"server_uuid"`
	BackupUuid     string `json:"backup_uuid"`
	SnapshotId     string `json:"snapshot_id,omitempty"`
	UniqueId       string `json:"unique_id"`
	BackupDisk     string `json:"backup_disk,omitempty"`
	RepositoryType string `json:"repository_type,omitempty"`
}

func (*BackupPayload) GetPayload

func (p *BackupPayload) GetPayload() *jwt.Payload

Returns the JWT payload.

func (*BackupPayload) IsUniqueRequest

func (p *BackupPayload) IsUniqueRequest() bool

Determines if this JWT is valid for the given request cycle. If the unique ID passed in the token has already been seen before this will return false. This allows us to use this JWT as a one-time token that validates all of the request.

type FilePayload

type FilePayload struct {
	jwt.Payload
	Scoped

	FilePath   string `json:"file_path"`
	ServerUuid string `json:"server_uuid"`
	UniqueId   string `json:"unique_id"`
}

func (*FilePayload) GetPayload

func (p *FilePayload) GetPayload() *jwt.Payload

Returns the JWT payload.

func (*FilePayload) IsUniqueRequest

func (p *FilePayload) IsUniqueRequest() bool

Determines if this JWT is valid for the given request cycle. If the unique ID passed in the token has already been seen before this will return false. This allows us to use this JWT as a one-time token that validates all of the request.

type JwtScope added in v1.4.0

type JwtScope string

type Scoped added in v1.4.0

type Scoped struct {
	Scope string `json:"scope"`
}

func (Scoped) HasScope added in v1.4.0

func (s Scoped) HasScope(scope JwtScope) bool

func (Scoped) Scopes added in v1.4.0

func (s Scoped) Scopes() []string

type TokenData

type TokenData interface {
	GetPayload() *jwt.Payload
}

type TokenStore

type TokenStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*TokenStore) IsValidToken

func (t *TokenStore) IsValidToken(token string) bool

Checks if a token is valid or not.

type TransferPayload

type TransferPayload struct {
	jwt.Payload
	Scoped
}

func (*TransferPayload) GetPayload

func (p *TransferPayload) GetPayload() *jwt.Payload

GetPayload returns the JWT payload.

type UploadPayload

type UploadPayload struct {
	jwt.Payload
	Scoped

	ServerUuid string `json:"server_uuid"`
	UserUuid   string `json:"user_uuid"`
	UniqueId   string `json:"unique_id"`
}

func (*UploadPayload) GetPayload

func (p *UploadPayload) GetPayload() *jwt.Payload

Returns the JWT payload.

func (*UploadPayload) IsUniqueRequest

func (p *UploadPayload) IsUniqueRequest() bool

Determines if this JWT is valid for the given request cycle. If the unique ID passed in the token has already been seen before this will return false. This allows us to use this JWT as a one-time token that validates all of the request.

type WebsocketPayload

type WebsocketPayload struct {
	jwt.Payload
	sync.RWMutex
	Scoped

	UserUUID    string   `json:"user_uuid"`
	ServerUUID  string   `json:"server_uuid"`
	Permissions []string `json:"permissions"`
}

WebsocketPayload defines the JWT payload for a websocket connection. This JWT is passed along to the websocket after it has been connected to by sending an "auth" event.

func (*WebsocketPayload) Denylisted

func (p *WebsocketPayload) Denylisted() bool

Check if the JWT has been marked as denied by the instance due to either being issued before Wings was booted, or because we have denied all tokens with the same JTI occurring before a set time.

func (*WebsocketPayload) GetPayload

func (p *WebsocketPayload) GetPayload() *jwt.Payload

Returns the JWT payload.

func (*WebsocketPayload) GetServerUuid

func (p *WebsocketPayload) GetServerUuid() string

Returns the UUID of the server associated with this JWT.

func (*WebsocketPayload) HasPermission

func (p *WebsocketPayload) HasPermission(permission string) bool

Checks if the given token payload has a permission string.

Jump to

Keyboard shortcuts

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