Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/16.0.0' into config-defa…
Browse files Browse the repository at this point in the history
…ult-value3
  • Loading branch information
pelord committed Oct 10, 2023
2 parents be289c4 + 3b75824 commit 82e751d
Show file tree
Hide file tree
Showing 67 changed files with 471 additions and 254 deletions.
23 changes: 10 additions & 13 deletions demo/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
interface Environment {
production: boolean;
igo: any;
}
import { EnvironmentOptions } from '@igo2/integration';
import { CatalogQueryFormatTypes, ICatalog, TooltipType } from '@igo2/geo';

export const environment: Environment = {
export const environment: EnvironmentOptions = {
production: true,
igo: {
projections: [
Expand All @@ -15,13 +13,15 @@ export const environment: Environment = {
}
],
auth: {
tokenKey: 'testIgo2Lib',
intern: {
enabled: true
},
allowAnonymous: true
},
interactiveTour: {
tourInMobile: true
tourInMobile: true,
activateInteractiveTour: true
},
importExport: {
url: 'https://geoegl.msp.gouv.qc.ca/apis/ogre'
Expand All @@ -42,14 +42,11 @@ export const environment: Environment = {
url: 'https://ws.mapserver.transports.gouv.qc.ca/swtq',
queryFormat: {
html: '*',
'application/json': [
'stations_meteoroutieres',
'histo_stations_meteoroutieres'
]
},
json: ['stations_meteoroutieres', 'histo_stations_meteoroutieres']
} as CatalogQueryFormatTypes,
queryHtmlTarget: 'iframe',
count: 30
},
} as ICatalog,
{
id: 'catalogwithregex',
title: 'Filtered catalog by regex',
Expand All @@ -60,7 +57,7 @@ export const environment: Environment = {
id: 'catalogwithtooltipcontrol',
title: 'Controling tooltip format',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
tooltipType: 'abstract' // or title
tooltipType: TooltipType.ABSTRACT
}
]
},
Expand Down
35 changes: 12 additions & 23 deletions demo/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build ---configuration production` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
import { EnvironmentOptions } from '@igo2/integration';
import { TooltipType, CatalogQueryFormatTypes, ICatalog } from '@igo2/geo';

// import { IgoEnvironment } from '@igo2/core';

interface Environment {
production: boolean;
igo: any;
}

export const environment: Environment = {
export const environment: EnvironmentOptions = {
production: false,
igo: {
importWithStyle: true,
Expand Down Expand Up @@ -54,14 +46,11 @@ export const environment: Environment = {
url: 'https://ws.mapserver.transports.gouv.qc.ca/swtq',
queryFormat: {
html: '*',
'application/json': [
'stations_meteoroutieres',
'histo_stations_meteoroutieres'
]
},
json: ['stations_meteoroutieres', 'histo_stations_meteoroutieres']
} as CatalogQueryFormatTypes,
queryHtmlTarget: 'iframe',
count: 30
},
} as ICatalog,
{
id: 'catalogwithregex',
title: 'Filtered catalog by regex',
Expand All @@ -72,7 +61,7 @@ export const environment: Environment = {
id: 'catalogwithtooltipcontrol',
title: 'Controling tooltip format',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
tooltipType: 'abstract' // or title
tooltipType: TooltipType.ABSTRACT
},
{
id: 'arcgisrestcompletecatalog',
Expand Down Expand Up @@ -148,7 +137,7 @@ export const environment: Environment = {
id: 'wmts_error',
url: 'https://servicesmatriciels.mern.gouv.qc.ca/erdas-iws/ogc/wmts/Elevation?SERVICE=WMTS&REQUEST=GetCapabilities',
type: 'wmts',
crossOrigin: true,
setCrossOriginAnonymous: true,
matrixSet: 'EPSG_3857',
version: '1.0.0',
forcedProperties: [
Expand All @@ -166,7 +155,7 @@ export const environment: Environment = {
id: 'wms',
url: 'https://cartes.geogratis.gc.ca/wms/canvec_fr',
type: 'wms',
crossOrigin: true,
setCrossOriginAnonymous: true,
version: '1.3.0',
forcedProperties: [
{
Expand Down Expand Up @@ -223,7 +212,7 @@ export const environment: Environment = {
id: 'wms',
url: 'https://cartes.geogratis.gc.ca/wms/canvec_fr',
type: 'wms',
crossOrigin: true,
setCrossOriginAnonymous: true,
version: '1.3.0'
},
{
Expand All @@ -237,7 +226,7 @@ export const environment: Environment = {
id: 'rn_wmts_1',
url: 'https://servicesmatriciels.mern.gouv.qc.ca/erdas-iws/ogc/wmts/Cartes_Images',
type: 'wmts',
crossOrigin: true,
setCrossOriginAnonymous: true,
matrixSet: 'EPSG_3857',
version: '1.0.0',
forcedProperties: [
Expand Down Expand Up @@ -293,7 +282,7 @@ export const environment: Environment = {
title: 'Feuillets SNRC',
searchUrl: '/ws/mffpecofor.fcgi',
storedquery_id: 'sq250et20kFeuillet',
fields: { name: 'no_feuillet', defaultValue: '0' },
fields: [{ name: 'no_feuillet', defaultValue: '0' }],
resultTitle: 'feuillet',
params: {
limit: '8'
Expand Down
6 changes: 6 additions & 0 deletions packages/auth/src/lib/environment/environment.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { AuthOptions, AuthStorageOptions } from '../shared';

export interface EnvironmentOptions {
auth?: AuthOptions;
storage?: AuthStorageOptions;
}
1 change: 1 addition & 0 deletions packages/auth/src/lib/environment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './environment.interface';
5 changes: 3 additions & 2 deletions packages/auth/src/lib/shared/admin.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

import { ConfigService } from '@igo2/core';
import { AuthService } from './auth.service';
import { AuthOptions } from './auth.interface';

@Injectable({
providedIn: 'root'
Expand All @@ -26,8 +27,8 @@ export class AdminGuard {

this.authService.redirectUrl = state.url;

const authConfig = this.config.getConfig('auth');
if (authConfig && authConfig.loginRoute) {
const authConfig = this.config.getConfig('auth') as AuthOptions;
if (authConfig?.loginRoute) {
this.router.navigateByUrl(authConfig.loginRoute);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/auth/src/lib/shared/auth-microsoft.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { MsalServiceb2c } from './auth-msalServiceb2c.service.';
export function MSALConfigFactory(
config: ConfigService
): PublicClientApplication {
const msConf: BrowserAuthOptions | null = config.getConfig('auth.microsoft');
const msConf = config.getConfig('auth.microsoft') as AuthMicrosoftOptions;

msConf.redirectUri = msConf?.redirectUri || window.location.href;
msConf.authority =
Expand All @@ -39,9 +39,9 @@ export function MSALConfigFactory(
export function MSALConfigFactoryb2c(
config: ConfigService
): PublicClientApplication {
const msConf: BrowserAuthOptions | null = config.getConfig(
const msConf = config.getConfig(
'auth.microsoftb2c.browserAuthOptions'
);
) as BrowserAuthOptions;
msConf.redirectUri = msConf?.redirectUri || window.location.href;
msConf.authority =
msConf?.authority || 'https://login.microsoftonline.com/organizations';
Expand All @@ -59,7 +59,7 @@ export function MSALConfigFactoryb2c(
export function MSALAngularConfigFactory(
config: ConfigService
): MSPMsalGuardConfiguration {
const msConf: AuthMicrosoftOptions = config.getConfig('auth.microsoft');
const msConf = config.getConfig('auth.microsoft') as AuthMicrosoftOptions;

return {
interactionType: InteractionType.Popup,
Expand All @@ -74,9 +74,9 @@ export function MSALAngularConfigFactory(
export function MSALAngularConfigFactoryb2c(
config: ConfigService
): MSPMsalGuardConfiguration {
const msConf: BrowserAuthOptions | null = config.getConfig(
const msConf = config.getConfig(
'auth.microsoftb2c.browserAuthOptions'
);
) as BrowserAuthOptions;

return {
interactionType: InteractionType.Popup,
Expand Down
5 changes: 3 additions & 2 deletions packages/auth/src/lib/shared/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

import { ConfigService } from '@igo2/core';
import { AuthService } from './auth.service';
import { AuthOptions } from './auth.interface';

@Injectable({
providedIn: 'root'
Expand All @@ -25,8 +26,8 @@ export class AuthGuard {

this.authService.redirectUrl = state.url;

const authConfig = this.config.getConfig('auth');
if (authConfig && authConfig.loginRoute) {
const authConfig = this.config.getConfig('auth') as AuthOptions;
if (authConfig?.loginRoute) {
this.router.navigateByUrl(authConfig.loginRoute);
}

Expand Down
18 changes: 12 additions & 6 deletions packages/auth/src/lib/shared/auth.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import { Md5 } from 'ts-md5';

import { ConfigService } from '@igo2/core';
import { TokenService } from './token.service';
import { AuthByKeyOptions, WithCredentialsOptions } from './auth.interface';
import {
AuthByKeyOptions,
AuthOptions,
WithCredentialsOptions
} from './auth.interface';

@Injectable({
providedIn: 'root'
})
export class AuthInterceptor implements HttpInterceptor {
private authOptions: AuthOptions;
private refreshInProgress = false;
private trustHosts: string[];
private hostsWithCredentials: WithCredentialsOptions[];
Expand All @@ -27,12 +32,13 @@ export class AuthInterceptor implements HttpInterceptor {
private tokenService: TokenService,
private http: HttpClient
) {
this.trustHosts = this.config.getConfig('auth.trustHosts') || [];
this.authOptions = this.config.getConfig('auth') as AuthOptions;

this.trustHosts = this.authOptions?.trustHosts || [];
this.trustHosts.push(window.location.hostname);

this.hostsWithCredentials =
this.config.getConfig('auth.hostsWithCredentials') || [];
this.hostsWithAuthByKey = this.config.getConfig('auth.hostsByKey') || [];
this.hostsWithCredentials = this.authOptions?.hostsWithCredentials || [];
this.hostsWithAuthByKey = this.authOptions?.hostsByKey || [];
}

intercept(
Expand Down Expand Up @@ -171,7 +177,7 @@ export class AuthInterceptor implements HttpInterceptor {
) {
this.refreshInProgress = true;

const url = this.config.getConfig('auth.url');
const url = this.authOptions?.url;
return this.http.post(`${url}/refresh`, {}).subscribe(
(data: any) => {
this.tokenService.set(data.token);
Expand Down
7 changes: 2 additions & 5 deletions packages/auth/src/lib/shared/auth.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ export interface AuthGoogleOptions {
clientId: string;
}

export interface AuthMicrosoftOptions {
export interface AuthMicrosoftOptions extends BrowserAuthOptions {
enabled?: boolean;
clientId: string;
redirectUri?: string;
authority?: string;
}

export interface AuthMicrosoftb2cOptions {
Expand Down Expand Up @@ -54,7 +51,7 @@ export interface AuthMicrosoftb2cOptionsAuthority {

export interface AuthOptions {
url?: string;
tokenKey: string;
tokenKey?: string;
allowAnonymous?: boolean;
loginRoute?: string;
logoutRoute?: string;
Expand Down
Loading

0 comments on commit 82e751d

Please sign in to comment.