auth

package
v0.8.21 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthAdd

func AuthAdd(r *http.Request, clientID, clientSecret string, style session.AuthHeaderStyle)

AuthAdd is a function to set Authorization header.

  • Style must be AuthHeaderStyleBasic or AuthHeaderStyleBearerSecret, otherwise it does nothing.
  • Default style is AuthHeaderStyleBasic.

func NewState

func NewState() (string, error)

NewState generates cryptographically secure random state with base64 URL encoding.

func RemoveCookie

func RemoveCookie(w http.ResponseWriter, cookie *Cookie)

func SetBearerAuth

func SetBearerAuth(r *http.Request, token string)

SetBearerAuth sets the Authorization header to use Bearer token.

func SetCookie

func SetCookie(w http.ResponseWriter, value string, cookie *Cookie)

Types

type Code

type Code struct {
	// BaseURL is the base URL to use for the redirect.
	// Default is the request Host with checking the X-Forwarded-Host header.
	BaseURL string `cfg:"base_url"`
	// Schema is the default schema to use for the redirect if no schema is provided.
	// Default is the https schema.
	Schema string `cfg:"schema"`
	// Path is the path to use for the redirect.
	Path string `cfg:"path"`

	InsecureSkipVerify bool `cfg:"insecure_skip_verify"`
	// contains filtered or unexported fields
}

func (*Code) AuthCodeRedirectURL

func (m *Code) AuthCodeRedirectURL(r *http.Request, providerName string) (string, error)

func (*Code) AuthCodeURL

func (m *Code) AuthCodeURL(r *http.Request, state, providerName string, oauth2 *session.Oauth2) (string, error)

func (*Code) CodeToken

func (m *Code) CodeToken(ctx context.Context, r *http.Request, code, providerName string, oauth2 *session.Oauth2) ([]byte, int, error)

func (*Code) Init

func (m *Code) Init() error

func (*Code) RevokeToken

func (m *Code) RevokeToken(ctx context.Context, token string, oauth2 *session.Oauth2) error

func (*Code) UserInfo

func (m *Code) UserInfo(ctx context.Context, token string, oauth2 *session.Oauth2) (map[string]interface{}, int, error)
type Cookie struct {
	// CookieName is the name of the cookie.
	CookieName string `cfg:"cookie_name"`
	// MaxAge the number of seconds until the cookie expires.
	MaxAge int `cfg:"max_age"`
	// Path that must exist in the requested URL for the browser to send the Cookie header.
	Path string `cfg:"path"`
	// Domain for defines the host to which the cookie will be sent.
	Domain string `cfg:"domain"`
	// Secure to cookie only sent over HTTPS.
	Secure bool `cfg:"secure"`
	// SameSite for Lax 2, Strict 3, None 4.
	SameSite http.SameSite `cfg:"same_site"`
	// HttpOnly for true for not accessible by JavaScript.
	HttpOnly bool `cfg:"http_only"`
}

Jump to

Keyboard shortcuts

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