auth

package
v0.0.0-...-02c6b06 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGitHubOAuth

func NewGitHubOAuth(log logr.Logger, githubHostname, org, clientID, clientSecret, redirectURL, cookieSecret string) *githubOAuth

Types

type AuthContext

type AuthContext struct {
	Token oauth2.Token
	User  string
}

type Provider

type Provider interface {
	// Protect is a middleware to protect a page to unauthorized access
	Protect(http.HandlerFunc) http.HandlerFunc

	// Redirect is the function that is called on a callback
	Redirect(w http.ResponseWriter, r *http.Request)

	// GetAuthContext should return the current AuthContext
	GetAuthContext(r *http.Request) (AuthContext, error)

	// Login should login a user and maybe redirect the request to a IDP
	Login(w http.ResponseWriter, r *http.Request)

	// Logout should logout a user and delete the session
	Logout(w http.ResponseWriter, r *http.Request)

	// DisplayLogin should return true if a login should be doable.
	DisplayLogin() bool
}

func NewDummyAuth

func NewDummyAuth() Provider

NewDummyAuth returns a dummy implementation that implements the authentication interface but with a dummy user. This auth method should only be used for local development

func NewNoAuth

func NewNoAuth() Provider

NewNoAuth returns the noAuth authentication provider that is a dummy implementation that implements the authentication interface but with no authentication

Jump to

Keyboard shortcuts

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