Skip to content

Commit

Permalink
feat(auth-interceptor): allow to pass credentials by domain, based on…
Browse files Browse the repository at this point in the history
… regex (#589)

* feat(portal) allow to control auto anonymous authentification

* feat(portal) control if the user button is shown or not

* docs(auth) autoLoginAnonymous, loginButton and hostsWithCredentials

* wip

* wip

Co-authored-by: Pierre-Étienne Lord <[email protected]>
  • Loading branch information
pelord and Pierre-Étienne Lord authored Apr 8, 2021
1 parent 9eeef45 commit c33e3b2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
24 changes: 17 additions & 7 deletions docs/config_json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ Exemples
"auth": {
"url": "/apis/users",
"tokenKey": "id_token_igo",
"allowAnonymous": true
"allowAnonymous": true,
"hostsWithCredentials": [{
withCredentials: true,
domainRegFilters: '(https:\/\/|http:\/\/)(.*domain.com)(.*)'
}]
}
Propriétés
Expand Down Expand Up @@ -293,12 +297,18 @@ Propriétés
d'accéder aux contextes publics
- true | false
- true
* - ...
- ...
- .. line-block::
...
- ...
- ...
* - hostsWithCredentials
- {}[] (liste d'objet)
- .. line-block::
Indique à l'application, la liste des domaines a être interceptés
et à y ajouter dans l'appel.
"withCredentials": true/false selon la valeur définie.
exemple: [{
withCredentials: true,
domainRegFilters: '(https:\/\/|http:\/\/)(.*domain.com)(.*)'
}]
-
-

Important : Les propriétés en caractère gras suivies d'un * sont obligatoires.

Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<igo-spinner igoSpinnerActivity></igo-spinner>
<igo-message-center></igo-message-center>
<igo-auth-form *ngIf="authConfig"></igo-auth-form>
<igo-auth-form *ngIf="authConfig && authConfig.url"></igo-auth-form>

<app-portal igoStopDropPropagation></app-portal>
4 changes: 3 additions & 1 deletion src/app/pages/portal/portal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
[@mobileOffsetY]="getToastPanelStatus()">
</igo-geolocate-button>
<igo-rotation-button [showIfNoRotation]="showRotationButtonIfNoRotation" [map]="map" color="primary"></igo-rotation-button>
<igo-user-button [map]="map" color="primary"
<igo-user-button
*ngIf="auth.url"
[map]="map" color="primary"
[@controlsOffsetY]="getControlsOffsetY()"
[@mobileOffsetY]="getToastPanelStatus()">
</igo-user-button>
Expand Down
9 changes: 6 additions & 3 deletions src/app/pages/portal/portal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
Widget,
EntityTablePaginatorOptions
} from '@igo2/common';
import { AuthService } from '@igo2/auth';
import { AuthOptions, AuthService } from '@igo2/auth';
import { DetailedContext } from '@igo2/context';
import {
DataSourceService,
Expand Down Expand Up @@ -159,6 +159,10 @@ export class PortalComponent implements OnInit, OnDestroy {
return this.mapState.map;
}

get auth(): AuthOptions {
return this.configService.getConfig('auth') || [];
}

get toastPanelOpened(): boolean {
return this._toastPanelOpened;
}
Expand Down Expand Up @@ -1194,8 +1198,7 @@ export class PortalComponent implements OnInit, OnDestroy {
}

private initWelcomeWindow(): void {
const authConfig = this.configService.getConfig('auth');
if (authConfig) {
if (this.auth) {
this.authService.logged$.subscribe((logged) => {
if (logged) {
this.createWelcomeWindow();
Expand Down
4 changes: 2 additions & 2 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export const environment: Environment = {
url: '/apis/users',
tokenKey: 'id_token_igo',
allowAnonymous: true,
trustHosts: ['geoegl.msp.gouv.qc.ca']
trustHosts: ['geoegl.msp.gouv.qc.ca'],
},
catalog: {
sources: [
sources: [
{
id: 'Image Arcgis Rest',
title: 'Image Arcgis Rest',
Expand Down

0 comments on commit c33e3b2

Please sign in to comment.