Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
93a5b319
Commit
93a5b319
authored
6 years ago
by
Alexandru Munteanu
Browse files
Options
Downloads
Patches
Plain Diff
add EiC authsome policy
parent
b74266f2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!13
Sprint #14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/xpub-faraday/config/authsome-mode.js
+22
-4
22 additions, 4 deletions
packages/xpub-faraday/config/authsome-mode.js
with
22 additions
and
4 deletions
packages/xpub-faraday/config/authsome-mode.js
+
22
−
4
View file @
93a5b319
...
...
@@ -52,7 +52,7 @@ function unauthenticatedUser(operation, object) {
const
createPaths
=
[
'
/collections
'
,
'
/collections/:collectionId/fragments
'
]
async
function
authenticatedUser
(
user
,
operation
,
object
,
context
)
{
async
function
a
pplyA
uthenticatedUser
Policy
(
user
,
operation
,
object
,
context
)
{
if
(
operation
===
'
GET
'
)
{
if
(
get
(
object
,
'
path
'
)
===
'
/collections
'
)
{
return
{
...
...
@@ -247,6 +247,23 @@ async function authenticatedUser(user, operation, object, context) {
return
unauthenticatedUser
(
operation
,
object
)
}
async
function
applyEditorInChiefPolicy
(
user
,
operation
,
object
,
context
)
{
if
(
operation
===
'
GET
'
)
{
if
(
get
(
object
,
'
type
'
)
===
'
collection
'
)
{
return
{
filter
:
collection
=>
({
...
collection
,
visibleStatus
:
get
(
statuses
,
`
${
collection
.
status
}
.editorInChief.label`
,
),
}),
}
}
}
return
true
}
const
authsomeMode
=
async
(
userId
,
operation
,
object
,
context
)
=>
{
if
(
!
userId
)
{
return
unauthenticatedUser
(
operation
,
object
)
...
...
@@ -256,11 +273,12 @@ const authsomeMode = async (userId, operation, object, context) => {
// authorization/authsome mode, e.g.
const
user
=
await
context
.
models
.
User
.
find
(
userId
)
// Admins and editor in chiefs can do anything
if
(
user
&&
(
user
.
admin
||
user
.
editorInChief
))
return
true
if
(
get
(
user
,
'
admin
'
)
||
get
(
user
,
'
editorInChief
'
))
{
return
applyEditorInChiefPolicy
(
user
,
operation
,
object
,
context
)
}
if
(
user
)
{
return
authenticatedUser
(
user
,
operation
,
object
,
context
)
return
a
pplyA
uthenticatedUser
Policy
(
user
,
operation
,
object
,
context
)
}
return
false
...
...
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