Documentation ¶
Index ¶
- Constants
- Variables
- func DrainFn(c <-chan interface{})
- func PollFn(ctx context.Context, wg *sync.WaitGroup, sessid string, c <-chan interface{}) string
- type LoginCandidate
- type SessMgr
- func (sessMgr *SessMgr) CheckUserRole(ctx context.Context, sessionID string, roleName string) (bool, error)
- func (sessMgr *SessMgr) DeleteAppClaim(ctx context.Context, sessionID string, appName string) (string, error)
- func (sessMgr *SessMgr) GetJwtClaim(ctx context.Context, sessionID string) (map[string]interface{}, error)
- func (sessMgr *SessMgr) GetJwtClaimElement(ctx context.Context, sessionID, element string) (interface{}, error)
- func (sessMgr *SessMgr) IsSessionValid(ctx context.Context, sessionID string) (bool, error)
- func (sessMgr *SessMgr) NewSession(ctx context.Context, shdr map[string]interface{}) (string, error)
- func (sessMgr *SessMgr) RefreshSession(ctx context.Context, sessionID string) <-chan interface{}
- func (sessMgr *SessMgr) SetAppClaim(ctx context.Context, sessionID string, appName string, appClaim string) (string, error)
- type SessProvider
Constants ¶
View Source
const ( //ConstJwtID id (session) element ConstJwtID = "jti" //ConstJwtRole roletoken id ConstJwtRole = "rle" //ConstJwtAccID account id ConstJwtAccID = "aid" //ConstJwtEml email ConstJwtEml = "eml" )
Variables ¶
View Source
var ( //ErrKeyPairNotExist occurs if the key pair cannot be read ErrKeyPairNotExist = errors.New("keypair could not be created") //ErrJwtCouldNotParseToken error message ErrJwtCouldNotParseToken = errors.New("could not parse token, or token not valid") //ErrLoginSessionNotCreated failed to create session error ErrLoginSessionNotCreated = errors.New("could not create a login session") //ErrJwtInvalidSession error message ErrJwtInvalidSession = errors.New("session is no longer valid, please login") //ErrClaimElementNotExist error message ErrClaimElementNotExist = errors.New("the claim element does not exist") )
errors
View Source
var ( //EnvDebugOn controls verbose logging EnvDebugOn bool )
Functions ¶
Types ¶
type LoginCandidate ¶
type LoginCandidate struct { SessionID string `json:"sessionid" datastore:"sessionid"` UserAccountID string `json:"useraccountid" datastore:"useraccountid"` Email string `json:"email" datastore:"email"` RoleToken string `json:"roletoken" datastore:"roletoken"` Activated bool `json:"activated" datastore:"activated"` CreatedDate *time.Time `json:"createddate,omitempty" datastore:"createddate"` ActivatedDate *time.Time `json:"activateddate,omitempty" datastore:"activateddate"` }
LoginCandidate is a record of a login attempt
type SessMgr ¶
type SessMgr struct {
// contains filtered or unexported fields
}
SessMgr handles jwts
func (*SessMgr) CheckUserRole ¶
func (sessMgr *SessMgr) CheckUserRole(ctx context.Context, sessionID string, roleName string) (bool, error)
CheckUserRole checks that the jwt authorises a given claim
func (*SessMgr) DeleteAppClaim ¶
func (sessMgr *SessMgr) DeleteAppClaim(ctx context.Context, sessionID string, appName string) (string, error)
DeleteAppClaim removes an appclaim within the jwt (includes token refresh)
func (*SessMgr) GetJwtClaim ¶
func (sessMgr *SessMgr) GetJwtClaim(ctx context.Context, sessionID string) (map[string]interface{}, error)
GetJwtClaim returns a decoded map[string]interface{} from the session string
func (*SessMgr) GetJwtClaimElement ¶
func (sessMgr *SessMgr) GetJwtClaimElement(ctx context.Context, sessionID, element string) (interface{}, error)
GetJwtClaimElement returns a decoded interface{} from the session string
func (*SessMgr) IsSessionValid ¶
IsSessionValid returns a bool indicating if the session is still valid
func (*SessMgr) NewSession ¶
func (sessMgr *SessMgr) NewSession(ctx context.Context, shdr map[string]interface{}) (string, error)
NewSession returns a signed jwt as a string
func (*SessMgr) RefreshSession ¶
RefreshSession exchanges a valid token for an extended life token
type SessProvider ¶
type SessProvider interface { NewSession(ctx context.Context, shdr map[string]interface{}) (string, error) CheckUserRole(ctx context.Context, sessionID string, roleName string) (bool, error) GetJwtClaim(ctx context.Context, sessionID string) (map[string]interface{}, error) GetJwtClaimElement(ctx context.Context, sessionID, element string) (interface{}, error) IsSessionValid(ctx context.Context, sessionID string) (bool, error) RefreshSession(ctx context.Context, sessionID string) <-chan interface{} SetAppClaim(ctx context.Context, sessionID string, appName string, appClaim string) (string, error) DeleteAppClaim(ctx context.Context, sessionID string, appName string) (string, error) }
SessProvider defines the public operations of a session manager
Click to show internal directories.
Click to hide internal directories.