Skip to content
Snippets Groups Projects
Commit 04f9a430 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Disable request cache in elasticsearchService with option in environment,...

Disable request cache in elasticsearchService with option in environment, remove lazy loading for geosource module, redirect to oidc login page for 401 unauthorized response
parent 43f5e0ab
No related branches found
No related tags found
No related merge requests found
...@@ -3,10 +3,10 @@ import { Routes, RouterModule, PreloadAllModules } from '@angular/router'; ...@@ -3,10 +3,10 @@ import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
import { AppRoutes } from './routes'; import { AppRoutes } from './routes';
export const routes: Routes = [ export const routes: Routes = [
{ // {
path: AppRoutes.research.uri, // path: AppRoutes.research.uri,
loadChildren: './geosource/geosource.module#GeosourceModule', // loadChildren: './geosource/geosource.module#GeosourceModule',
}, // },
]; ];
@NgModule({ @NgModule({
......
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http'; import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment.prod';
@Injectable() @Injectable()
export class AuthInterceptor implements HttpInterceptor { export class AuthInterceptor implements HttpInterceptor {
......
...@@ -6,10 +6,15 @@ import { ...@@ -6,10 +6,15 @@ import {
HttpEvent, HttpResponse, HttpErrorResponse, HttpEvent, HttpResponse, HttpErrorResponse,
} from '@angular/common/http'; } from '@angular/common/http';
import { tap } from 'rxjs/operators'; import { tap } from 'rxjs/operators';
import { environment } from '../../../environments/environment';
import { Router } from '@angular/router';
import { AppRoutes } from '../../routes';
@Injectable() @Injectable()
export class HttpErrorResponseInterceptor implements HttpInterceptor { export class HttpErrorResponseInterceptor implements HttpInterceptor {
constructor() { } constructor(
private router: Router,
) { }
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).pipe(tap( return next.handle(req).pipe(tap(
(event: HttpEvent<any>) => { (event: HttpEvent<any>) => {
...@@ -23,6 +28,8 @@ export class HttpErrorResponseInterceptor implements HttpInterceptor { ...@@ -23,6 +28,8 @@ export class HttpErrorResponseInterceptor implements HttpInterceptor {
switch (err.status) { switch (err.status) {
case 401: case 401:
console.log('HTTP ERROR: Unauthorized'); console.log('HTTP ERROR: Unauthorized');
window.location.href = environment.oidcLoginEndpoint;
// this.router.navigate(['/', AppRoutes.signin.uri])
break; break;
case 403: case 403:
console.log('HTTP ERROR: Forbidden'); console.log('HTTP ERROR: Forbidden');
...@@ -30,8 +37,6 @@ export class HttpErrorResponseInterceptor implements HttpInterceptor { ...@@ -30,8 +37,6 @@ export class HttpErrorResponseInterceptor implements HttpInterceptor {
case 404: case 404:
console.log('HTTP ERROR: Not Found'); console.log('HTTP ERROR: Not Found');
break; break;
case 301:
console.log('Redirection !!!!!!');
case 500: case 500:
case 502: case 502:
case 503: case 503:
......
...@@ -31,7 +31,7 @@ export class AuthService { ...@@ -31,7 +31,7 @@ export class AuthService {
exchangeOidcCode(code: string): Observable<boolean> { exchangeOidcCode(code: string): Observable<boolean> {
console.log('[x] Exchanging code'); console.log('[x] Exchanging code');
const url = `${env.kongUrl}/authentication/api/oidc/token?code=${code}`; const url = `${env.kongUrl}/authentication/oidc/token?code=${code}`;
return this._http.get<ILoginResponse>(url).pipe( return this._http.get<ILoginResponse>(url).pipe(
map( map(
(res) => { (res) => {
...@@ -48,7 +48,7 @@ export class AuthService { ...@@ -48,7 +48,7 @@ export class AuthService {
exchangeGlcCode(code: string): Observable<boolean> { exchangeGlcCode(code: string): Observable<boolean> {
console.log('[x] Exchanging code'); console.log('[x] Exchanging code');
const url = `${env.kongUrl}/authentication/api/glc/token?code=${code}`; const url = `${env.kongUrl}/authentication/glc/token?code=${code}`;
return this._http.get<ILoginResponse>(url).pipe( return this._http.get<ILoginResponse>(url).pipe(
map( map(
(res) => { (res) => {
...@@ -102,7 +102,7 @@ export class AuthService { ...@@ -102,7 +102,7 @@ export class AuthService {
} catch (error) { } catch (error) {
} }
let url = `${env.kongUrl}/authentication/api/logout?`; let url = `${env.kongUrl}/authentication/logout?`;
url += `id_token=${idToken}&identity_provider=${identityProvider}`; url += `id_token=${idToken}&identity_provider=${identityProvider}`;
window.location.href = url; window.location.href = url;
......
...@@ -6,7 +6,6 @@ import { EditorialisationServices } from './services'; ...@@ -6,7 +6,6 @@ import { EditorialisationServices } from './services';
import { EditorialisationResolvers } from './resolvers'; import { EditorialisationResolvers } from './resolvers';
import { SharedModule } from '../shared/shared.module'; import { SharedModule } from '../shared/shared.module';
import { GeosourceModule } from '../geosource/geosource.module'; import { GeosourceModule } from '../geosource/geosource.module';
import { DatasetResearchService } from '../geosource/services';
@NgModule({ @NgModule({
imports: [ imports: [
......
...@@ -13,7 +13,7 @@ export class ActorsService { ...@@ -13,7 +13,7 @@ export class ActorsService {
) { } ) { }
getActors() { getActors() {
return this._httpClient.get<IActor[]>(environment.backend.url + '/organizations').pipe( return this._httpClient.get<IActor[]>(environment.organizations.url).pipe(
map((actorsLoopback) => { map((actorsLoopback) => {
const actors = []; const actors = [];
actorsLoopback.forEach((actor) => { actorsLoopback.forEach((actor) => {
......
...@@ -6,7 +6,7 @@ import { AppRoutes } from '../routes'; ...@@ -6,7 +6,7 @@ import { AppRoutes } from '../routes';
export const routes: Routes = [ export const routes: Routes = [
{ {
path: '', path: AppRoutes.research.uri,
component: ResearchComponent, component: ResearchComponent,
data: { data: {
title: AppRoutes.research.title, title: AppRoutes.research.title,
......
...@@ -28,7 +28,7 @@ export class ElasticsearchService { ...@@ -28,7 +28,7 @@ export class ElasticsearchService {
getFullDataList(options: ElasticsearchOptions): Observable<IElasticsearchResponse> { getFullDataList(options: ElasticsearchOptions): Observable<IElasticsearchResponse> {
const requestOptions = this.constructElasticsearchRequest(options); const requestOptions = this.constructElasticsearchRequest(options);
const request = this._storageService.get('requestES'); const request = this._storageService.get('requestES');
if (request === JSON.stringify(requestOptions)) { if (environment.enableEsFrontCache === true && request === JSON.stringify(requestOptions)) {
const jsonESResponse = JSON.parse(this._storageService.get('resultES')) as IElasticsearchResponse; const jsonESResponse = JSON.parse(this._storageService.get('resultES')) as IElasticsearchResponse;
return of(jsonESResponse); return of(jsonESResponse);
} }
......
...@@ -5,27 +5,29 @@ import { AppRoutes } from '../app/routes'; ...@@ -5,27 +5,29 @@ import { AppRoutes } from '../app/routes';
// `ng build --env=prod` then `environment.prod.ts` will be used instead. // `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`. // The list of which env maps to which file can be found in `.angular-cli.json`.
const servicesProxyUrl = 'https://data-intothesky.alpha.grandlyon.com'; const servicesProxyUrl = 'https://data-intothesky.alpha.grandlyon.com';
const kongUrl = 'https://kong.alpha.grandlyon.com'; const kongBaseUrl = 'https://kong.alpha.grandlyon.com';
export const environment = { export const environment = {
kongUrl,
production: true, production: true,
oidcLoginEndpoint: kongUrl + '/authentication/api/oidc/login', kongUrl: kongBaseUrl,
glcLoginEndpoint: kongUrl + '/authentication/api/glc/login', oidcLoginEndpoint: kongBaseUrl + '/authentication/oidc/login',
logoutEndpoint: kongUrl + '/authentication/api/logout', glcLoginEndpoint: kongBaseUrl + '/authentication/glc/login',
logoutEndpoint: kongBaseUrl + '/authentication/logout',
// ElasticSearch // ElasticSearch
elasticsearchUrl: { elasticsearchUrl: {
full: kongUrl + '/elasticsearch/test-all-in-one-index.full.v8.quadtree', full: kongBaseUrl + '/es-consumer-aware',
meta: servicesProxyUrl + '/elasticsearch/*.meta', meta: kongBaseUrl + '/elasticsearch/*.meta',
}, },
enableEsFrontCache: false,
matomo: { matomo: {
url: 'https://matomo-intothesky.alpha.grandlyon.com', url: 'https://matomo-intothesky.alpha.grandlyon.com',
}, },
backend: { organizations: {
url: servicesProxyUrl + '/backend', url: kongBaseUrl + '/organizations',
}, },
// Path to the built app in a particular language // Path to the built app in a particular language
......
...@@ -5,27 +5,30 @@ import { AppRoutes } from '../app/routes'; ...@@ -5,27 +5,30 @@ import { AppRoutes } from '../app/routes';
// `ng build --env=prod` then `environment.prod.ts` will be used instead. // `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`. // The list of which env maps to which file can be found in `.angular-cli.json`.
const servicesProxyUrl = 'https://data-intothesky.alpha.grandlyon.com'; const servicesProxyUrl = 'https://data-intothesky.alpha.grandlyon.com';
const kongUrl = 'https://kong.alpha.grandlyon.com'; const kongBaseUrl = 'https://kong.alpha.grandlyon.com';
export const environment = { export const environment = {
kongUrl,
production: false, production: false,
oidcLoginEndpoint: '', kongUrl: kongBaseUrl,
oidcLoginEndpoint: kongBaseUrl + '/authentication/oidc/login',
glcLoginEndpoint: '', glcLoginEndpoint: '',
logoutEndpoint: '', logoutEndpoint: '',
// ElasticSearch // ElasticSearch
elasticsearchUrl: { elasticsearchUrl: {
full: servicesProxyUrl + '/elasticsearch2/test-all-in-one-index.full.v8.quadtree', // full: servicesProxyUrl + '/elasticsearch2/test-all-in-one-index.full.v8.quadtree',
full: kongBaseUrl + '/es-consumer-aware',
meta: servicesProxyUrl + '/elasticsearch/*.meta', meta: servicesProxyUrl + '/elasticsearch/*.meta',
}, },
enableEsFrontCache: true,
matomo: { matomo: {
url: 'https://matomo-intothesky.alpha.grandlyon.com', url: 'https://matomo-intothesky.alpha.grandlyon.com',
}, },
backend: { organizations: {
url: 'http://localhost:3000', url: kongBaseUrl + '/organizations',
}, },
// Path to the built app in a particular language // Path to the built app in a particular language
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment