auth

package
v0.0.0-...-bf5f488 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Users = map[string]User{
	"user1": {"user1", "pass1"},
	"user2": {"user2", "pass2"},
}

Users is a map of registered users

Functions

func ActiveDirectoryAuth

func ActiveDirectoryAuth(w http.ResponseWriter, r *http.Request)

You can use this module by importing it in your application and calling the ActiveDirectoryAuth function with an http.ResponseWriter and http.Request as arguments. This function will extract the username and password from the form values and authenticate against the active directory server using the ldapserver package. Once the user is logged in, the callback function will be executed

ActiveDirectoryAuth performs authentication using SSO with Active Directory

func Authenticate

func Authenticate(username, password string) (bool, error)

Authenticate checks if a username and password match a registered user

func GithubAuth

func GithubAuth(w http.ResponseWriter, r *http.Request)

func GoogleAuth

func GoogleAuth(w http.ResponseWriter, r *http.Request)

func OAuthAuth

func OAuthAuth(w http.ResponseWriter, r *http.Request, config *OAuthConfig)

OAuthAuth performs authentication using OAuth2 with a generic provider

Types

type JWTAuth

type JWTAuth struct {
	Secret []byte
}

You can use this module by importing it in your application and creating an instance of the JWTAuth struct, and then call the Authenticate function with an http.ResponseWriter and http.Request as arguments. This function will extract the JWT from the request header, parse it and validate it using the secret key that

JWTAuth is a struct that contains the JWT configuration

func (*JWTAuth) Authenticate

func (j *JWTAuth) Authenticate(w http.ResponseWriter, r *http.Request)

Authenticate performs authentication using JWT

type OAuthConfig

type OAuthConfig struct {
	ClientID     string
	ClientSecret string
	TokenURL     string
	Scopes       []string
}

OAuthConfig is a struct that contains the OAuth2 configuration

type OIDCAuth

type OIDCAuth struct {
	OAuthConfig *oauth2.Config
}

You can use this function by importing it in your application and creating an instance of the OIDCAuth struct and configuring it with the appropriate values, such as client ID, client secret, redirect URL, and OpenID Connect provider's URL. Then, you can use the Authenticate function in your HTTP handler to perform authentication. In addition, different OpenID providers have different ways of providing the client id and secret, redirect url and provider url, you should check the provider's documentation to get the correct values.

OIDCAuth is a struct that contains the OpenID Connect configuration

func (*OIDCAuth) Authenticate

func (o *OIDCAuth) Authenticate(w http.ResponseWriter, r *http.Request)

Authenticate performs authentication using OpenID Connect

type User

type User struct {
	Username string
	Password string
}

You can use this module by importing it in your application and calling the Authenticate function with a username and password. It returns a boolean value indicating whether the authentication was successful and an error message in case of failure.

User represents a user with a username and password

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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