Documentation ¶
Index ¶
- Constants
- func CheckOauthUserAndRedirect(userInfo OAuthUserInfo, w http.ResponseWriter) error
- func Init(config models.AuthenticationConfig)
- func IsAuthenticated(w http.ResponseWriter, r *http.Request) bool
- func IsCorrectUsernameAndPassword(username, password string) bool
- func IsEqualStringConstantTime(s1, s2 string) bool
- func IsLogoutAvailable() bool
- func Logout(w http.ResponseWriter, r *http.Request)
- type OAuthUserClaims
- type OAuthUserInfo
Constants ¶
const CookieOauth = "state"
CookieOauth is the cookie name used for login
const Disabled = 3
Disabled authentication ignores all internal authentication procedures. A reverse proxy needs to restrict access
const Header = 2
Header authentication relies on a header from a reverse proxy to parse the username
const Internal = 0
Internal authentication method uses a user / password combination handled by Gokapi
const OAuth2 = 1
OAuth2 authentication retrieves the users email with Open Connect ID
Variables ¶
This section is empty.
Functions ¶
func CheckOauthUserAndRedirect ¶ added in v1.8.1
func CheckOauthUserAndRedirect(userInfo OAuthUserInfo, w http.ResponseWriter) error
CheckOauthUserAndRedirect checks if the user is allowed to use the Gokapi instance
func Init ¶
func Init(config models.AuthenticationConfig)
Init needs to be called first to process the authentication configuration
func IsAuthenticated ¶
func IsAuthenticated(w http.ResponseWriter, r *http.Request) bool
IsAuthenticated returns true if the user provides a valid authentication
func IsCorrectUsernameAndPassword ¶
IsCorrectUsernameAndPassword checks if a provided username and password is correct
func IsEqualStringConstantTime ¶
IsEqualStringConstantTime uses ConstantTimeCompare to prevent timing attack.
func IsLogoutAvailable ¶
func IsLogoutAvailable() bool
IsLogoutAvailable returns true if a logout button should be shown with the current form of authentication
Types ¶
type OAuthUserClaims ¶ added in v1.8.1
type OAuthUserClaims interface {
Claims(v interface{}) error
}
OAuthUserClaims contains the claims
type OAuthUserInfo ¶ added in v1.8.1
type OAuthUserInfo struct { Subject string Email string ClaimsSent OAuthUserClaims }
OAuthUserInfo is used to make testing easier. This results in an additional parameter for the subject unfortunately