Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(object-authorization): Fix object authorization for interfaces #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tcitworld
Copy link

Very similar to #26, but for interfaces instead of unions

Very similar to jungsoft#26, but for interfaces instead of unions

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
@gabrielpra1
Copy link
Member

Hey @tcitworld, thank you for this PR!

However, I don't think interfaces should work exactly like Unions, because we can't always infer the authorization rules from the underlying types. It works well on your example, but it would not work for a query that fetches only common fields, since in this case we wouldn't have selections to check, as is the case for unions.

So let's say :interface has the common field :id:

    interface :interface do
      field :id, :integer
      resolve_type fn
        %{name: _}, _ -> :user
        %{total: _}, _ -> :wallet_balance
      end
    end

If we fetch only this id, the query would be allowed without any authorization checks:

  defp interface_query do
    """
    {
      interfaceQuery {
        id
      }
    }
    """
  end

Therefore, I think we need to force users to define a meta :authorize for the interfaces, and then we check that they have access to that interface, as well as all of the nested types that may be requested. Wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants