tokens

package
v1.11.11 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DenyJTI added in v1.1.0

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

	ServerUuid string `json:"server_uuid"`
	BackupUuid string `json:"backup_uuid"`
	UniqueId   string `json:"unique_id"`
}

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
	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 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
}

func (*TransferPayload) GetPayload

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

GetPayload returns the JWT payload.

type UploadPayload

type UploadPayload struct {
	jwt.Payload

	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

	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 added in v1.1.0

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