1.4.5.2
This commit is contained in:
80
EdgeCommon/pkg/serverconfigs/http_auth_methods_plus.go
Normal file
80
EdgeCommon/pkg/serverconfigs/http_auth_methods_plus.go
Normal file
@@ -0,0 +1,80 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
//go:build plus
|
||||
|
||||
package serverconfigs
|
||||
|
||||
type HTTPAuthType = string
|
||||
|
||||
const (
|
||||
HTTPAuthTypeBasicAuth HTTPAuthType = "basicAuth" // BasicAuth
|
||||
HTTPAuthTypeSubRequest HTTPAuthType = "subRequest" // 子请求
|
||||
|
||||
HTTPAuthTypeTypeA HTTPAuthType = "typeA"
|
||||
HTTPAuthTypeTypeB HTTPAuthType = "typeB"
|
||||
HTTPAuthTypeTypeC HTTPAuthType = "typeC"
|
||||
HTTPAuthTypeTypeD HTTPAuthType = "typeD"
|
||||
)
|
||||
|
||||
type HTTPAuthTypeDefinition struct {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Description string `json:"description"`
|
||||
IsPlus bool `json:"isPlus"`
|
||||
}
|
||||
|
||||
func FindAllHTTPAuthTypes(role string) []*HTTPAuthTypeDefinition {
|
||||
var urlDocA = ""
|
||||
var urlDocB = ""
|
||||
var urlDocC = ""
|
||||
var urlDocD = ""
|
||||
|
||||
switch role {
|
||||
case "admin":
|
||||
urlDocA = "https://goedge.cn/docs/Server/HTTPAuthTypeA.md"
|
||||
urlDocB = "https://goedge.cn/docs/Server/HTTPAuthTypeB.md"
|
||||
urlDocC = "https://goedge.cn/docs/Server/HTTPAuthTypeC.md"
|
||||
urlDocD = "https://goedge.cn/docs/Server/HTTPAuthTypeD.md"
|
||||
case "user":
|
||||
urlDocA = "/docs/cdn/http-auth-type-a.html"
|
||||
urlDocB = "/docs/cdn/http-auth-type-b.html"
|
||||
urlDocC = "/docs/cdn/http-auth-type-c.html"
|
||||
urlDocD = "/docs/cdn/http-auth-type-d.html"
|
||||
}
|
||||
|
||||
return []*HTTPAuthTypeDefinition{
|
||||
{
|
||||
Name: "URL鉴权A",
|
||||
Code: HTTPAuthTypeTypeA,
|
||||
Description: "示例URL:https://example.com/images/test.jpg?sign=1661753445-8453b620246d423d-8b7221a273fa96d467052b421d1a9f37<br/><a href=\"" + urlDocA + "\" target=\"_blank\">[算法详解]</a>",
|
||||
IsPlus: true,
|
||||
},
|
||||
{
|
||||
Name: "URL鉴权B",
|
||||
Code: HTTPAuthTypeTypeB,
|
||||
Description: "示例URL:https://example.com/1661753540/af5df08679b86f9a51436983eb86f820/images/test.jpg<br/><a href=\"" + urlDocB + "\" target=\"_blank\">[算法详解]</a>",
|
||||
IsPlus: true,
|
||||
},
|
||||
{
|
||||
Name: "URL鉴权C",
|
||||
Code: HTTPAuthTypeTypeC,
|
||||
Description: "示例URL:https://example.com/d8cd2b671fae56342fdd82e3df88c9a3/1661753633/images/test.jpg<br/><a href=\"" + urlDocC + "\" target=\"_blank\">[算法详解]</a>",
|
||||
IsPlus: true,
|
||||
},
|
||||
{
|
||||
Name: "URL鉴权D",
|
||||
Code: HTTPAuthTypeTypeD,
|
||||
Description: "示例URL:https://example.com/images/test.jpg?sign=f66af42f87cf63a64f4b86ec11c7797a&t=1661753717<br/><a href=\"" + urlDocD + "\" target=\"_blank\">[算法详解]</a>",
|
||||
IsPlus: true,
|
||||
},
|
||||
{
|
||||
Name: "基本认证",
|
||||
Code: HTTPAuthTypeBasicAuth,
|
||||
Description: "BasicAuth,最简单的HTTP请求认证方式,通过传递<span class=\"ui label tiny basic text\">Authorization: Basic xxx</span> Header认证。",
|
||||
},
|
||||
{
|
||||
Name: "子请求",
|
||||
Code: HTTPAuthTypeSubRequest,
|
||||
Description: "通过自定义的URL子请求来认证请求。",
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user