oidcx

package
v6.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackOutput

type CallbackOutput struct {
	Redirect    string `json:"redirect"`
	Msg         string `json:"msg"`
	AccessToken string `json:"accessToken"`
	Username    string `json:"username"`
	Nickname    string `json:"nickname"`
	Phone       string `yaml:"phone"`
	Email       string `yaml:"email"`
}

type Config

type Config struct {
	Enable          bool
	DisplayName     string
	RedirectURL     string
	SsoAddr         string
	ClientId        string
	ClientSecret    string
	CoverAttributes bool
	SkipTlsVerify   bool
	Attributes      struct {
		Nickname string
		Username string
		Phone    string
		Email    string
	}
	DefaultRoles []string
}

type SsoClient

type SsoClient struct {
	Enable          bool
	Verifier        *oidc.IDTokenVerifier
	Config          oauth2.Config
	SsoAddr         string
	CallbackAddr    string
	CoverAttributes bool
	DisplayName     string
	Attributes      struct {
		Username string
		Nickname string
		Phone    string
		Email    string
	}
	DefaultRoles []string

	Ctx      context.Context
	Provider *oidc.Provider
	sync.RWMutex
}

func New

func New(cf Config) (*SsoClient, error)

func (*SsoClient) Authorize

func (s *SsoClient) Authorize(redis storage.Redis, redirect string) (string, error)

Authorize return the sso authorize location with state

func (*SsoClient) Callback

func (s *SsoClient) Callback(redis storage.Redis, ctx context.Context, code, state string) (*CallbackOutput, error)

Callback 用 code 兑换 accessToken 以及 用户信息,

func (*SsoClient) GetDisplayName

func (s *SsoClient) GetDisplayName() string

func (*SsoClient) Reload

func (s *SsoClient) Reload(cf Config) error

Jump to

Keyboard shortcuts

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