1 Star 0 Fork 0

kevin186 / keyauth

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
grpc.go 507 Bytes
一键复制 编辑 原始数据 按行查看 历史
Aliee 提交于 2023-11-26 12:50 . update grpc and config
package header
import (
"context"
"google.golang.org/grpc/metadata"
)
const (
ClientHeaderKey = "client-id"
ClientSecretKey = "client-secret"
)
func GetClientCredential(ctx context.Context) (clientId, clientSecret string) {
// 重上下文中获取认证信息
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return
}
cids := md.Get(ClientHeaderKey)
sids := md.Get(ClientSecretKey)
if len(cids) > 0 {
clientId = cids[0]
}
if len(sids) > 0 {
clientSecret = sids[0]
}
return
}
1
https://gitee.com/kevin186/keyauth.git
git@gitee.com:kevin186/keyauth.git
kevin186
keyauth
keyauth
v0.0.17

搜索帮助