Documentation ¶
Index ¶
- Variables
- func ActiveDirectoryAuth(w http.ResponseWriter, r *http.Request)
- func Authenticate(username, password string) (bool, error)
- func GithubAuth(w http.ResponseWriter, r *http.Request)
- func GoogleAuth(w http.ResponseWriter, r *http.Request)
- func OAuthAuth(w http.ResponseWriter, r *http.Request, config *OAuthConfig)
- type JWTAuth
- type OAuthConfig
- type OIDCAuth
- type User
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
OAuthConfig is a struct that contains the OAuth2 configuration
type OIDCAuth ¶
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 ¶
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