gauth

package module
v0.0.1-alpha-c Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

README

gauth

An auth implemenation for SOARCA

Installation

Using gauth

settings

Documentation

Index

Constants

View Source
const (
	DEFAULT_OIDC_CALLBACK_PATH   = "/oidc-callback"
	COOKIE_ENCRYPTION_KEY_LENGTH = 32
	COOKIE_SECRET_KEY_LENGTH     = 32
)

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(key, fallback string) string

func GetEnvBool

func GetEnvBool(key string, defaultValue bool) bool

Types

type Authenticator

type Authenticator struct {
	Cookiejar   cookies.ICookieJar
	OIDCconfig  *oidc.Config
	OauthConfig *oauth2.Config
	// contains filtered or unexported fields
}

func New

func New(config *Config) (*Authenticator, error)

func (*Authenticator) GetProvider

func (auth *Authenticator) GetProvider() *oidc.Provider

func (*Authenticator) GetTokenVerifier

func (auth *Authenticator) GetTokenVerifier() *oidc.IDTokenVerifier

func (*Authenticator) LoadAuthContext

func (auth *Authenticator) LoadAuthContext() gin.HandlerFunc

func (*Authenticator) Logout

func (auth *Authenticator) Logout(gc *gin.Context, redirectPath string)

func (*Authenticator) Middleware

func (auth *Authenticator) Middleware(requiredGroups []string) gin.HandlerFunc

func (*Authenticator) OIDCCallBack

func (auth *Authenticator) OIDCCallBack(gc *gin.Context, redirectPath string)

func (*Authenticator) OIDCRedirectToLogin

func (auth *Authenticator) OIDCRedirectToLogin(gc *gin.Context)

func (*Authenticator) VerifyClaims

func (auth *Authenticator) VerifyClaims(gc *gin.Context, token string) (*models.User, error)

type Config

type Config struct {
	Mode                ConfigMode
	ProviderLink        string
	ClientID            string
	ClientSecret        string
	SkipTLSValidation   bool
	OidcCallbackPath    string
	CookieJarSecret     string
	CookieEncryptionKey string
	RedirectURL         string
	Provider            Provider
}

func DefaultConfig

func DefaultConfig() *Config

func OIDCRedirectConfig

func OIDCRedirectConfig() *Config

type ConfigMode

type ConfigMode int
const (
	ModeVerify ConfigMode = iota
	ModeOIDCRedirect
)

type IAuth

type IAuth interface {
	Middleware(groups []string)
	LoadAuthContext() gin.HandlerFunc
	OIDCCallBack(gc *gin.Context, redirectPath string)
	OIDCRedirectToLogin(gc *gin.Context)
}

type Provider

type Provider string
const (
	Generic   Provider = "Generic"
	Authentik Provider = "Authentik"
)

type UserClaimsConfig

type UserClaimsConfig struct {
	OIDCClaimUsernameField string
	OIDCClaimEmailField    string
	OIDCClaimNameField     string
	OIDCClaimGroupsField   string
}

func GetUserClaims

func GetUserClaims(provider Provider) *UserClaimsConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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