@@ -6,11 +6,11 @@ import (
66 "fmt"
77 "strconv"
88 "strings"
9-
9+
1010 auth_driver "github.com/APIParkLab/APIPark/module/application-authorization/auth-driver"
11-
11+
1212 "github.com/eolinker/go-common/utils"
13-
13+
1414 application_authorization_dto "github.com/APIParkLab/APIPark/module/application-authorization/dto"
1515)
1616
@@ -26,12 +26,12 @@ type Config struct {
2626 Iss string `json:"iss"`
2727 Algorithm string `json:"algorithm"`
2828 Secret string `json:"secret"`
29- PublicKey string `json:"public_key "`
29+ PublicKey string `json:"publicKey "`
3030 User string `json:"user"`
31- UserPath string `json:"user_path "`
32- ClaimsToVerify []string `json:"claims_to_verify "`
31+ UserPath string `json:"userPath "`
32+ ClaimsToVerify []string `json:"claimsToVerify "`
3333 Label map [string ]string `json:"label"`
34- SignatureIsBase64 bool `json:"signature_is_base64 "`
34+ SignatureIsBase64 bool `json:"signatureIsBase64 "`
3535}
3636
3737func (cfg * Config ) ID () string {
@@ -46,7 +46,7 @@ func (cfg *Config) ID() string {
4646 for _ , claim := range cfg .ClaimsToVerify {
4747 builder .WriteString (strings .TrimSpace (claim ))
4848 }
49-
49+
5050 case "RS256" , "RS384" , "RS512" , "ES256" , "ES384" , "ES512" :
5151 builder .WriteString (strings .TrimSpace (cfg .Iss ))
5252 builder .WriteString (strings .TrimSpace (cfg .PublicKey ))
@@ -81,7 +81,7 @@ func (cfg *Config) Valid() ([]byte, error) {
8181 default :
8282 return nil , fmt .Errorf ("unsupport algorithm" )
8383 }
84-
84+
8585 //校验 校验字段
8686 for _ , claim := range cfg .ClaimsToVerify {
8787 switch claim {
@@ -94,26 +94,26 @@ func (cfg *Config) Valid() ([]byte, error) {
9494}
9595
9696func (cfg * Config ) Detail () []application_authorization_dto.DetailItem {
97-
97+
9898 items := []application_authorization_dto.DetailItem {
9999 {Key : "Iss" , Value : cfg .Iss },
100100 {Key : "签名算法" , Value : cfg .Algorithm },
101101 {Key : "用户名" , Value : cfg .User },
102102 {Key : "用户名JsonPath" , Value : cfg .UserPath },
103103 {Key : "校验字段" , Value : strings .Join (cfg .ClaimsToVerify , "," )},
104104 }
105-
105+
106106 switch cfg .Algorithm {
107107 case "HS256" , "HS384" , "HS512" :
108108 items = append (items , application_authorization_dto.DetailItem {Key : "Secret" , Value : cfg .Secret })
109109 base64 := "false"
110110 if cfg .SignatureIsBase64 {
111111 base64 = "true"
112112 }
113- items = append (items , application_authorization_dto.DetailItem {Key : "Secret " , Value : base64 })
113+ items = append (items , application_authorization_dto.DetailItem {Key : "SignatureIsBase64 " , Value : base64 })
114114 default :
115115 items = append (items , application_authorization_dto.DetailItem {Key : "RSA公钥" , Value : cfg .PublicKey })
116116 }
117-
117+
118118 return items
119119}
0 commit comments