authentication

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: BSD-2-Clause Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCode

func GetCode(r *http.Request) (code string, err error)

func LoginURL

func LoginURL(endpoint Endpoint, config Config) string

LoginURL needs endpoint Endpoint.Authorization, and configs Config.ClientID, Config.Scopes and Config.RedirectURI

func LogoutURL

func LogoutURL(endpoint Endpoint, postLogoutRedirectURI string) string

LogoutURL needs endpoint Endpoint.Logout

func RedeemCode

func RedeemCode(endpoint Endpoint, config Config) func(code string) (tokens Token, err error)

RedeemCode needs endpoint Endpoint.Token, and configs Config.ClientID, Config.Scopes and RedirectURI config.RedirectURI must be the same as acquiring the code

Types

type Config

type Config struct {
	ClientID    string
	Scopes      []string
	RedirectURI string
}

type Endpoint

type Endpoint struct {
	Authorize string
	Token     string
	Logout    string
}

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	ExpiresAt   int64  `json:"expires_at"`

	RefreshToken string `json:"refresh_token"`
}

func Login

func Login(ctx context.Context, endpoint Endpoint, listenAddr string, config Config) (token Token, err error)

Login opens an interactive authorization code flow. Arguments for LoginURL and RedeemCode are needed.

func Refresh

func Refresh(refreshToken string, endpoint Endpoint, config Config) (tokens Token, err error)

Refresh needs endpoint Endpoint.Token, and configs Config.ClientID and Config.Scopes

func (Token) Expired

func (token Token) Expired() bool

Jump to

Keyboard shortcuts

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