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

Redirect to login page instead of error dialog on session expiration. #1440

Merged
merged 3 commits into from
Dec 6, 2023
Merged
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
14 changes: 7 additions & 7 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2405,8 +2405,8 @@ Now everything should be ready to start using Fairspace:

Requires:

* Helm >= 3.5.x
* kubectl >= 1.17.x
* Helm >= 3.13.x
* kubectl >= 1.27.x

You can deploy Fairspace on a Kubernetes cluster using link:https://helm.sh/[Helm].
Helm charts for Fairspace are published to the public helm repository at
Expand All @@ -2423,15 +2423,15 @@ We provide a number of charts for various components that can be used in combina

===== Download and install helm and gcloud

* Download ``helm 3.6.0`` from https://github.com/helm/helm/releases/tag/v3.6.0
* Download ``helm 3.13.1`` from https://github.com/helm/helm/releases/tag/v3.13.1
* Extract the downloaded archive to ``~/bin/helm`` and check with:
+
[source, shell]
----
~/bin/helm/helm version
----

* Install link:https://kubernetes.io/docs/tasks/tools/install-kubectl/[kubectl] (for Helm 3.6.x install version > 1.18.x).
* Install link:https://kubernetes.io/docs/tasks/tools/install-kubectl/[kubectl] (for Helm 3.13.x install version > 1.27.x).
* Download and install the link:https://cloud.google.com/sdk/docs/install[Google Cloud SDK] (requires Python).
* Obtain credentials for Kubernetes:
+
Expand Down Expand Up @@ -2473,7 +2473,7 @@ kubectl get ns
# Add the fairspace repo for reading
~/bin/helm/helm repo add fairspace https://storage.googleapis.com/fairspace-helm
# (Optional) Add the fairspace repo via the GCS plugin for writing
~/bin/helm/helm plugin install https://github.com/hayorov/helm-gcs.git --version 0.3.11
~/bin/helm/helm plugin install https://github.com/hayorov/helm-gcs.git --version 0.4.2
gcloud iam service-accounts keys create credentials.json --iam-account [email protected]
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
~/bin/helm/helm repo add fairspace-gcs gs://fairspace-helm
Expand All @@ -2496,7 +2496,7 @@ Create DNS records for the ``keycloak.example.com``, ``fairspace.example.com`` a
# List available fairspace-keycloak chart versions
~/bin/helm/helm search repo --versions fairspace/fairspace-keycloak
# Fetch the fairspace-keycloak chart
~/bin/helm/helm pull fairspace/fairspace-keycloak --version 0.6.4
~/bin/helm/helm pull fairspace/fairspace-keycloak --version 0.7.0
# List available fairspace chart versions
~/bin/helm/helm search repo --versions fairspace/fairspace
# Fetch the fairspace chart
Expand All @@ -2513,7 +2513,7 @@ Create a new deployment (called _release_ in helm terminology) and
install the Fairspace Keycloak chart:
[source, shell]
----
~/bin/helm/helm install keycloak-new fairspace/fairspace-keycloak --version 0.6.4 --namespace keycloak-new \
~/bin/helm/helm install keycloak-new fairspace/fairspace-keycloak --version 0.7.0 --namespace keycloak-new \
-f /path/to/fairspace-keycloak-values.yaml
----
You can pass values files with ``-f``.
Expand Down
11 changes: 7 additions & 4 deletions projects/mercury/src/common/utils/__tests__/httpUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import ErrorDialog from "../../components/ErrorDialog";
describe('Http Utils', () => {
describe('handleHttpError', () => {
it('Should show an error on 401', () => {
Object.defineProperty(window.location, 'assign', jest.fn());
ErrorDialog.showError = jest.fn();
handleHttpError("Default error")({response: {status: 401}});
expect(ErrorDialog.showError).toHaveBeenCalledWith("Your session has expired. Please log in again.", null, expect.anything());
delete window.location;
window.location = {assign: jest.fn()};
handleHttpError("")({response: {status: 401}});
expect(window.location.assign).toHaveBeenCalledTimes(1);
expect(window.location.assign).toHaveBeenCalledWith(
"/login?redirectUrl=undefined",
);
});

it('Should show an error on 403', () => {
Expand Down
4 changes: 1 addition & 3 deletions projects/mercury/src/common/utils/httpUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export const handleAuthError = (status) => {
switch (status) {
case 401:
sessionStorage.clear();
ErrorDialog.showError('Your session has expired. Please log in again.',
null,
() => window.location.assign(`/login?redirectUrl=${encodeURI(window.location.href)}`));
window.location.assign(`/login?redirectUrl=${encodeURI(window.location.href)}`);
break;
case 403:
ErrorDialog.showError('You have no access to this resource. Ask your administrator to grant you access.',
Expand Down
2 changes: 1 addition & 1 deletion projects/mercury/src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = (app) => {
keycloak.redirectToLogin = (request) => !(request.baseUrl.startsWith('/api/'));

app.use(keycloak.middleware({logout: '/logout'}));
app.use('/dev', keycloak.protect());
app.use('/', keycloak.protect());

const addToken = (proxyReq, req) => req.kauth.grant && proxyReq.setHeader('Authorization', `Bearer ${req.kauth.grant.access_token.token}`);

Expand Down
Loading