Documentation ¶
Index ¶
- type BlocklistTokenMap
- type Service
- func (service *Service) AddTokenToBlocklist(token string)
- func (service *Service) GenerateToken(data *portainer.TokenData) (string, error)
- func (service *Service) GenerateTokenForKubeconfig(data *portainer.TokenData) (string, error)
- func (service *Service) GenerateTokenForOAuth(data *portainer.TokenData, expiryTime *time.Time) (string, error)
- func (service *Service) ParseAndVerifyToken(token string) (*portainer.TokenData, error)
- func (service *Service) SetUserSessionDuration(userSessionDuration time.Duration)
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 ¶
AddTokenToBlocklist adds a token identifier to the token list
func (*Service) GenerateToken ¶
GenerateToken generates a new JWT token.
func (*Service) GenerateTokenForKubeconfig ¶
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 ¶
ParseAndVerifyToken parses a JWT token and verify its validity. It returns an error if token is invalid.
func (*Service) SetUserSessionDuration ¶
SetUserSessionDuration sets the user session duration