authn

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FederateAccessKey = flag.String("federate-access", "", "shared secret, 64 chars, enables federation")
	FederateSecretKey = flag.String("federate-secret", "", "internal secret, 64 chars")
)
View Source
var (
	OIDCIssuer       = flag.String("oidc-issuer", "https://accounts.google.com", "OIDC issuer URL provided by IdP")
	OIDCClientID     = flag.String("oidc-client-id", "f8b8b020-4ec2-0135-6452-027de1ec0c4e43491", "OIDC client ID")
	OIDCClientSecret = flag.String("oidc-client-secret", "cxLF74XOeRRFDJbKuJpZAOtL4pVPK1t2XGVrDbe5R", "OIDC client secret")

	OIDCConfig   OIDCConfigI
	OIDCVerifier OIDCVerifierI

	GetOIDCClaims = parseClaims
)
View Source
var (
	SAMLCert = flag.String("saml-cert-file", "example/myservice.cert", "SAML SP path to cert.pem")
	SAMLKey  = flag.String("saml-key-file", "example/myservice.key", "SAML SP path to key.pem")

	SAMLID  = flag.String("saml-entity-id", "", "SAML SP entity ID (blank defaults to beyond-host)")
	SAMLIDP = flag.String("saml-metadata-url", "", "SAML metadata URL from IdP (blank disables SAML)")

	SAMLNIDF = flag.String("saml-nameid-format", "email", "SAML SP option: {email, persistent, transient, unspecified}")
	SAMLAttr = flag.String("saml-session-key", "email", "SAML attribute to map from session")

	SAMLSignRequests = flag.Bool("saml-sign-requests", false, "SAML SP signs authentication requests")
	SAMLSignMethod   = flag.String("saml-signature-method", "", "SAML SP option: {sha1, sha256, sha512}")
)
View Source
var (
	CookieAge  = flag.Int("cookie-age", 3600*6, "MaxAge setting in seconds")
	CookieDom  = flag.String("cookie-domain", ".myorg.net", "session cookie domain")
	CookieKey  = flag.String("cookie-key", "", "64-char hex key for cookie authentication and encryption")
	CookieKey1 = flag.String("cookie-key1", "", "legacy cookie authentication key; use with -cookie-key2")
	CookieKey2 = flag.String("cookie-key2", "", "legacy cookie encryption key; use with -cookie-key1")
	CookieName = flag.String("cookie-name", "beyond", "session cookie name")
)
View Source
var (
	TokenBase = flag.String("token-base", "", "token server URL prefix (eg. https://api.github.com/user)")
	TokenGQL  = flag.String("token-graphql", "", "GraphQL URL for auth (eg. https://api.github.com/graphql)")
	TokenGQLQ = flag.String("token-graphql-query", `{"query": "query { viewer { login }}"}`, "")
)

Functions

func EncodeFederateNext

func EncodeFederateNext(next string) (string, error)

EncodeFederateNext encodes a next URL for federation

func Federate

func Federate(w http.ResponseWriter, r *http.Request, cookieName string, loginHandler func(http.ResponseWriter, *http.Request))

Federate handles federation requests

func FederateSetup

func FederateSetup() error

FederateSetup initializes the federation codecs

func FederateVerify

func FederateVerify(w http.ResponseWriter, r *http.Request)

FederateVerify verifies a federation token

func GetSession

func GetSession(r *http.Request, name string) (*sessions.Session, error)

GetSession retrieves a session from the request

func GetStore

func GetStore() *sessions.CookieStore

GetStore returns the global session store

func NewSession

func NewSession(name string) *sessions.Session

NewSession creates a new session

func OIDCAuthCodeURL

func OIDCAuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string

OIDCAuthCodeURL returns the OIDC authorization URL

func OIDCSetup

func OIDCSetup(issuer, host string) error

OIDCSetup initializes the OIDC provider

func OIDCVerify

func OIDCVerify(code string) (string, error)

OIDCVerify verifies an OIDC authorization code and returns the user email

func OIDCVerifyToken

func OIDCVerifyToken(ctx context.Context, token *oauth2.Token) (string, error)

OIDCVerifyToken verifies an OAuth2 token and extracts the user email

func OIDCVerifyTokenID

func OIDCVerifyTokenID(ctx context.Context, rawID string) (string, error)

OIDCVerifyTokenID verifies an OIDC ID token and extracts the user email

func RandHex32

func RandHex32() (string, error)

RandHex32 generates a random 32-byte hex string

func SAMLFilter

func SAMLFilter(w http.ResponseWriter, r *http.Request, sessionStore SessionStore, cookieName string) (bool, error)

SAMLFilter processes SAML authentication and sets the user session

func SAMLHandleStartAuthFlow

func SAMLHandleStartAuthFlow(w http.ResponseWriter, r *http.Request)

SAMLHandleStartAuthFlow initiates the SAML authentication flow

func SAMLMiddleware

func SAMLMiddleware() *samlsp.Middleware

SAMLMiddleware returns the SAML middleware for handling SAML endpoints

func SAMLSetup

func SAMLSetup(host string) error

SAMLSetup initializes the SAML service provider

func SetupSession

func SetupSession() error

SetupSession initializes the session store

func TokenAuth

func TokenAuth(r *http.Request) string

TokenAuth extracts and validates a token from the request, returning the user login

Types

type OIDCClaims

type OIDCClaims struct {
	Email string `json:"email"`
}

OIDCClaims represents OIDC token claims

type OIDCConfigI

type OIDCConfigI interface {
	AuthCodeURL(string, ...oauth2.AuthCodeOption) string
	Exchange(context.Context, string) (*oauth2.Token, error)
}

OIDCConfigI is the interface for OIDC configuration

type OIDCVerifierI

type OIDCVerifierI interface {
	Verify(context.Context, string) (*oidc.IDToken, error)
}

OIDCVerifierI is the interface for OIDC token verification

type Session

type Session struct {
	Values map[string]interface{}
	// contains filtered or unexported fields
}

Session represents a user session

func (*Session) Save

func (s *Session) Save(w http.ResponseWriter) error

Save saves the session

type SessionStore

type SessionStore interface {
	Get(r *http.Request, name string) (*Session, error)
	New(name string) *Session
}

SessionStore interface for session management

type TokenUser

type TokenUser struct {
	Login string
	Email string
}

TokenUser represents a user from token authentication

Jump to

Keyboard shortcuts

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