Skip to content

Commit

Permalink
fix(website): allow unauthenticated users to view datasets (#1263)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukepereira committed Mar 8, 2024
1 parent 4d6e36f commit fcdf8aa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class SecurityConfig {

private val getEndpointsThatArePublic = arrayOf(
"/data-use-terms/*",
"/get-dataset",
"/get-dataset-records",
"get-dataset-cited-by-publication",
)

@Bean
Expand Down
4 changes: 0 additions & 4 deletions website/src/pages/datasets/[datasetId].astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { getRuntimeConfig } from '../../config';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { DatasetCitationClient } from '../../services/datasetCitationClient.ts';
import type { Dataset } from '../../types/datasetCitation';
import { createAuthorizationHeader } from '../../utils/createAuthorizationHeader.ts';
import { getAccessToken } from '../../utils/getAccessToken';
const clientConfig = getRuntimeConfig().public;
Expand All @@ -20,17 +19,14 @@ const datasetClient = DatasetCitationClient.create();
const datasetResponse = (await datasetClient.call('getDataset', {
params: { datasetId, version },
headers: createAuthorizationHeader(accessToken),
})) as any;
const datasetRecordsResponse = (await datasetClient.call('getDatasetRecords', {
params: { datasetId, version },
headers: createAuthorizationHeader(accessToken),
})) as any;
const datasetCitedByResponse = (await datasetClient.call('getDatasetCitedBy', {
params: { datasetId, version },
headers: createAuthorizationHeader(accessToken),
})) as any;
const getDatasetByVersion = (datasetVersions: Dataset[], version: string) => {
Expand Down
3 changes: 0 additions & 3 deletions website/src/services/datasetCitationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const getDatasetCitedByEndpoint = makeEndpoint({
method: 'get',
path: '/get-dataset-cited-by-publication?datasetId=:datasetId&version=:version',
alias: 'getDatasetCitedBy',
parameters: [authorizationHeader],
response: citedByResult,
errors: [notAuthorizedError],
});
Expand All @@ -35,7 +34,6 @@ const getDatasetEndpoint = makeEndpoint({
method: 'get',
path: '/get-dataset?datasetId=:datasetId&version=:version',
alias: 'getDataset',
parameters: [authorizationHeader],
response: datasets,
errors: [notAuthorizedError],
});
Expand All @@ -44,7 +42,6 @@ const getDatasetRecordsEndpoint = makeEndpoint({
method: 'get',
path: '/get-dataset-records?datasetId=:datasetId&version=:version',
alias: 'getDatasetRecords',
parameters: [authorizationHeader],
response: datasetRecords,
errors: [notAuthorizedError],
});
Expand Down
2 changes: 1 addition & 1 deletion website/src/utils/shouldMiddlewareEnforceLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getEnforcedLoginRoutes(configuredOrganisms: string[]) {

enforcedLoginRoutesCache[cacheKey] = [
new RegExp('^/user/?'),
new RegExp(`^/datasets/?`),
new RegExp(`^/datasets\/?$`),
...organismSpecificRoutes,
];
}
Expand Down

0 comments on commit fcdf8aa

Please sign in to comment.