Documentation ¶
Index ¶
- Constants
- func CheckHash(secret, hash string) bool
- func Hash(secret string, cost int) (string, error)
- func NewToken(n int) (string, error)
- type APIKeyMeta
- type Auth
- func (a *Auth) Close() error
- func (a *Auth) GetRTSPToken(ctx context.Context, sess SessionMeta) (token string, err error)
- func (a *Auth) NewAPIKey(ctx context.Context, apikey APIKeyMeta, duration time.Duration) (string, error)
- func (a *Auth) NewSession(ctx context.Context, meta SessionMeta) (string, error)
- func (a *Auth) ReadAPIKeyMetadata(bytes []byte) (metadata APIKeyMeta, err error)
- func (a *Auth) ReadSessionMetadata(bytes []byte) (metadata SessionMeta, err error)
- func (a *Auth) RemoveAPIKey(ctx context.Context, id int32) error
- func (a *Auth) RemoveSession(ctx context.Context, userId int32) error
- func (a *Auth) Validate(ctx context.Context, session string) (metadata SessionMeta, err error)
- func (a *Auth) ValidateAPIKey(ctx context.Context, apikey string) (metadata APIKeyMeta, err error)
- type AuthConfig
- type SessionMeta
Constants ¶
View Source
const SessionCookieName = "sess"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIKeyMeta ¶
type APIKeyMeta struct { // Id is the API Key id. Id int32 // UserId is the user identifier. UserId int32 // Role is the user role. Role roles.Role }
func (*APIKeyMeta) Bytes ¶
func (a *APIKeyMeta) Bytes() []byte
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func (*Auth) GetRTSPToken ¶
func (*Auth) NewAPIKey ¶
func (a *Auth) NewAPIKey(ctx context.Context, apikey APIKeyMeta, duration time.Duration) (string, error)
Craetes a API key for a user and saves on Redis.
func (*Auth) NewSession ¶
Crates a new session for a user and saves on Redis and remove any old session.
func (*Auth) ReadAPIKeyMetadata ¶
func (a *Auth) ReadAPIKeyMetadata(bytes []byte) (metadata APIKeyMeta, err error)
func (*Auth) ReadSessionMetadata ¶
func (a *Auth) ReadSessionMetadata(bytes []byte) (metadata SessionMeta, err error)
func (*Auth) RemoveAPIKey ¶
RemoveAPIKey removes a user API key. If API key doesn't exists returns an error.
func (*Auth) RemoveSession ¶
RemoveSession removes a user session. If session doesn't exists returns an error.
func (*Auth) Validate ¶
Validate validates a session on Redis and return the user metadata. An error is returned if fail to comunicate with Redis or session doesn't exist.
func (*Auth) ValidateAPIKey ¶
ValidateAPIKey validates a API key on Redis and return the key metadata. An error is returned if fail to comunicate with Redis or API key doesn't exist.
type AuthConfig ¶
type AuthConfig struct { }
type SessionMeta ¶
func (*SessionMeta) Bytes ¶
func (m *SessionMeta) Bytes() []byte
Click to show internal directories.
Click to hide internal directories.