saml

package
v0.0.0-...-ff4cbb2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 42 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package saml 使用维护中的 SAML2 验证器处理签名和加密响应,禁用未经请求的登录。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IDPMetadataURL                           string
	HTTPClient                               *http.Client
	VerifyMetadata                           func(context.Context, []byte) error
	EntityID, MetadataURL, ACSURL, LogoutURL string
	Key                                      crypto.Signer
	Certificate                              *x509.Certificate
	IDP                                      *protocol.EntityDescriptor
	Store                                    oauth2.StateStore
	TTL                                      time.Duration
	MaxPending                               int
	AllowHTTP                                bool
	Map                                      func(context.Context, *protocol.Assertion) (security.Principal, error)
}

Config 声明SAML2 登录及单点退出所需的可信配置及实现。

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

Endpoint 承载SAML2 登录及单点退出的运行状态与显式操作。

func NewEndpoint

func NewEndpoint(config EndpointConfig) (*Endpoint, error)

NewEndpoint 校验配置并创建SAML2 登录及单点退出组件。

func (*Endpoint) Close

func (e *Endpoint) Close() error

Close 停止后续操作并释放本组件拥有的状态,外部依赖由调用方管理。

func (*Endpoint) Handle

func (e *Endpoint) Handle(w http.ResponseWriter, r *http.Request) (bool, error)

Handle 通过现有 Security Filter 处理协议专用端点,业务请求继续进入拦截器。

type EndpointConfig

type EndpointConfig struct {
	// BindingCookie 隔离并行提供者的浏览器挑战,空值保留默认名称。
	BindingCookie                      string
	Service                            *Service
	Sessions                           *session.Manager
	Cookies                            *securityhttp.CookieSource
	Links                              *federation.Service
	LoginPath, LogoutPath, SuccessPath string
	AllowHTTP                          bool
}

EndpointConfig 声明SAML2 登录及单点退出所需的可信配置及实现。

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service 承载SAML2 登录及单点退出的运行状态与显式操作。

func New

func New(config Config) (*Service, error)

New 校验配置并创建SAML2 登录及单点退出组件。

func (*Service) Begin

func (s *Service) Begin(ctx context.Context, binding string) (string, error)

Begin 保存浏览器绑定挑战并构造SAML2 登录及单点退出跳转地址。

func (*Service) BeginLogout

func (s *Service) BeginLogout(ctx context.Context, binding, nameID, index string) (string, error)

BeginLogout 保存请求关联并签名会话索引,响应不能只靠 RelayState 判断有效。

func (*Service) Close

func (s *Service) Close() error

Close 停止后续操作并释放本组件拥有的状态,外部依赖由调用方管理。

func (*Service) Complete

func (s *Service) Complete(ctx context.Context, binding string, r *http.Request) (security.Principal, error)

Complete 只接受与 SP 请求及浏览器绑定一致的响应;断言签名、受众、目的地和期限由协议库校验。

func (*Service) LogoutURL

func (s *Service) LogoutURL(nameID, state string) (string, error)

LogoutURL 返回可信身份提供者的退出地址。

func (*Service) Metadata

func (s *Service) Metadata() ([]byte, error)

Metadata 返回签名服务提供者元数据的独立字节内容。

func (*Service) RefreshIDP

func (s *Service) RefreshIDP(ctx context.Context) error

RefreshIDP 从固定配置源读取有界 XML,禁用重定向,并在校验后原子更新证书。 VerifyMetadata 可验证签名或应用自己的固定指纹,网络客户端生命周期归应用。

func (*Service) RotateKey

func (s *Service) RotateKey(key crypto.Signer, certificate *x509.Certificate) error

RotateKey 更换 SP 签名与解密密钥,旧密钥保留一个请求 TTL,以完成轮换前的在途响应。 最多保留八个有效旧密钥;超过额度时拒绝轮换,外部 Signer 生命周期归应用。

func (*Service) SingleLogout

func (s *Service) SingleLogout(ctx context.Context, binding string, r *http.Request, links *federation.Service, replay dpop.Store) (string, error)

SingleLogout 支持 IdP 请求与关联 SP 响应,验证签名根节点后才撤销本地会话。

func (*Service) UpdateIDP

func (s *Service) UpdateIDP(m *protocol.EntityDescriptor) error

UpdateIDP 原子替换可信元数据,只允许证书及期限更新,禁止实体身份和 SSO/SLO 端点漂移。 调用方必须验证元数据来源;失败保留原快照,原快照过期后认证失败关闭。

Jump to

Keyboard shortcuts

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