auth

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Copyright (C) 2023 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) 2022 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) 2023 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) 2022 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) 2023 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) 2022 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

This section is empty.

Types

type Authentication

type Authentication struct {
	SessionMaxAge time.Duration

	LdapAuth  *LdapAuthenticator
	JwtAuth   *JWTAuthenticator
	LocalAuth *LocalAuthenticator
	// contains filtered or unexported fields
}

func Init

func Init() (*Authentication, error)

func (*Authentication) Auth

func (auth *Authentication) Auth(
	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(
	onsuccess http.Handler,
	onfailure func(rw http.ResponseWriter, r *http.Request, loginErr error)) http.Handler

func (*Authentication) Logout

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

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)

Jump to

Keyboard shortcuts

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