Documentation ¶
Index ¶
- Variables
- func ClaimsFromJwt(jwtString string) (string, string, int, error)
- func IsCorrupted(jwtString string) (string, string, int, error)
- type AppToken
- func (appToken *AppToken) AddMember(userUuid string)
- func (appToken AppToken) CompareHash(orgn, appName string) bool
- func (appToken AppToken) HasRead(userUuid string, userOrgn string) error
- func (appToken AppToken) HasReadOrWrite(userUuid string, userOrgn string) error
- func (appToken AppToken) HasReadWrite(userUuid string) error
- func (appToken AppToken) IsValid(jwtRefreshCount int) bool
- func (appToken *AppToken) Issue(orgn, appName string) (*AppToken, error)
- func (appToken AppToken) JWT() (string, int64, error)
- func (appToken AppToken) MarkDirty() *AppToken
- type ApptokenRepo
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingFields = fmt.Errorf("AppToken must have appRefUuid/hash/owner") ErrWrongAppHash = fmt.Errorf("provided org/app-name hash does not match with db record") ErrAppTokenStillValid = fmt.Errorf("current AppToken is still valid") ErrNoReadWriteAccess = fmt.Errorf("user read/write access for AppToken") ErrNoReadAccess = fmt.Errorf("user has no read access for AppToken") )
Functions ¶
Types ¶
type AppToken ¶
type AppToken struct { AppRefUuid string `bson:"_id" required:"yes"` OwnerOrgn string `bson:"owner_orgn"` Locked bool `bson:"locked"` IsPrivate bool `bson:"is_private"` AppHash string `bson:"app_hash" required:"yes"` AppOwner string `bson:"app_owner" required:"yes"` AppOrigin string `bson:"app_origin"` Member []string `bson:"member"` Jwt string `bson:"app_jwt"` Exp int64 `bson:"app_jwt_exp"` RefreshCount int32 `bson:"refresh_count"` }
AppToken represents the token data as it will be stored in the datbase
func NewDefault ¶
func NewDefault(AppRefUuid, appHash, appOwner, ownerOrgn, appOrigin string, isPrivate bool) (*AppToken, error)
NewDefault creates a new default AppToken with only the meta data but no valid Jwt nor Expiration time
func (AppToken) CompareHash ¶
CompareHash compares if the provided meta data (orgnanization name and app name) match with the apptoken.Hash.
func (AppToken) HasReadOrWrite ¶
HasReadOrWrite checks if the user has either read or write acces on the AppToken
func (AppToken) HasReadWrite ¶
HasReadWrite checks if the provided user uuid is listed as owner of AppToken
func (AppToken) IsValid ¶
IsValid matches the JWT refresh count with the refresh count from the database if they dont match, the app-token is marked as invalid
func (*AppToken) Issue ¶
Issue issues a new AppToken with an updated Jwt and Exp and RefreshCount. The operation fails if the current AppToken.Exp has not yet expired
type ApptokenRepo ¶
type ApptokenRepo interface { Initialize(ctx context.Context, appToken AppToken) error GetById(ctx context.Context, uuid string, result interface{}) error Update(ctx context.Context, uuid, jwt string, exp int64, refreshCount int32) error SetAppTokenLock(ctx context.Context, uuid string, lock bool) error AddMember(ctx context.Context, uuid, userUuid string) error RollbackAddMember(ctx context.Context, uuid, userUuid string) error }