Skip to content
Snippets Groups Projects
Commit 1c5c4617 authored by Chris Beer's avatar Chris Beer
Browse files

Support IIIF Auth v0.9

parent 155d7b1d
No related branches found
No related tags found
No related merge requests found
......@@ -344,6 +344,10 @@ export default {
{ profile: 'http://iiif.io/api/auth/1/kiosk', kiosk: true },
{ profile: 'http://iiif.io/api/auth/1/clickthrough' },
{ profile: 'http://iiif.io/api/auth/1/login' },
{ profile: 'http://iiif.io/api/auth/0/external', external: true },
{ profile: 'http://iiif.io/api/auth/0/kiosk', kiosk: true },
{ profile: 'http://iiif.io/api/auth/0/clickthrough' },
{ profile: 'http://iiif.io/api/auth/0/login' }
]
}
};
......@@ -23,9 +23,11 @@ const mapStateToProps = (state, { windowId }) => {
const accessTokenService = service && (
Utils.getService(service, 'http://iiif.io/api/auth/1/token')
|| Utils.getService(service, 'http://iiif.io/api/auth/0/token')
);
const logoutService = service && (
Utils.getService(service, 'http://iiif.io/api/auth/1/logout')
|| Utils.getService(service, 'http://iiif.io/api/auth/0/logout')
);
const authStatuses = getAuth(state) || {};
......
......
......@@ -52,7 +52,8 @@ export function* refetchInfoResponses({ serviceId }) {
const haveThisTokenService = infoResponse => {
const services = Utils.getServices(infoResponse);
return services.some(e => {
const infoTokenService = Utils.getService(e, 'http://iiif.io/api/auth/1/token');
const infoTokenService = Utils.getService(e, 'http://iiif.io/api/auth/1/token')
|| Utils.getService(e, 'http://iiif.io/api/auth/0/token');
return infoTokenService && infoTokenService.id === serviceId;
});
};
......@@ -89,7 +90,8 @@ export function* doAuthWorkflow({ infoJson, windowId }) {
// start the auth
yield put(addAuthenticationRequest(windowId, authService.id, authService.getProfile()));
} else if (profileConfig.external) {
const tokenService = Utils.getService(authService, 'http://iiif.io/api/auth/1/token');
const tokenService = Utils.getService(authService, 'http://iiif.io/api/auth/1/token')
|| Utils.getService(authService, 'http://iiif.io/api/auth/0/token');
if (!tokenService) return;
// resolve the auth
......@@ -105,7 +107,8 @@ export function* rerequestOnAccessTokenFailure({ infoJson, windowId, tokenServic
// make sure we have an auth service to try
const authService = Utils.getServices(infoJson).find(service => {
const tokenService = Utils.getService(service, 'http://iiif.io/api/auth/1/token');
const tokenService = Utils.getService(service, 'http://iiif.io/api/auth/1/token')
|| Utils.getService(service, 'http://iiif.io/api/auth/0/token');
return tokenService && tokenService.id === tokenServiceId;
});
......
......
......@@ -126,7 +126,8 @@ function* getAccessTokenService(resource) {
for (let i = 0; i < services.length; i += 1) {
const authService = services[i];
const accessTokenService = Utils.getService(authService, 'http://iiif.io/api/auth/1/token');
const accessTokenService = Utils.getService(authService, 'http://iiif.io/api/auth/1/token')
|| Utils.getService(authService, 'http://iiif.io/api/auth/0/token');
const token = accessTokenService && accessTokens[accessTokenService.id];
if (token && token.json) return token;
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment