Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Labels
Plan
Issues
25
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cokoapps
server
Commits
28e9b37a
Commit
28e9b37a
authored
4 years ago
by
Yannis Barlas
Browse files
Options
Downloads
Patches
Plain Diff
docs(middleware): update authorization readme
parent
18319e8f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+4
-0
4 additions, 0 deletions
README.md
with
4 additions
and
0 deletions
README.md
+
4
−
0
View file @
28e9b37a
...
...
@@ -41,6 +41,7 @@ If you place this file in `server/app.js`, starting the server should work autom
The server provides authorization checks through using
`graphql-shield`
.
You can access all of shield's exports (eg.
`rule`
,
`and`
,
`or`
etc.) through
`@coko/server/authorization`
.
The only exception is
`shield`
, which is used internally by the server.
Besides shield's exports, two helpers,
`isAdmin`
and
`isAuthenticated`
are provided.
To get started, declare your permissions in any file you want:
...
...
@@ -54,6 +55,9 @@ const permissions = {
myQuery
:
rule
()(
async
(
parent
,
args
,
ctx
,
info
)
=>
{
// my auth logic here
}),
// using provided helpers
anotherQuery
:
isAdmin
,
yetAnotherQuery
:
isAuthenticated
,
},
Mutation
:
{
myMutation
:
rule
()(
async
(
parent
,
args
,
ctx
,
info
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment