Skip to content

useGenericAuth always calls validateUser even when @skipAuth #1470

Closed

Description

@aslansky

When using generic auth in "protect-all" mode the documentation states:

Then, in your GraphQL schema SDL, you can add @skipAuth directive to your fields, and the validateUser will not get called while resolving that specific field

This does not seem to be true. The validateUser always gets called, even when @skipAuth is set on the field.

I am not sure if documentation is wrong or there needs to be a check added to the plugins handleField function when @skipAuth is enabled.

Activity

  1. n1ru4l commented on Aug 12, 2022

    @n1ru4l
    Collaborator

    Hey @aslansky do you think you can provide a minimal reproduction on CodeSandbox or Stackblitz or even better a PR with a failing test?

  2. added a commit that references this issue on Aug 12, 2022
  3. aslansky commented on Aug 12, 2022

    @aslansky
    ContributorAuthor

    The behaviour is the same for @auth and @skipAuth, but as I said, I am not sure if this is expected behaviour and the user needs to handle the check for fieldAuthDirectiveNode and fieldAuthExtension in the custom validateUser function.

  4. n1ru4l commented on Aug 12, 2022

    @n1ru4l
    Collaborator

    @aslansky From the test it is now more clear to me.

    validateUser is called in that case as well because the field could behave differently based on whether a user is authenticated or not. E.g. if you have a Query.feed field it could either resolve to a generic feed if the user resolved from validateUser is null or a customized user feed if the user resolved from validateUser is non-null 9e.g. a user object).

    Does that make sense to you? In the meanwhile I will change this issue to a discussion!

  5. locked and limited conversation to collaborators on Aug 12, 2022
  6. converted this issue into a discussion #1475 on Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions