jwt

package
v0.0.0-...-270f78c Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Zlib Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlocklistTokenMap

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

func NewBlocklistTokenMap

func NewBlocklistTokenMap(maxTimeToLive int, interval time.Duration) (m *BlocklistTokenMap)

NewBlocklistTokenMap Creates a new blocklist for invalid tokens. The timeout for the element is given as integer

func (*BlocklistTokenMap) IsBlocked

func (m *BlocklistTokenMap) IsBlocked(token string) bool

IsBlocked checks whether the blocklist contains a certain token. When the requested token is expired it does not count as blocked.

func (*BlocklistTokenMap) IsExpired

func (m *BlocklistTokenMap) IsExpired(mapToken *blocklistToken) bool

IsExpired returns true when the token is expired

func (*BlocklistTokenMap) Put

func (m *BlocklistTokenMap) Put(token string)

Put puts an element into the blocklist

func (*BlocklistTokenMap) Remove

func (m *BlocklistTokenMap) Remove(token string)

Remove removes a specific token from the map

func (*BlocklistTokenMap) UpdateList

func (m *BlocklistTokenMap) UpdateList()

UpdateList updates the list and removes old elements

type Service

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

Service represents a service for managing JWT tokens.

func NewService

func NewService(userSessionDuration string, dataStore dataservices.DataStore) (*Service, error)

NewService initializes a new service. It will generate a random key that will be used to sign JWT tokens.

func (*Service) AddTokenToBlocklist

func (service *Service) AddTokenToBlocklist(token string)

AddTokenToBlocklist adds a token identifier to the token list

func (*Service) GenerateToken

func (service *Service) GenerateToken(data *portainer.TokenData) (string, error)

GenerateToken generates a new JWT token.

func (*Service) GenerateTokenForKubeconfig

func (service *Service) GenerateTokenForKubeconfig(data *portainer.TokenData) (string, error)

GenerateTokenForKubeconfig generates a new JWT token for Kubeconfig

func (*Service) GenerateTokenForOAuth

func (service *Service) GenerateTokenForOAuth(data *portainer.TokenData, expiryTime *time.Time) (string, error)

GenerateTokenForOAuth generates a new JWT token for OAuth login token expiry time response from OAuth provider is considered

func (*Service) ParseAndVerifyToken

func (service *Service) ParseAndVerifyToken(token string) (*portainer.TokenData, error)

ParseAndVerifyToken parses a JWT token and verify its validity. It returns an error if token is invalid.

func (*Service) SetUserSessionDuration

func (service *Service) SetUserSessionDuration(userSessionDuration time.Duration)

SetUserSessionDuration sets the user session duration

Jump to

Keyboard shortcuts

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