endpoint

package
v0.0.0-...-de569a9 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 认证详情key
	OAuth2DetailsKey = "OAuth2Details"
	// 客户端详情key
	OAuth2ClientDetailsKey = "OAuth2ClientDetails"
	// 认证错误key
	OAuth2ErrorKey = "OAuth2Error"
)

请求上下文使用的key

Variables

View Source
var (
	ErrInvalidClientRequest = errors.New("invalid client message")
	ErrInvalidUserRequest   = errors.New("invalid user message")
	ErrNotPermit            = errors.New("not permit")
)

Functions

func MakeAdminEndpoint

func MakeAdminEndpoint(svc service.Service) endpoint.Endpoint

创建Admin终端

func MakeAuthorityAuthorizationMiddleware

func MakeAuthorityAuthorizationMiddleware(authority string, logger log.Logger) endpoint.Middleware

创建验权中间件,需要验证权限

func MakeCheckTokenEndpoint

func MakeCheckTokenEndpoint(svc service.TokenService) endpoint.Endpoint

创建校验令牌终端

func MakeClientAuthorizationMiddleware

func MakeClientAuthorizationMiddleware(logger log.Logger) endpoint.Middleware

创建客户端认证中间件

func MakeHealthCheckEndpoint

func MakeHealthCheckEndpoint(svc service.Service) endpoint.Endpoint

MakeHealthCheckEndpoint 创建健康检查Endpoint

func MakeIndexEndpoint

func MakeIndexEndpoint(svc service.Service) endpoint.Endpoint

创建首页终端

func MakeOAuth2AuthorizationMiddleware

func MakeOAuth2AuthorizationMiddleware(logger log.Logger) endpoint.Middleware

创建认证中间件,需要有令牌访问

func MakeSampleEndpoint

func MakeSampleEndpoint(svc service.Service) endpoint.Endpoint

创建简单示例终端

func MakeTokenEndpoint

func MakeTokenEndpoint(svc service.TokenGranter, clientService service.ClientDetailsService) endpoint.Endpoint

创建令牌终端

Types

type AdminRequest

type AdminRequest struct {
}

type AdminResponse

type AdminResponse struct {
	Result string `json:"result"`
	Error  string `json:"error"`
}

type CheckTokenRequest

type CheckTokenRequest struct {
	Token         string
	ClientDetails model.ClientDetails
}

type CheckTokenResponse

type CheckTokenResponse struct {
	OAuthDetails *model.OAuth2Details `json:"o_auth_details"`
	Error        string               `json:"error"`
}

type HealthRequest

type HealthRequest struct{}

HealthRequest 健康检查请求结构

type HealthResponse

type HealthResponse struct {
	Status bool `json:"status"`
}

HealthResponse 健康检查响应结构

type IndexRequest

type IndexRequest struct {
}

type IndexResponse

type IndexResponse struct {
	Result string `json:"result"`
	Error  string `json:"error"`
}

type OAuth2Endpoints

type OAuth2Endpoints struct {
	// 令牌终端
	TokenEndpoint endpoint.Endpoint
	// 校验令牌终端
	CheckTokenEndpoint endpoint.Endpoint
	// 健康检测终端
	HealthCheckEndpoint endpoint.Endpoint
	// 首页终端
	IndexEndpoint endpoint.Endpoint
	// 示例终端
	SampleEndpoint endpoint.Endpoint
	// admin终端
	AdminEndpoint endpoint.Endpoint
}

终端层,负责接收请求,处理请求,并返回结果。可以添加熔断、日志、限流、负载均衡等能力

type SampleRequest

type SampleRequest struct {
}

type SampleResponse

type SampleResponse struct {
	Result string `json:"result"`
	Error  string `json:"error"`
}

type TokenRequest

type TokenRequest struct {
	GrantType string
	Reader    *http.Request
}

令牌请求

type TokenResponse

type TokenResponse struct {
	AccessToken *model.OAuth2Token `json:"access_token"`
	Error       string             `json:"error"`
}

令牌响应

Jump to

Keyboard shortcuts

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