M auth/middleware.go => auth/middleware.go +3 -2
@@ 279,8 279,9 @@ func internalAuth(payload []byte, w http.ResponseWriter, r *http.Request, next h
auth.AuthMethod = AUTH_INTERNAL
}
} else {
- // Using anonymous internal auth. This is only used in one specific
- // situation: registering for a new account.
+ // Using anonymous internal auth. This is used in situations where a
+ // user context can not (yet) be established: registering an account,
+ // looking up SSH keys, etc.
auth = &AuthContext{}
auth.AuthMethod = AUTH_ANON_INTERNAL
}
M server/directives.go => server/directives.go +4 -4
@@ 22,11 22,11 @@ func Admin(ctx context.Context, obj any,
func AnonInternal(ctx context.Context, obj any,
next graphql.Resolver) (any, error) {
- if auth.ForContext(ctx).AuthMethod != auth.AUTH_ANON_INTERNAL {
- return nil, fmt.Errorf("anonymous internal auth access denied")
+ switch auth.ForContext(ctx).AuthMethod {
+ case auth.AUTH_ANON_INTERNAL, auth.AUTH_INTERNAL:
+ return next(ctx)
}
-
- return next(ctx)
+ return nil, fmt.Errorf("anonymous internal auth access denied")
}
func Internal(ctx context.Context, obj any,