From a1e1aa3e8ddd8614507ed87d8a9b77d06b4a1653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Agneray?= <francois.agneray@lam.fr> Date: Thu, 16 Sep 2021 13:02:40 +0200 Subject: [PATCH] Direct download for private dataset => done --- client/src/app/auth/auth.actions.ts | 4 +--- client/src/app/auth/auth.effects.ts | 19 ++----------------- client/src/app/auth/auth.reducer.ts | 11 ++--------- client/src/app/auth/auth.selector.ts | 5 ----- client/src/app/auth/init.keycloak.ts | 3 --- .../components/result/download.component.html | 8 ++++---- .../search/containers/result.component.ts | 1 - .../renderer/download-renderer.component.html | 2 +- conf-dev/public_key | 2 +- docker-compose.yml | 2 +- 10 files changed, 12 insertions(+), 45 deletions(-) diff --git a/client/src/app/auth/auth.actions.ts b/client/src/app/auth/auth.actions.ts index e661950b..429574a4 100644 --- a/client/src/app/auth/auth.actions.ts +++ b/client/src/app/auth/auth.actions.ts @@ -14,8 +14,6 @@ import { UserProfile } from './user-profile.model'; export const login = createAction('[Auth] Login'); export const logout = createAction('[Auth] Logout'); export const authSuccess = createAction('[Auth] Auth Success'); -export const authRefreshSuccess = createAction('[Auth] Auth Refresh Success'); export const loadUserProfileSuccess = createAction('[Auth] Load User Profile Success', props<{ userProfile: UserProfile }>()); -export const loadUserRoleSuccess = createAction('[Auth] Load User Roles Success', props<{ userRoles: string[] }>()); -export const loadTokenSuccess = createAction('[Auth] Load Token Success', props<{ token: string }>()); +export const loadUserRolesSuccess = createAction('[Auth] Load User Roles Success', props<{ userRoles: string[] }>()); export const openEditProfile = createAction('[Auth] Edit Profile'); diff --git a/client/src/app/auth/auth.effects.ts b/client/src/app/auth/auth.effects.ts index d063947d..bdb76a95 100644 --- a/client/src/app/auth/auth.effects.ts +++ b/client/src/app/auth/auth.effects.ts @@ -49,24 +49,9 @@ export class AuthEffects { ofType(authActions.authSuccess), switchMap(() => from(this.keycloak.loadUserProfile()) .pipe( - withLatestFrom(this.keycloak.getToken()), - switchMap(([userProfile, token]) => [ + switchMap(userProfile => [ authActions.loadUserProfileSuccess({ userProfile }), - authActions.loadUserRoleSuccess({ userRoles: this.keycloak.getUserRoles() }), - authActions.loadTokenSuccess({ token }) - ]) - ) - ) - ) - ); - - authRefreshSuccess$ = createEffect(() => - this.actions$.pipe( - ofType(authActions.authRefreshSuccess), - switchMap(() => from(this.keycloak.getToken()) - .pipe( - switchMap(token => [ - authActions.loadTokenSuccess({ token }) + authActions.loadUserRolesSuccess({ userRoles: this.keycloak.getUserRoles() }), ]) ) ) diff --git a/client/src/app/auth/auth.reducer.ts b/client/src/app/auth/auth.reducer.ts index d181f446..a516f9c9 100644 --- a/client/src/app/auth/auth.reducer.ts +++ b/client/src/app/auth/auth.reducer.ts @@ -16,14 +16,12 @@ export interface State { isAuthenticated: boolean; userProfile: UserProfile; userRoles: string[]; - token: string; } export const initialState: State = { isAuthenticated: false, userProfile: null, - userRoles: [], - token: null + userRoles: [] }; export const authReducer = createReducer( @@ -36,17 +34,12 @@ export const authReducer = createReducer( ...state, userProfile })), - on(authActions.loadUserRoleSuccess, (state, { userRoles }) => ({ + on(authActions.loadUserRolesSuccess, (state, { userRoles }) => ({ ...state, userRoles - })), - on(authActions.loadTokenSuccess, (state, { token }) => ({ - ...state, - token })) ); export const selectIsAuthenticated = (state: State) => state.isAuthenticated; export const selectUserProfile = (state: State) => state.userProfile; export const selectUserRoles = (state: State) => state.userRoles; -export const selectToken = (state: State) => state.token; diff --git a/client/src/app/auth/auth.selector.ts b/client/src/app/auth/auth.selector.ts index 3822a905..8b0e4f73 100644 --- a/client/src/app/auth/auth.selector.ts +++ b/client/src/app/auth/auth.selector.ts @@ -27,8 +27,3 @@ export const selectUserRoles = createSelector( selectAuthState, fromAuth.selectUserRoles ); - -export const selectToken = createSelector( - selectAuthState, - fromAuth.selectToken -); diff --git a/client/src/app/auth/init.keycloak.ts b/client/src/app/auth/init.keycloak.ts index d488a979..a15e68f1 100644 --- a/client/src/app/auth/init.keycloak.ts +++ b/client/src/app/auth/init.keycloak.ts @@ -24,9 +24,6 @@ export function initializeKeycloak(keycloak: KeycloakService, store: Store<{ }>, if (event.type === KeycloakEventType.OnAuthSuccess) { store.dispatch(keycloakActions.authSuccess()); } - if (event.type === KeycloakEventType.OnAuthRefreshSuccess) { - store.dispatch(keycloakActions.authRefreshSuccess()); - } if (event.type === KeycloakEventType.OnAuthRefreshError) { store.dispatch(keycloakActions.login()); } diff --git a/client/src/app/instance/search/components/result/download.component.html b/client/src/app/instance/search/components/result/download.component.html index bca9d41f..5fc5683f 100644 --- a/client/src/app/instance/search/components/result/download.component.html +++ b/client/src/app/instance/search/components/result/download.component.html @@ -18,15 +18,15 @@ <p>Download results just here:</p> </div> <div class="col"> - <a *ngIf="getConfigDownloadResultFormat('download_csv')" (click)="click($event, getUrl('csv'), 'csv')" class="btn btn-outline-primary" title="Download results in CSV format"> + <a *ngIf="getConfigDownloadResultFormat('download_csv')" [href]="getUrl('csv')" (click)="click($event, getUrl('csv'), 'csv')" class="btn btn-outline-primary" title="Download results in CSV format"> <i class="fas fa-file-csv"></i> CSV </a> - <a *ngIf="getConfigDownloadResultFormat('download_ascii')" (click)="click($event, getUrl('ascii'), 'txt')" class="btn btn-outline-primary" title="Download results in ASCII format"> + <a *ngIf="getConfigDownloadResultFormat('download_ascii')" [href]="getUrl('ascii')" (click)="click($event, getUrl('ascii'), 'txt')" class="btn btn-outline-primary" title="Download results in ASCII format"> <i class="fas fa-file"></i> ASCII </a> - <a *ngIf="getConfigDownloadResultFormat('download_vo')" (click)="click($event, getUrl('votable'), 'xml')" class="btn btn-outline-primary" title="Download results in VO format"> + <a *ngIf="getConfigDownloadResultFormat('download_vo')" [href]="getUrl('votable')" (click)="click($event, getUrl('votable'), 'xml')" class="btn btn-outline-primary" title="Download results in VO format"> <i class="fas fa-file"></i> VOtable </a> @@ -41,7 +41,7 @@ <p>Download archive files just here:</p> </div> <div class="col"> - <a (click)="click($event, getUrlArchive(), 'zip')" class="btn btn-outline-primary" title="Download an archive with all files"> + <a [href]="getUrlArchive()" (click)="click($event, getUrlArchive(), 'zip')" class="btn btn-outline-primary" title="Download an archive with all files"> <i class="fas fa-archive"></i> Files archive </a> </div> diff --git a/client/src/app/instance/search/containers/result.component.ts b/client/src/app/instance/search/containers/result.component.ts index 9254082a..f62ca538 100644 --- a/client/src/app/instance/search/containers/result.component.ts +++ b/client/src/app/instance/search/containers/result.component.ts @@ -20,7 +20,6 @@ import * as searchActions from '../../store/actions/search.actions'; import * as searchSelector from '../../store/selectors/search.selector'; import * as sampActions from '../../store/actions/samp.actions'; import * as sampSelector from '../../store/selectors/samp.selector'; -import * as authSelector from 'src/app/auth/auth.selector'; @Component({ selector: 'app-result', diff --git a/client/src/app/instance/shared-search/components/datatable/renderer/download-renderer.component.html b/client/src/app/instance/shared-search/components/datatable/renderer/download-renderer.component.html index da864835..ad2ae4dd 100644 --- a/client/src/app/instance/shared-search/components/datatable/renderer/download-renderer.component.html +++ b/client/src/app/instance/shared-search/components/datatable/renderer/download-renderer.component.html @@ -1,4 +1,4 @@ -<a (click)="click($event)" [ngClass]="{'btn btn-outline-primary btn-sm': (config.display=='text-button' || config.display=='icon-button' || config.display=='icon-text-btn')}"> +<a [href]="getHref()" (click)="click($event)" [ngClass]="{'btn btn-outline-primary btn-sm': (config.display=='text-button' || config.display=='icon-button' || config.display=='icon-text-btn')}"> <span *ngIf="config.display === 'icon-button' || config.display === 'icon-text-btn'" class="{{config.icon}}"></span> <span *ngIf="config.display === 'icon-text-btn'"> </span> <span *ngIf="config.display !== 'icon-button'">{{ getText() }}</span> diff --git a/conf-dev/public_key b/conf-dev/public_key index 3c3ba0e8..93662776 100644 --- a/conf-dev/public_key +++ b/conf-dev/public_key @@ -1,3 +1,3 @@ -----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1fucBQK34tl8Gx/fefATnpWqW5PVlwMYcJAqgWvmtwNm9ZW/S5HNZZfjW1S9BOJLfudCM83WHrAwGixgHKI310YXg+6BI9qn2Gnge1GC3JtKZx6UdcxZFAYmlhY0QGL5QxGR58DkEj6l/FDrwAHyVkC5sLqDMiYsqO7CA1uJLtF8yUrCyHvI4TR+kk5ZSM94/osg6eGxGSYA89u+qhG5tz5YCFgiRUNxuAEucsz8XiEfNVAz5kdYgsR4+LtmqECfczpwcJrAu7yDxs3rQPjBqFdGqEehALHX9vq71VEYe5Id2P7ddik3byHa0a21Q0RuVhMYwGrLiMLJCXqxE1YMuwIDAQAB +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg0yRIw1yfb6rQLWWmaZgyzXlYCRX8C8TkFH2MmU6PXTrSSwG3r1N5lAKhxFlWCZaTVhWNaYsYGG7l1DwJVrZ2U4Gc7lFADn0ltV/tGwxWJiEwfl/2eMcRZ7L8yToqqL0M8PJ3mPSVjaYlUAFFlB2SOiyQE8uszM9pUO5ZayN4YBs4i6o7ONnOp0e3p6LZ1yM9Bmff4bsuzdIBIAM2Zg0UWdJ646a+AcwZTaPIW1Z/GsufEoNxnN7Wh6wudDWxJ+lDUoZ1m3qNT2x9eUi0K62leWTNwl7ZsOx8l79UJJ+WD+CwylqmXneKUddIPtjlfrRggx3kp3uUTna/BzQUqGJXwIDAQAB -----END PUBLIC KEY----- diff --git a/docker-compose.yml b/docker-compose.yml index 482db673..ee412b76 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,7 @@ services: SSO_AUTH_URL: "http://localhost:8180/auth" SSO_REALM: "anis" SSO_CLIENT_ID: "anis-client" - TOKEN_ENABLED: 1 + TOKEN_ENABLED: 0 TOKEN_PUBLIC_KEY_FILE: /mnt/public_key TOKEN_ADMIN_ROLE: anis_admin ports: -- GitLab