sso

package
v0.0.113 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthCodeURL

func GetAuthCodeURL(c *gin.Context)

func GetSSOConfig

func GetSSOConfig(c *gin.Context)

GetSSOConfig 获取SSO列表,用于前端展示

func GetUsername

func GetUsername(claims map[string]interface{}, preferKeys []string) string

func HandleCallback

func HandleCallback(c *gin.Context)

HandleCallback 处理OAuth2回调

Types

type Client

type Client struct {
	OAuth2Config *oauth2.Config
	Provider     *oidc.Provider
	Verifier     *oidc.IDTokenVerifier
	DBConfig     *models.SSOConfig
}

func NewOIDCClient

func NewOIDCClient(c *gin.Context, cfg *models.SSOConfig) (*Client, error)

NewOIDCClient 创建一个 OIDC 客户端

type Config

type Config struct {
	Issuer       string   // OIDC Issuer 地址
	ClientID     string   // 应用注册的 Client ID
	ClientSecret string   // 应用注册的 Secret
	RedirectURL  string   // 登录回调地址
	Scopes       []string // eg: ["openid", "email", "profile"]
}

Jump to

Keyboard shortcuts

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