auth

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObotAccessTokenCookie = "obot_access_token"

	// AuthProviderVerifyCookie carries the ID of an in-flight staged-provider verification across
	// the OAuth round trip, so only the browser that started it can log in through the staged
	// provider.
	AuthProviderVerifyCookie = "obot_auth_provider_verify"

	// AuthProviderVerifyWindow is how long a staged-provider verification stays open.
	AuthProviderVerifyWindow = 15 * time.Minute
)

Variables

This section is empty.

Functions

func ClearAuthProviderVerifyCookie added in v0.26.1

func ClearAuthProviderVerifyCookie(w http.ResponseWriter)

func ContextWithProviderGroupIDPrefix added in v0.25.2

func ContextWithProviderGroupIDPrefix(ctx context.Context, prefix string) context.Context

ContextWithProviderGroupIDPrefix adds the auth provider's declared group ID prefix to the context.

func ContextWithProviderURL

func ContextWithProviderURL(ctx context.Context, url string) context.Context

ContextWithProviderURL adds the auth provider URL to the context

func ProviderGroupIDPrefixFromContext added in v0.25.2

func ProviderGroupIDPrefixFromContext(ctx context.Context) string

ProviderGroupIDPrefixFromContext retrieves the auth provider's declared group ID prefix.

func ProviderURLFromContext

func ProviderURLFromContext(ctx context.Context) string

ProviderURLFromContext retrieves the auth provider URL from the context

func SafeRedirectPath added in v0.26.0

func SafeRedirectPath(rd string) string

SafeRedirectPath sanitizes a caller-supplied redirect so that it can only point back into Obot, returning "/" for anything else. Browsers treat "\" as "/" when resolving against an http(s) base, so "/\evil.com" is another spelling of "//evil.com" and must be rejected too. Browsers also strip tabs and newlines from URLs, so "/\t/evil.com" is rejected along with any other control character.

func ValidateGroupID added in v0.25.2

func ValidateGroupID(groupID, prefix string) error

ValidateGroupID checks that a group returned by an auth provider belongs to the namespace that provider declared in its manifest.

func ValidateGroupIDPrefix added in v0.25.2

func ValidateGroupIDPrefix(prefix string) error

ValidateGroupIDPrefix validates a provider-declared group ID namespace. An empty prefix means that the provider does not support groups.

Types

type GroupInfo

type GroupInfo struct {
	ID      string  `json:"id"`
	Name    string  `json:"name"`
	IconURL *string `json:"iconURL"`
}

GroupInfo represents information about a user group from an authentication provider

type SerializableRequest added in v0.10.0

type SerializableRequest struct {
	Method string              `json:"method"`
	URL    string              `json:"url"`
	Header map[string][]string `json:"header"`
}

SerializableRequest represents an HTTP request that can be serialized for authentication flows

type SerializableState added in v0.10.0

type SerializableState struct {
	ExpiresOn             *time.Time `json:"expiresOn"`
	AccessToken           string     `json:"accessToken"`
	PreferredUsername     string     `json:"preferredUsername"`
	User                  string     `json:"user"`
	Email                 string     `json:"email"`
	SetCookies            []string   `json:"setCookies"`
	RequirePasswordChange bool       `json:"requirePasswordChange,omitempty"`
}

SerializableState represents the authentication state returned from auth providers

Jump to

Keyboard shortcuts

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