(schema string)
| 176 | } |
| 177 | |
| 178 | func ParseAuthMeta(schema string) (*AuthMeta, error) { |
| 179 | metaInfo, err := Parse(schema) |
| 180 | if err != nil { |
| 181 | return nil, err |
| 182 | } |
| 183 | |
| 184 | if _, ok := metaInfo.SigningMethod.(*jwt.SigningMethodRSA); ok { |
| 185 | // The jwt library internally uses `bytes.IndexByte(data, '\n')` to fetch new line and fails |
| 186 | // if we have newline "\n" as ASCII value {92,110} instead of the actual ASCII value of 10. |
| 187 | // To fix this we replace "\n" with new line's ASCII value. |
| 188 | bytekey := bytes.ReplaceAll([]byte(metaInfo.VerificationKey), []byte{92, 110}, []byte{10}) |
| 189 | |
| 190 | if metaInfo.RSAPublicKey, err = jwt.ParseRSAPublicKeyFromPEM(bytekey); err != nil { |
| 191 | return nil, err |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | return metaInfo, nil |
| 196 | } |
| 197 | |
| 198 | func (a *AuthMeta) GetHeader() string { |
| 199 | if a == nil { |
no test coverage detected