sso

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const URIAuthCodeCallback = "/login/auth/callback"

Variables

This section is empty.

Functions

func Initialize

func Initialize(sso *config.SSO) error

Initialize init the provider(s) successfully, if not, crash it

func NextState

func NextState() string

NextState generate a new oauth2's state code

func Register

func Register(name Vendor, p Provider)

Register register a provider with the name

Types

type Link struct {
	Name string
	Link string
}

Link represents a sso vendor name & the auth code link pair

func AuthCodeLinks(redirect string, client string) []Link

AuthCodeLinks generates the all sso vendor name & the auth code link pairs If the node port equals `0`, which means the login request is not started from the PairMesh node.

type Provider

type Provider interface {
	Setup(cfg *config.SSO) error
	AuthCodeURL(redirect, client string) string
	AccessToken(code string) (*Token, error)
	UserInfo(token *Token) (*models.User, bool, error)
}

Provider represents the sso vendor

func WithName

func WithName(name Vendor) Provider

WithName returns the provider with the name

type Token

type Token struct {
	AccessToken string
	Raw         map[string]string //extra data for diff platform
}

type Vendor

type Vendor int

Vendor represents the current sso provider (github, ...)

const (
	GitHub Vendor = iota
)

func (Vendor) String

func (v Vendor) String() string

String implements the fmt.Stringer interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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