auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginErrKey = "loginError"
)

Variables

View Source
var ErrInvalidToken = errors.New("Invalid token")
View Source
var ErrUnauthorizedDomain = fmt.Errorf("unauthorized email domain")

Functions

func APIKeyValidatorMiddleware

func APIKeyValidatorMiddleware(apiKeyMgr apikeymanager.APIKeyManager) func(http.Handler) http.Handler

func MockOAuth2Server

func MockOAuth2Server() *http.Server

Types

type IdToken

type IdToken map[string]any

func (IdToken) Exists

func (id IdToken) Exists(claim string) bool

func (IdToken) GetString

func (id IdToken) GetString(claim string) string

type Idp

type Idp struct {
	oauth2.Config

	LoginPromptData LoginPromptData
	// contains filtered or unexported fields
}

func NewIdp

func NewIdp(config *OAuth2ClientConfig, sessionManager *scs.SessionManager) *Idp

func NewMockIdp

func NewMockIdp(config *OAuth2ClientConfig, sessionManager *scs.SessionManager) *Idp

func (*Idp) CheckUserAuthorization

func (idp *Idp) CheckUserAuthorization(email string) error

CheckUserAuthorization checks if the user with the given email is authorized.

func (*Idp) HandleSignInCallback

func (idp *Idp) HandleSignInCallback(w http.ResponseWriter, r *http.Request)

func (*Idp) LogoutHandler

func (idp *Idp) LogoutHandler(w http.ResponseWriter, r *http.Request)

func (*Idp) RedirectIfLoggedIn

func (idp *Idp) RedirectIfLoggedIn(next http.Handler) http.Handler

func (*Idp) RequestSignIn

func (idp *Idp) RequestSignIn(w http.ResponseWriter, r *http.Request)

func (*Idp) RequireAuthentication

func (idp *Idp) RequireAuthentication(next http.Handler) http.Handler

type LoginPromptData

type LoginPromptData struct {
	Text     string
	Provider string
}

type OAuth2ClientConfig

type OAuth2ClientConfig struct {
	ClientID          string `mapstructure:"clientID"`
	ClientSecret      string `mapstructure:"clientSecret"`
	RedirectURL       string `mapstructure:"redirectURL"`
	AuthURL           string `mapstructure:"authURL"`
	TokenURL          string `mapstructure:"tokenURL"`
	Scopes            []string
	Provider          string   `mapstructure:"provider"`
	AuthorizedDomains []string `mapstructure:"authorizedDomains"`
	Tenant            string
	Domain            string
	LoginText         string
}

Jump to

Keyboard shortcuts

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