Skip to content

graphql: add GraphQL authorisation #5179

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

Merged
merged 25 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
43245da
Add Auth directive (#5178)
MichaelJCompton Apr 13, 2020
ffe62ef
graphql: parse auth rules (#5180)
MichaelJCompton Apr 13, 2020
0d95533
Fix parsing of `and` and `not` rule.
Apr 14, 2020
28d3649
Fix test.
Apr 14, 2020
c7727dc
Merge branch 'master' into graphql/authorization
MichaelJCompton Apr 19, 2020
60f6782
Added query rewriting and e2e tests (#5229)
harshil-goel Apr 20, 2020
e62b876
skip all and make compile (#5245)
MichaelJCompton Apr 20, 2020
91355e1
Parse and evaluate RBAC rules. (#5210)
Apr 20, 2020
cddeee6
Merge branch 'master' into graphql/authorization
MichaelJCompton Apr 20, 2020
d4041f0
Added test cases for auth schema parsing. (#5195)
Apr 21, 2020
b513780
Merge branch 'master' into graphql/authorization
MichaelJCompton Apr 21, 2020
22ceae6
graphql: process auth query rules (#5181)
MichaelJCompton Apr 22, 2020
ac5900b
Merge branch 'master' into graphql/authorization
MichaelJCompton Apr 27, 2020
2afb4dd
fix tests after merge
MichaelJCompton Apr 27, 2020
2df9888
graphql: delete authorization (#5270)
MichaelJCompton Apr 28, 2020
0db9b22
Parse auth meta info from schema. (#5269)
Apr 28, 2020
02a3a54
Merge branch 'master' into graphql/authorization
MichaelJCompton Apr 29, 2020
1729947
graphql: auth on add update mutations (#5300)
MichaelJCompton Apr 29, 2020
1619dd9
Merge branch 'master' into graphql/authorization
MichaelJCompton Apr 30, 2020
9be6565
[graphql] Adds query e2e tests for authentication.
harshil-goel Apr 30, 2020
cd62d6e
Merge branch 'master' into graphql/authorization
MichaelJCompton May 4, 2020
60826e9
Merge branch 'master' into graphql/authorization
MichaelJCompton May 5, 2020
75be5d3
bump some test numbers after merge
MichaelJCompton May 5, 2020
3cddb05
graphql: more testing around additional deletes and auth (#5357)
MichaelJCompton May 5, 2020
c992d4e
Add RSA algo for JWT token verification. (#5358)
May 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions graphql/schema/gqlschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
dgraphPredArg = "pred"
idDirective = "id"
secretDirective = "secret"
authDirective = "auth"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authDirective is unused (from varcheck)


deprecatedDirective = "deprecated"
NumUid = "numUids"
Expand Down Expand Up @@ -67,11 +68,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ enum Role {
User
}

directive @auth(r: Role = User) on FIELD_DEFINITION
directive @auth2(r: Role = User, b: Role = User) on FIELD_DEFINITION
directive @auth3(r: Role = User, b: Role = User) on FIELD_DEFINITION
directive @unkown1(r: Role = User) on OBJECT | FIELD_DEFINITION
directive @unkown2(r: Role = User, b: Role = User) on FIELD_DEFINITION
directive @unkown3(r: Role = User, b: Role = User) on FIELD_DEFINITION

type Product @auth {
type Product @unkown1 {
id: ID!
price: Float! @search @auth(r: Admin) @auth2(r: User, b: Admin)
name: String! @auth(r: Admin) @search @auth2 @auth3 @dgraph(pred: "p")
name2: String! @auth(r: Admin) @search @auth2 @dgraph(pred: "p") @auth3
price: Float! @search @unkown1(r: Admin) @unkown2(r: User, b: Admin)
name: String! @unkown1(r: Admin) @search @unkown2 @unkown3 @dgraph(pred: "p")
name2: String! @unkown1(r: Admin) @search @unkown2 @dgraph(pred: "p") @unkown3
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
12 changes: 12 additions & 0 deletions graphql/schema/testdata/schemagen/output/deprecated.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
12 changes: 12 additions & 0 deletions graphql/schema/testdata/schemagen/output/hasInverse.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,23 @@ enum DgraphIndex {
hour
}

input AuthRule {
and: [AuthRule]
or: [AuthRule]
not: AuthRule
rule: String
}

directive @hasInverse(field: String!) on FIELD_DEFINITION
directive @search(by: [DgraphIndex!]) on FIELD_DEFINITION
directive @dgraph(type: String, pred: String) on OBJECT | INTERFACE | FIELD_DEFINITION
directive @id on FIELD_DEFINITION
directive @secret(field: String!, pred: String) on OBJECT | INTERFACE
directive @auth(
query: AuthRule,
add: AuthRule,
update: AuthRule,
delete:AuthRule) on OBJECT | FIELD_DEFINITION

input IntFilter {
eq: Int
Expand Down
Loading