auth

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Types

type Authentication

type Authentication struct {
	LdapAuth  *LdapAuthenticator
	JwtAuth   *JWTAuthenticator
	LocalAuth *LocalAuthenticator

	SessionMaxAge time.Duration
	// contains filtered or unexported fields
}

func GetAuthInstance added in v1.4.0

func GetAuthInstance() *Authentication

func (*Authentication) Auth

func (auth *Authentication) Auth(
	onsuccess http.Handler,
	onfailure func(rw http.ResponseWriter, r *http.Request, authErr error),
) http.Handler

func (*Authentication) AuthApi added in v1.4.0

func (auth *Authentication) AuthApi(
	onsuccess http.Handler,
	onfailure func(rw http.ResponseWriter, r *http.Request, authErr error),
) http.Handler

func (*Authentication) AuthConfigApi added in v1.4.0

func (auth *Authentication) AuthConfigApi(
	onsuccess http.Handler,
	onfailure func(rw http.ResponseWriter, r *http.Request, authErr error),
) http.Handler

func (*Authentication) AuthFrontendApi added in v1.4.0

func (auth *Authentication) AuthFrontendApi(
	onsuccess http.Handler,
	onfailure func(rw http.ResponseWriter, r *http.Request, authErr error),
) http.Handler

func (*Authentication) AuthUserApi added in v1.4.0

func (auth *Authentication) AuthUserApi(
	onsuccess http.Handler,
	onfailure func(rw http.ResponseWriter, r *http.Request, authErr error),
) http.Handler

func (*Authentication) AuthViaSession

func (auth *Authentication) AuthViaSession(
	rw http.ResponseWriter,
	r *http.Request,
) (*schema.User, error)

func (*Authentication) Login

func (auth *Authentication) Login(
	onfailure func(rw http.ResponseWriter, r *http.Request, loginErr error),
) http.Handler

func (*Authentication) Logout

func (auth *Authentication) Logout(onsuccess http.Handler) http.Handler

func (*Authentication) SaveSession added in v1.3.0

func (auth *Authentication) SaveSession(rw http.ResponseWriter, r *http.Request, user *schema.User) error

type Authenticator

type Authenticator interface {
	CanLogin(user *schema.User, username string, rw http.ResponseWriter, r *http.Request) (*schema.User, bool)
	Login(user *schema.User, rw http.ResponseWriter, r *http.Request) (*schema.User, error)
}

type JWTAuthenticator

type JWTAuthenticator struct {
	// contains filtered or unexported fields
}

func (*JWTAuthenticator) AuthViaJWT added in v1.2.0

func (ja *JWTAuthenticator) AuthViaJWT(
	rw http.ResponseWriter,
	r *http.Request,
) (*schema.User, error)

func (*JWTAuthenticator) Init

func (ja *JWTAuthenticator) Init() error

func (*JWTAuthenticator) ProvideJWT

func (ja *JWTAuthenticator) ProvideJWT(user *schema.User) (string, error)

Generate a new JWT that can be used for authentication

type JWTCookieSessionAuthenticator added in v1.2.0

type JWTCookieSessionAuthenticator struct {
	// contains filtered or unexported fields
}

func (*JWTCookieSessionAuthenticator) CanLogin added in v1.2.0

func (ja *JWTCookieSessionAuthenticator) CanLogin(
	user *schema.User,
	username string,
	rw http.ResponseWriter,
	r *http.Request,
) (*schema.User, bool)

func (*JWTCookieSessionAuthenticator) Init added in v1.2.0

func (*JWTCookieSessionAuthenticator) Login added in v1.2.0

type JWTSessionAuthenticator added in v1.2.0

type JWTSessionAuthenticator struct {
	// contains filtered or unexported fields
}

func (*JWTSessionAuthenticator) CanLogin added in v1.2.0

func (ja *JWTSessionAuthenticator) CanLogin(
	user *schema.User,
	username string,
	rw http.ResponseWriter,
	r *http.Request,
) (*schema.User, bool)

func (*JWTSessionAuthenticator) Init added in v1.2.0

func (ja *JWTSessionAuthenticator) Init() error

func (*JWTSessionAuthenticator) Login added in v1.2.0

type LdapAuthenticator

type LdapAuthenticator struct {
	UserAttr string
	// contains filtered or unexported fields
}

func (*LdapAuthenticator) CanLogin

func (la *LdapAuthenticator) CanLogin(
	user *schema.User,
	username string,
	rw http.ResponseWriter,
	r *http.Request,
) (*schema.User, bool)

func (*LdapAuthenticator) Init

func (la *LdapAuthenticator) Init() error

func (*LdapAuthenticator) Login

func (la *LdapAuthenticator) Login(
	user *schema.User,
	rw http.ResponseWriter,
	r *http.Request,
) (*schema.User, error)

func (*LdapAuthenticator) Sync

func (la *LdapAuthenticator) Sync() error

type LocalAuthenticator

type LocalAuthenticator struct {
	// contains filtered or unexported fields
}

func (*LocalAuthenticator) CanLogin

func (la *LocalAuthenticator) CanLogin(
	user *schema.User,
	username string,
	rw http.ResponseWriter,
	r *http.Request) (*schema.User, bool)

func (*LocalAuthenticator) Init

func (la *LocalAuthenticator) Init() error

func (*LocalAuthenticator) Login

func (la *LocalAuthenticator) Login(
	user *schema.User,
	rw http.ResponseWriter,
	r *http.Request) (*schema.User, error)

type OIDC added in v1.3.0

type OIDC struct {
	// contains filtered or unexported fields
}

func NewOIDC added in v1.3.0

func NewOIDC(a *Authentication) *OIDC

func (*OIDC) OAuth2Callback added in v1.3.0

func (oa *OIDC) OAuth2Callback(rw http.ResponseWriter, r *http.Request)

func (*OIDC) OAuth2Login added in v1.3.0

func (oa *OIDC) OAuth2Login(rw http.ResponseWriter, r *http.Request)

func (*OIDC) RegisterEndpoints added in v1.3.0

func (oa *OIDC) RegisterEndpoints(r *mux.Router)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL