Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab 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
IIIF
Mirador
Mirador Video
Commits
32dd9ab4
Unverified
Commit
32dd9ab4
authored
Sep 17, 2020
by
Jack Reed
Committed by
GitHub
Sep 17, 2020
Browse files
Options
Downloads
Plain Diff
Merge pull request #3254 from ProjectMirador/auth-refactor
Consolidate IIIF auth behaviors
parents
b15cbb61
6653ec3d
No related branches found
No related tags found
No related merge requests found
Changes
41
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/state/selectors/canvases.js
+0
-98
0 additions, 98 deletions
src/state/selectors/canvases.js
with
0 additions
and
98 deletions
src/state/selectors/canvases.js
+
0
−
98
View file @
32dd9ab4
import
{
createSelector
}
from
'
reselect
'
;
import
{
Utils
}
from
'
manifesto.js/dist-esmodule/Utils
'
;
import
flatten
from
'
lodash/flatten
'
;
import
CanvasGroupings
from
'
../../lib/CanvasGroupings
'
;
import
MiradorCanvas
from
'
../../lib/MiradorCanvas
'
;
...
...
@@ -206,100 +205,3 @@ export const selectInfoResponse = createSelector(
&&
infoResponses
[
iiifServiceId
];
},
);
const
authServiceProfiles
=
{
clickthrough
:
true
,
external
:
true
,
kiosk
:
true
,
login
:
true
,
};
/**
*
*/
export
function
selectNextAuthService
({
auth
},
resource
,
filter
=
authServiceProfiles
)
{
const
orderedAuthServiceProfiles
=
[
'
http://iiif.io/api/auth/1/external
'
,
'
http://iiif.io/api/auth/1/kiosk
'
,
'
http://iiif.io/api/auth/1/clickthrough
'
,
'
http://iiif.io/api/auth/1/login
'
,
];
const
mapFilterToProfiles
=
{
'
http://iiif.io/api/auth/1/clickthrough
'
:
'
clickthrough
'
,
'
http://iiif.io/api/auth/1/external
'
:
'
external
'
,
'
http://iiif.io/api/auth/1/kiosk
'
:
'
kiosk
'
,
'
http://iiif.io/api/auth/1/login
'
:
'
login
'
,
};
for
(
const
profile
of
orderedAuthServiceProfiles
)
{
const
services
=
getServices
(
resource
,
profile
);
for
(
const
service
of
services
)
{
if
(
!
auth
[
service
.
id
])
{
return
filter
[
mapFilterToProfiles
[
profile
]]
&&
service
;
}
if
(
auth
[
service
.
id
].
isFetching
||
auth
[
service
.
id
].
ok
)
return
null
;
}
}
return
null
;
}
/** */
export
function
selectActiveAuthService
(
state
,
resource
)
{
const
orderedAuthServiceProfiles
=
[
'
http://iiif.io/api/auth/1/login
'
,
'
http://iiif.io/api/auth/1/clickthrough
'
,
'
http://iiif.io/api/auth/1/kiosk
'
,
'
http://iiif.io/api/auth/1/external
'
,
];
for
(
const
profile
of
orderedAuthServiceProfiles
)
{
const
services
=
getServices
(
resource
,
profile
);
const
service
=
services
.
find
(
s
=>
selectAuthStatus
(
state
,
s
));
if
(
service
)
return
service
;
}
return
null
;
}
export
const
selectCanvasAuthService
=
createSelector
(
[
selectInfoResponse
,
state
=>
state
,
],
(
infoResponse
,
state
)
=>
{
const
resource
=
infoResponse
&&
infoResponse
.
json
;
if
(
!
resource
)
return
undefined
;
return
selectNextAuthService
(
state
,
resource
)
||
selectActiveAuthService
(
state
,
resource
);
},
);
export
const
selectLogoutAuthService
=
createSelector
(
[
selectInfoResponse
,
state
=>
state
,
],
(
infoResponse
,
state
)
=>
{
if
(
!
infoResponse
)
return
undefined
;
const
authService
=
selectActiveAuthService
(
state
,
infoResponse
.
json
);
if
(
!
authService
)
return
undefined
;
return
authService
.
getService
(
'
http://iiif.io/api/auth/1/logout
'
);
},
);
/** */
export
function
selectAuthStatus
({
auth
},
service
)
{
if
(
!
service
)
return
null
;
if
(
!
auth
[
service
.
id
])
return
null
;
if
(
auth
[
service
.
id
].
isFetching
)
return
'
fetching
'
;
if
(
auth
[
service
.
id
].
ok
)
return
'
ok
'
;
return
'
failed
'
;
}
/** Get all the services that match a profile */
function
getServices
(
resource
,
profile
)
{
const
services
=
Utils
.
getServices
({
...
resource
,
options
:
{}
});
return
services
.
filter
(
service
=>
service
.
getProfile
()
===
profile
);
}
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
Preview
0%
Loading
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
sign in
to comment