Documentation ¶
Index ¶
- Constants
- Variables
- func Authorize(ctx context.Context, fullMethodName string, mds map[string]string, ...) (context.Context, error)
- func GetDeviceID(mds map[string]string) string
- func GetIPFromMeta(mds map[string]string) string
- func GetUserAgent(mds map[string]string) string
- func InitByConfig(iss string, cfg *oidc.Config) error
- func InitOIDC(path string) error
- func StreamServerInterceptor(fn OidcAuthFuncHandler) grpc.StreamServerInterceptor
- func UnaryServerInterceptor(fn OidcAuthFuncHandler) grpc.UnaryServerInterceptor
- func VerifyHas(par string, data []string) error
- type AuthConfig
- type Config
- type IDToken
- type OidcAuthFuncHandler
Constants ¶
View Source
const ( //x-scope = X_SCOPE string = "x-scope" //x-client-id X_CLIENT_ID string = "x-client-id" //x-project-id X_PROJECT_ID string = "x-project-id" //x-service-name X_SERVICE_NAME string = "x-service-name" //full_method_name FULL_METHOD_NAME string = "full_method_name" //soa_service_id SOA_SERVICE_ID string = "soa_service_id" //soa_service_name SOA_SERVICE_NAME string = "soa_service_name" //authorization AUTHORIZATION string = "authorization" )
Variables ¶
View Source
var ( // OIDCVerifier 备注:一定要初始化到全局 OIDCVerifier *oidc.IDTokenVerifier )
Functions ¶
func Authorize ¶
func Authorize(ctx context.Context, fullMethodName string, mds map[string]string, handler OidcAuthFuncHandler) (context.Context, error)
Authorize 检查授权
func GetDeviceID ¶
func GetIPFromMeta ¶
GetIPFromMeta returns IP address from request. Only when it used use proxy
func GetUserAgent ¶
func InitOIDC ¶
InitOIDC InitOIDC oidcissue 内网填写 https://apis.xbase.xyz , 外网填写:https://apis.xbase.cloud
func StreamServerInterceptor ¶
func StreamServerInterceptor(fn OidcAuthFuncHandler) grpc.StreamServerInterceptor
GrpcStreamServerInterceptor .
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(fn OidcAuthFuncHandler) grpc.UnaryServerInterceptor
Types ¶
type AuthConfig ¶
type Config ¶
type Config struct {
OIDCAuth AuthConfig `json:"OIDCAuth" yaml:"OIDCAuth"`
}
type IDToken ¶
type IDToken struct { Issue string `protobuf:"bytes,1,opt,name=iss,json=Issue,proto3" json:"iss,omitempty"` ClientID string `protobuf:"bytes,2,opt,name=aud,json=Aud,proto3" json:"aud,omitempty"` Exp int64 `protobuf:"bytes,3,opt,name=exp,json=Exp,proto3" json:"exp,omitempty"` Iat int64 `protobuf:"bytes,4,opt,name=iat,json=Iat,proto3" json:"iat,omitempty"` AtHash string `protobuf:"bytes,5,opt,name=at_hash,json=AtHash,proto3" json:"at_hash,omitempty"` Scope string `protobuf:"bytes,6,opt,name=scope,json=Scope,proto3" json:"scope,omitempty"` // ClientID string `protobuf:"bytes,7,opt,name=client_id,json=ClientID,proto3" json:"client_id,omitempty` ProjectID string `protobuf:"bytes,8,opt,name=project_id,json=ProjectID,proto3" json:"project_id,omitempty"` ServiceID string `protobuf:"bytes,9,opt,name=service_id,json=ServiceID,proto3" json:"service_id,omitempty"` ServiceName string `protobuf:"bytes,10,opt,name=service_name,json=ServiceName,proto3" json:"service_name,omitempty"` Sub string `protobuf:"bytes,10,opt,name=sub,json=Sub,proto3" json:"sub,omitempty"` }
IDToken IDToken
type OidcAuthFuncHandler ¶
IDToken IDToken
func DefaultAuthHandler ¶
func DefaultAuthHandler() OidcAuthFuncHandler
Click to show internal directories.
Click to hide internal directories.