Documentation ¶
Overview ¶
Package auth implement the auth system from the openslides-auth-service: https://github.com/OpenSlides/openslides-auth-service
Index ¶
- Constants
- type Auth
- func (a *Auth) Authenticate(w http.ResponseWriter, r *http.Request) (ctx context.Context, err error)
- func (a *Auth) FromContext(ctx context.Context) int
- func (a *Auth) ListenOnLogouts(ctx context.Context, logoutEventer LogoutEventer, errHandler func(error))
- func (a *Auth) PruneOldData(ctx context.Context)
- type LogoutEventer
Constants ¶
const ( DebugTokenKey = "auth-dev-token-key" DebugCookieKey = "auth-dev-cookie-key" )
DebugTokenKey and DebugCookieKey are non random auth keys for development.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth authenticates a request against the openslides-auth-service.
Has to be initialized with auth.New().
func New ¶
func New( authServiceURL string, closed <-chan struct{}, tokenKey, cookieKey []byte, ) (*Auth, error)
New initializes an Auth service.
func (*Auth) Authenticate ¶
func (a *Auth) Authenticate(w http.ResponseWriter, r *http.Request) (ctx context.Context, err error)
Authenticate uses the headers from the given request to get the user id. The returned context will be cancled, if the session is revoked.
func (*Auth) FromContext ¶
FromContext returnes the user id from a context returned by Authenticate(). If the context was not returned from Authenticate or the user is an anonymous user, then 0 is returned.
func (*Auth) ListenOnLogouts ¶
func (a *Auth) ListenOnLogouts(ctx context.Context, logoutEventer LogoutEventer, errHandler func(error))
ListenOnLogouts listen on logout events and closes the connections.
func (*Auth) PruneOldData ¶
PruneOldData removes old logout events.