xoidc

package
v0.0.0-...-80fcaa9 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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 GetDeviceID(mds map[string]string) string

func GetIPFromMeta

func GetIPFromMeta(mds map[string]string) string

GetIPFromMeta returns IP address from request. Only when it used use proxy

func GetUserAgent

func GetUserAgent(mds map[string]string) string

func InitByConfig

func InitByConfig(iss string, cfg *oidc.Config) error

func InitOIDC

func InitOIDC(path string) error

InitOIDC InitOIDC oidcissue 内网填写 https://apis.xbase.xyz , 外网填写:https://apis.xbase.cloud

func StreamServerInterceptor

func StreamServerInterceptor(fn OidcAuthFuncHandler) grpc.StreamServerInterceptor

GrpcStreamServerInterceptor .

func VerifyHas

func VerifyHas(par string, data []string) error

Types

type AuthConfig

type AuthConfig struct {
	Issuer         string   `json:"issuer" yaml:"issuer"`
	AllowProjects  []string `json:"allow_projects" yaml:"allow_projects"`
	Scopes         []string `json:"scopes" yaml:"scopes"`
	AllowedIssuers []string `json:"allowed_issuers" yaml:"allowed_issuers"`
}

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

func VerifyIDToken

func VerifyIDToken(ctx context.Context, token string) (*IDToken, error)

VerifyIDToken VerifyIDToken the id token

type OidcAuthFuncHandler

type OidcAuthFuncHandler func(ctx context.Context, fullmethod string, token *IDToken) error

IDToken IDToken

func DefaultAuthHandler

func DefaultAuthHandler() OidcAuthFuncHandler

Jump to

Keyboard shortcuts

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