Motivation
The @secret directive
Dgraph GraphQL has support for @secret directive to have password fields. Adding @secret field for a type, generates the check<Type>Password
query The query returns an instance of the Type if the correct ID and password field is passed. The query was designed to be used for authentication by privileged (admin) users.
Example:
type Author @secret(field: "pwd") {
name: String! @id
token: String
}
generates the query,
query {
checkAuthorPassword(name: String!, pwd: String!): Author
}
Combining @secret and @auth directive
We also support Authorization using the @auth directive. With @auth directive, rules can be provided for query
, add
, delete
, update
queries / mutations which are used for the respective queries / mutations.
Eventhough, checkPassword
is a separate query, it internally is treated like a different form of get
query and also uses auth
rules specified by query
field.
The recent discuss posts Combining @secret and @auth directives and Auth rule with other directives show that this is proving to be problematic. The checkPassword
query does not work in cases in which it is used for authenticating newly created Users. The usecase here is to use checkPassword
at the time of Sign In of Users.
Proposed Solution
To solve this problem, there are 2 possible solutions.
- Have a separate field in
@auth
directive, saypwd
. This field could be used for specifying the auth rule to be applied forcheckPassword
query. In case no rule has been specified forpwd
, thequery
rule could be used. - Disable applying of auth rules for
checkPassword
query.
Possible Drawbacks
- Making the
checkPassword
query not follow any auth rules could lead to its misuse and brute force attacks to guess password.
@spinelsun , @gregerolsson , @amaster507, @maaft , We will like to know more about your use case and which solution fits your needs.