Question: How do you recommend enforcing authorization?
See original GitHub issueHello,
I’d like to systematically enforce authorization for nodes and individual fields within the nodes.
Conceptually something like this might work:
class MyNode(AuthZSQLAlchemyObjectType):
class Meta:
model = MyModel
authorize_node_function = node_authorizer
field_auth = dict(
"name": all_authorizer,
"private_things": self_only_authorizer,
)
node_authorizer(model_instance)
would get called whenever a new Node of that type is created. Only fields in the field_auth dict would be exposed in node, and then the associated function would be called like resolve_authorizer(model_instance, field_name)
Any opinions on the best way to achieve this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
How to properly enforce authorization | by Security Lit Limited
Due to the frightening consequences that it can have, it becomes extremely important to enforce Authorization Properly.
Read more >Authorization - OWASP Cheat Sheet Series
Failure to enforce least privileges in an application can jeopardize the confidentiality ... Thoroughly Review the Authorization Logic of Chosen Tools and ...
Read more >What is Authorization? - Oso
Authorization is the mechanism for controlling who can do what in an application. It's how you make sure users have access to their...
Read more >Best practices for REST API security: Authentication and ...
There are three reasons you might find yourself writing a REST API ... Choose when to enforce authorization with request-level authorization.
Read more >Authentication vs. Authorization: What's the Difference?
Unfortunately, people often use both terms interchangeably as they both refer to system access. However, they are distinct processes. Simply put, one verifies ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is somewhat old but still open. Has there been any additional development to support this in graphene-sqlalchemy, or are there authorization patterns the community has settled on as workable?
Thanks @Nabellaleen Those approaches seem inline with what we’d like to do.
Our goals:
only_fields
like whitelist)We had been solving these concerns by being using
only_fields
on every Node and then overriding the resolve methods for columns where we need authorization controls. But that has become cumbersome and error prone. We have a lot of boilerplate code that looks like this:I’ve been experimenting with the concept above and it’s pretty similar to what @dfee suggests here https://github.com/graphql-python/graphene-django/issues/79#issuecomment-306583068
It seems to work, and I wonder if we can get some consensus around an approach that could be pushed upstream and be generally useful.
One fundamental challenge to overcome in this community is that graphene-django is basically a superset and fork of graphene-sqlalchemy.