// 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" // SubRequest
HTTPAuthTypeTypeA HTTPAuthType = "typeA"
HTTPAuthTypeTypeB HTTPAuthType = "typeB"
HTTPAuthTypeTypeC HTTPAuthType = "typeC"
HTTPAuthTypeTypeD HTTPAuthType = "typeD"
HTTPAuthTypeTypeE HTTPAuthType = "typeE"
)
type HTTPAuthTypeDefinition struct {
Name string `json:"name"`
Code string `json:"code"`
Description string `json:"description"`
IsPlus bool `json:"isPlus"`
}
func FindAllHTTPAuthTypes(role string) []*HTTPAuthTypeDefinition {
urlDocA := ""
urlDocB := ""
urlDocC := ""
urlDocD := ""
urlDocE := "https://help.aliyun.com/zh/cdn/user-guide/type-c-signing"
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
[算法详解]",
IsPlus: true,
},
{
Name: "URL鉴权B",
Code: HTTPAuthTypeTypeB,
Description: "示例URL:https://example.com/1661753540/af5df08679b86f9a51436983eb86f820/images/test.jpg
[算法详解]",
IsPlus: true,
},
{
Name: "URL鉴权C",
Code: HTTPAuthTypeTypeC,
Description: "示例URL:https://example.com/d8cd2b671fae56342fdd82e3df88c9a3/1661753633/images/test.jpg
[算法详解]",
IsPlus: true,
},
{
Name: "URL鉴权D",
Code: HTTPAuthTypeTypeD,
Description: "示例URL:https://example.com/images/test.jpg?sign=f66af42f87cf63a64f4b86ec11c7797a&t=1661753717
[算法详解]",
IsPlus: true,
},
{
Name: "URL鉴权E",
Code: HTTPAuthTypeTypeE,
Description: "严格兼容阿里云 Type-C 路径鉴权,示例URL:https://example.com/3a2c79f2d2f0df2f8f9e05ec9f482e5d/67cfdb9e/images/test.jpg
[阿里云文档]",
IsPlus: true,
},
{
Name: "基本认证",
Code: HTTPAuthTypeBasicAuth,
Description: "BasicAuth,最简单的 HTTP 请求认证方式,通过传递 Authorization: Basic xxx Header 认证。",
},
{
Name: "子请求",
Code: HTTPAuthTypeSubRequest,
Description: "通过自定义的 URL 子请求来认证请求。",
},
}
}