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

Function hasPoormansAuth

edgraph/server.go:2186–2202  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

2184}
2185
2186func hasPoormansAuth(ctx context.Context) error {
2187 if worker.Config.AuthToken == "" {
2188 return nil
2189 }
2190 md, ok := metadata.FromIncomingContext(ctx)
2191 if !ok {
2192 return errNoAuth
2193 }
2194 tokens := md.Get("auth-token")
2195 if len(tokens) == 0 {
2196 return errNoAuth
2197 }
2198 if subtle.ConstantTimeCompare([]byte(tokens[0]), []byte(worker.Config.AuthToken)) != 1 {
2199 return errors.Errorf("Provided auth token [%s] does not match. Permission denied.", tokens[0])
2200 }
2201 return nil
2202}
2203
2204// ParseMutationObject tries to consolidate fields of the api.Mutation into the
2205// corresponding field of the returned dql.Mutation. For example, the 3 fields,

Callers 3

StreamExtSnapshotMethod · 0.70
hasAdminAuthFunction · 0.70

Calls 2

GetMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected