MCPcopy
hub / github.com/dgraph-io/dgraph / ParseAuthMeta

Function ParseAuthMeta

graphql/authorization/auth.go:178–196  ·  view source on GitHub ↗
(schema string)

Source from the content-addressed store, hash-verified

176}
177
178func 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
198func (a *AuthMeta) GetHeader() string {
199 if a == nil {

Callers 1

parseMetaInfoFunction · 0.92

Calls 1

ParseFunction · 0.70

Tested by

no test coverage detected