Ai
1 Star 0 Fork 0

ryancartoon/sensu-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
token.go 1019 Bytes
一键复制 编辑 原始数据 按行查看 历史
Simon Plourde 提交于 2019-01-29 03:52 +08:00 . Add support for enterprise providers (#2639)
package v2
import jwt "github.com/dgrijalva/jwt-go"
// Claims represents the JWT claims
type Claims struct {
jwt.StandardClaims
// Custom claims
Groups []string `json:"groups"`
Provider AuthProviderClaims `json:"provider"`
}
// AuthProviderClaims contains information from the authentication provider
type AuthProviderClaims struct {
// ProviderID used to login the user
ProviderID string `json:"provider_id"`
// UserID assigned to the user by the provider
UserID string `json:"user_id"`
}
// FixtureClaims returns a testing fixture for a JWT claims
func FixtureClaims(username string, groups []string) *Claims {
return &Claims{
StandardClaims: jwt.StandardClaims{Subject: username},
Groups: groups,
Provider: AuthProviderClaims{
ProviderID: "basic/default",
UserID: username,
},
}
}
// StandardClaims returns an initialized jwt.StandardClaims with the subject
func StandardClaims(subject string) jwt.StandardClaims {
return jwt.StandardClaims{Subject: subject}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ryancartoon/sensu-go.git
git@gitee.com:ryancartoon/sensu-go.git
ryancartoon
sensu-go
sensu-go
v5.10.1

搜索帮助