diff --git a/Dockerfile b/Dockerfile index 4f04fd5..a9c5f78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN npm run build --prod ## STEP 2 DEPLOY ## FROM nginx:1.21.3 AS ngi -COPY --from=build /app/dist/EPAClient /usr/share/nginx/html/EPAClient +COPY --from=build /app/dist/EPAClient /usr/share/nginx/html COPY /nginx.conf /etc/nginx/conf.d/default.conf COPY /nginx.conf /etc/nginx/nginx.conf diff --git a/nginx.conf b/nginx.conf index 3fb64e9..eec2244 100644 --- a/nginx.conf +++ b/nginx.conf @@ -10,12 +10,26 @@ http { #ssl_certificate /etc/nginx/ssl/www.epa.apside.com.crt; #ssl_certificate_key /etc/nginx/ssl/www.epa.apside.com.key; - + include /etc/nginx/mime.types; location / { - root /usr/share/nginx/html/EPAClient; - try_files $uri $uri/ admin/index.html; + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html; } + + location /api { + proxy_pass http://digitepa_keycloak:8080/; + proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; + proxy_buffering off; + proxy_set_header Accept-Encoding ""; + } + + location /auth { + proxy_pass http://digitepa_back:44393/; + proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; + proxy_buffering off; + proxy_set_header Accept-Encoding ""; + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8177a79..c1efa58 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -14,8 +14,19 @@ import { AppRoutingModule } from './app-routing.module'; import { CollaborateursModule } from './collaborateurs'; -import { CommunModule } from './commun/commun-api.module'; import { CommunUiModule } from './commun/commun-ui.module'; +import { AuthModule } from './commun/auth/auth.module'; +import { CommunApiModule } from './commun/commun-api.module'; +import { CollaborateursService } from './commun/services/collaborateurs.service'; +import { DemandesDelegationService } from './commun/services/demandesDelegation.service'; +import { DemandesEPIService } from './commun/services/demandesEPI.service'; +import { DemandesFormationService } from './commun/services/demandesformation.service'; +import { EngagementsService } from './commun/services/engagements.service'; +import { EpService } from './commun/services/ep.service'; +import { FormationsService } from './commun/services/formations.service'; +import { NotesService } from './commun/services/notes.service'; +import { ParticipationsFormationsService } from './commun/services/participationsFormations.service'; +import { ReferentsEPService } from './commun/services/referentsEP.service'; @NgModule({ @@ -28,10 +39,22 @@ import { CommunUiModule } from './commun/commun-ui.module'; AppRoutingModule, HttpClientModule, CollaborateursModule, - CommunModule, - CommunUiModule + CommunApiModule, + CommunUiModule, + AuthModule.forRoot() + ], + providers: [ + CollaborateursService, + DemandesDelegationService, + DemandesEPIService, + DemandesFormationService, + EngagementsService, + EpService, + FormationsService, + NotesService, + ParticipationsFormationsService, + ReferentsEPService ], - providers: [], bootstrap: [AppComponent] }) diff --git a/src/app/commun/auth/auth-module-config.ts b/src/app/commun/auth/auth-module-config.ts index 6d85f7c..23d3f80 100644 --- a/src/app/commun/auth/auth-module-config.ts +++ b/src/app/commun/auth/auth-module-config.ts @@ -1,4 +1,5 @@ import { OAuthModuleConfig } from 'angular-oauth2-oidc'; +import { URL_API } from '../config/variables'; /** * Liste des urls pour lesquelles les appels doivent ĂȘtre interceptĂ©s. @@ -6,7 +7,7 @@ import { OAuthModuleConfig } from 'angular-oauth2-oidc'; */ export const authModuleConfig: OAuthModuleConfig = { resourceServer: { - allowedUrls: ['https://localhost:44393/api'], + allowedUrls: [URL_API], sendAccessToken: true, } }; diff --git a/src/app/commun/commun-api.module.ts b/src/app/commun/commun-api.module.ts index b8b5d97..98f4b7e 100644 --- a/src/app/commun/commun-api.module.ts +++ b/src/app/commun/commun-api.module.ts @@ -1,4 +1,5 @@ -import { NgModule } from '@angular/core'; +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; + import { CommonModule } from '@angular/common'; import { DemandesFormationService } from './services/demandesformation.service'; import { CollaborateursService } from './services/collaborateurs.service'; @@ -10,25 +11,35 @@ import { FormationsService } from './services/formations.service'; import { NotesService } from './services/notes.service'; import { ParticipationsFormationsService } from './services/participationsFormations.service'; import { ReferentsEPService } from './services/referentsEP.service'; +import { Configuration } from './config/configuration'; +import { HttpClient } from '@angular/common/http'; @NgModule({ - declarations: [], imports: [ CommonModule ], - providers: [ - CollaborateursService, - DemandesDelegationService, - DemandesEPIService, - DemandesFormationService, - EngagementsService, - EpService, - FormationsService, - NotesService, - ParticipationsFormationsService, - ReferentsEPService - ] + declarations: [] }) -export class CommunModule {} \ No newline at end of file +export class CommunApiModule { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { + return { + ngModule: CommunApiModule, + providers: [ + { provide: Configuration, useFactory: configurationFactory }, + + CollaborateursService, + DemandesDelegationService, + DemandesEPIService, + DemandesFormationService, + EngagementsService, + EpService, + FormationsService, + NotesService, + ParticipationsFormationsService, + ReferentsEPService + ] + }; + } +} diff --git a/src/app/commun/commun-ui.module.ts b/src/app/commun/commun-ui.module.ts index 28bb5ea..d343258 100644 --- a/src/app/commun/commun-ui.module.ts +++ b/src/app/commun/commun-ui.module.ts @@ -82,8 +82,7 @@ import { ProchainEpComponent } from './affichage-details-collaboarteur/prochain- // Module commun FilterModule, - RouterModule, - AuthModule.forRoot() + RouterModule ], exports: [ // Materials diff --git a/src/app/commun/config/variables.ts b/src/app/commun/config/variables.ts index 6fe5854..1f90fdc 100644 --- a/src/app/commun/config/variables.ts +++ b/src/app/commun/config/variables.ts @@ -7,3 +7,6 @@ export const COLLECTION_FORMATS = { 'ssv': ' ', 'pipes': '|' } + +export const URL_API = "https://localhost:44393/api"; +export const URL_AUTH = "http://localhost:8080"; \ No newline at end of file diff --git a/src/app/commun/services/collaborateurs.service.ts b/src/app/commun/services/collaborateurs.service.ts index 7d4a267..39d9a70 100644 --- a/src/app/commun/services/collaborateurs.service.ts +++ b/src/app/commun/services/collaborateurs.service.ts @@ -20,14 +20,14 @@ import { Observable } from 'rxjs'; import { CollaborateurDTO } from '../model/collaborateurDTO'; import { ErreurDTO } from '../model/erreurDTO'; -import { BASE_PATH, COLLECTION_FORMATS } from '../config/variables'; +import { BASE_PATH, COLLECTION_FORMATS, URL_API } from '../config/variables'; import { Configuration } from '../config/configuration'; @Injectable() export class CollaborateursService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = URL_API; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); diff --git a/src/app/commun/services/demandesDelegation.service.ts b/src/app/commun/services/demandesDelegation.service.ts index e8f5bf0..595c4a5 100644 --- a/src/app/commun/services/demandesDelegation.service.ts +++ b/src/app/commun/services/demandesDelegation.service.ts @@ -27,7 +27,7 @@ import { Configuration } from '../config/con @Injectable() export class DemandesDelegationService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = 'http://digitepa_proxy/api'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); diff --git a/src/app/commun/services/demandesEPI.service.ts b/src/app/commun/services/demandesEPI.service.ts index 8b93db4..8b1d817 100644 --- a/src/app/commun/services/demandesEPI.service.ts +++ b/src/app/commun/services/demandesEPI.service.ts @@ -28,7 +28,7 @@ import { Configuration } from '../config/con @Injectable() export class DemandesEPIService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = 'http://digitepa_proxy/api'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); diff --git a/src/app/commun/services/engagements.service.ts b/src/app/commun/services/engagements.service.ts index cac2da7..c9aadbf 100644 --- a/src/app/commun/services/engagements.service.ts +++ b/src/app/commun/services/engagements.service.ts @@ -28,7 +28,7 @@ import { Configuration } from '../config/con @Injectable() export class EngagementsService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = 'http://digitepa_proxy/api'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); diff --git a/src/app/commun/services/ep.service.ts b/src/app/commun/services/ep.service.ts index 553a592..5b8dd82 100644 --- a/src/app/commun/services/ep.service.ts +++ b/src/app/commun/services/ep.service.ts @@ -30,7 +30,7 @@ @Injectable() export class EpService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = 'http://digitepa_proxy/api'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); diff --git a/src/app/commun/services/formations.service.ts b/src/app/commun/services/formations.service.ts index 912b906..75b4455 100644 --- a/src/app/commun/services/formations.service.ts +++ b/src/app/commun/services/formations.service.ts @@ -25,18 +25,20 @@ import { OrigineFormationDTO } from '../model/origineFormationDTO'; import { StatutFormationDTO } from '../model/statutFormationDTO'; import { TypeFormationDTO } from '../model/typeFormationDTO'; -import { BASE_PATH, COLLECTION_FORMATS } from '../config/variables'; +import { BASE_PATH, COLLECTION_FORMATS, URL_API } from '../config/variables'; import { Configuration } from '../config/configuration'; @Injectable() export class FormationsService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = URL_API; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { + console.log("HERE"); + console.log("c " + configuration); if (basePath) { this.basePath = basePath; } @@ -477,10 +479,12 @@ export class FormationsService { let headers = this.defaultHeaders; // authentication (bearerAuth) required + console.log("config" + this.configuration.accessToken); if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; + console.log("token" + accessToken); headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header diff --git a/src/app/commun/services/notes.service.ts b/src/app/commun/services/notes.service.ts index fa248c0..590ddd3 100644 --- a/src/app/commun/services/notes.service.ts +++ b/src/app/commun/services/notes.service.ts @@ -28,7 +28,7 @@ import { Configuration } from '../config/con @Injectable() export class NotesService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = 'http://digitepa_proxy/api'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); diff --git a/src/app/commun/services/participationsFormations.service.ts b/src/app/commun/services/participationsFormations.service.ts index f7e59c7..d65c202 100644 --- a/src/app/commun/services/participationsFormations.service.ts +++ b/src/app/commun/services/participationsFormations.service.ts @@ -28,7 +28,7 @@ import { Configuration } from '../config/con @Injectable() export class ParticipationsFormationsService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = 'http://digitepa_proxy/api'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); diff --git a/src/app/commun/services/referentsEP.service.ts b/src/app/commun/services/referentsEP.service.ts index 5411640..58178c2 100644 --- a/src/app/commun/services/referentsEP.service.ts +++ b/src/app/commun/services/referentsEP.service.ts @@ -27,7 +27,7 @@ import { Configuration } from '../config/con @Injectable() export class ReferentsEPService { - protected basePath = 'https://localhost:44393/api'; + protected basePath = 'http://digitepa_proxy/api'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index c3f9f91..6d7d840 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,12 +1,14 @@ import { AuthConfig } from 'angular-oauth2-oidc'; +import { URL_AUTH } from 'app/commun/config/variables'; const keycloakConfig: AuthConfig = { // Url of the Identity Provider - //issuer: 'http://digitepa_keycloak:8080/auth/realms/Apside', - issuer: 'http://digitepa_proxy/auth/realms/Apside', + //issuer: 'http://localhost:8080/auth/realms/Apside', + issuer: URL_AUTH + '/auth/realms/Apside', + // URL of the SPA to redirect the user to after login - redirectUri: 'http://digitepa_proxy/', + redirectUri: 'http://localhost:4200/', // The SPA's id. The SPA is registerd with this id at the auth-server clientId: 'GestionEPA', @@ -16,7 +18,9 @@ const keycloakConfig: AuthConfig = { // and it might not enforce further best practices vital for security // such applications. //dummyClientSecret: 'b261c083-d8ba-4a7c-918e-9d13393f33bd', - dummyClientSecret: '201a3d53-7cd5-4613-bcb6-f2e98c1ba2ec', + //dummyClientSecret: '201a3d53-7cd5-4613-bcb6-f2e98c1ba2ec', + dummyClientSecret: '0073bd5c-5737-45b6-a811-df3d31bfd5fa', + // To configure your solution for code flow + PKCE you have to set the responseType to code responseType: 'code', diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 1ec1e1a..d14432e 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,13 +3,16 @@ // The list of file replacements can be found in `angular.json`. import { AuthConfig } from 'angular-oauth2-oidc'; +import { URL_AUTH } from 'app/commun/config/variables'; const keycloakConfig: AuthConfig = { // Url of the Identity Provider - issuer: 'http://localhost:8080/auth/realms/Apside', + //issuer: 'http://localhost:8080/auth/realms/Apside', + issuer: URL_AUTH + '/auth/realms/Apside', + // URL of the SPA to redirect the user to after login - redirectUri: 'http://localhost:4200', + redirectUri: 'http://localhost:4200/', // The SPA's id. The SPA is registerd with this id at the auth-server clientId: 'GestionEPA', @@ -19,7 +22,9 @@ const keycloakConfig: AuthConfig = { // and it might not enforce further best practices vital for security // such applications. //dummyClientSecret: 'b261c083-d8ba-4a7c-918e-9d13393f33bd', - dummyClientSecret: '201a3d53-7cd5-4613-bcb6-f2e98c1ba2ec', + //dummyClientSecret: '201a3d53-7cd5-4613-bcb6-f2e98c1ba2ec', + dummyClientSecret: 'fb3102cc-be74-4beb-b646-65a625998ec3', + // To configure your solution for code flow + PKCE you have to set the responseType to code responseType: 'code',