Skip to content
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

Experimental bearer token auth mechanism #201

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/core/infra/repositories/ApiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export class ApiConfig {

export enum DataverseApiAuthMechanism {
API_KEY = 'api-key',
SESSION_COOKIE = 'session-cookie' // Temporal and only for dev purposes
SESSION_COOKIE = 'session-cookie', // Temporal and only for dev purposes
BEARER_TOKEN = 'bearer-token'
}
9 changes: 9 additions & 0 deletions src/core/infra/repositories/apiConfigBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
requestConfig.headers['X-Dataverse-Key'] = ApiConfig.dataverseApiKey
}
break
case DataverseApiAuthMechanism.BEARER_TOKEN:
// TODO: ROCP_token name should be configurable and extracted to an environment variable / application constant.
let token = localStorage.getItem('ROCP_token')

Check failure on line 37 in src/core/infra/repositories/apiConfigBuilders.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected lexical declaration in case block
if (token) {
token = token.replace(/^"(.*)"$/, '$1')
requestConfig.headers['Authorization'] = 'Bearer ' + token
}
requestConfig.withCredentials = false
break
}
return requestConfig
}
Expand Down
Loading