-
Notifications
You must be signed in to change notification settings - Fork 3
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
[DPLT-1042] Add support for backend only mutations from Runner #109
[DPLT-1042] Add support for backend only mutations from Runner #109
Conversation
40c9b8f
to
331d8d2
Compare
@@ -13,5 +13,9 @@ pub(crate) async fn auth(req: HttpRequest) -> impl Responder { | |||
None => std::env::var("DEFAULT_HASURA_ROLE").unwrap(), | |||
}; | |||
|
|||
if role_header == "admin" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to this, it was possible to assume the admin
role by specifying it on the headers. This disables that functionality so that it is not possible to workaround the Backend Only Mutations.
Note that assuming admin
is still possible by passing the specifying the X-Hasura-Admin-Secret
header.
'X-Hasura-Use-Backend-Only-Permissions': 'true', | ||
...(hasuraRoleName && { | ||
'X-Hasura-Role': hasuraRoleName, | ||
'X-Hasura-Admin-Secret': process.env.HASURA_ADMIN_SECRET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only attach the admin secret if a role is specified - if this were attached without specifying a role, admin
would be used, granting the request access to everything.
@@ -354,7 +354,12 @@ export default class Indexer { | |||
method: 'POST', | |||
headers: { | |||
'Content-Type': 'application/json', | |||
...(hasuraRoleName && { 'X-Hasura-Role': hasuraRoleName }) | |||
'X-Hasura-Use-Backend-Only-Permissions': 'true', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't affect requests to tables without this flag enabled on the role.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This PR adds support for Backend Only Mutations in the Lambda Runner.
To mark a mutation as Backend Only, the flag must be set for the relevant Role. This makes the mutation hidden by default, and only accessible when the
X-Hasura-Use-Backend-Only-Permissions
, relevantX-Hasura-Role
, andX-Hasura-Admin-Secret
headers are present on the request. As the secret is secret, the mutation is mostly inaccessible to frontends, but not it is still possible to call it if you have the secret.Backend Only Mutations are only hidden for the relevant role. So if another role has unrestricted access to the mutation it will be able to execute it. This means that supplying the
X-Hasura-Admin-Secret
alone, therefore assuming theadmin
role which has access to everything, is enough to call the 'Backend Only Mutation'. This shouldn't be a concern as we are only ones with the secret.