Skip to content

Commit

Permalink
Merge pull request #26 from catenax-ng/main
Browse files Browse the repository at this point in the history
Sync from catena-x
  • Loading branch information
mkanal authored Feb 15, 2023
2 parents 798ff4e + 3142c0a commit adb2bc0
Show file tree
Hide file tree
Showing 37 changed files with 56 additions and 173 deletions.
49 changes: 0 additions & 49 deletions .github/workflows/veracode.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
appname: "Traceability-Foss-Frontend"
createprofile: false
filepath: "./veracode-scan-target.zip"
vid: "${{ secrets.ORG_VERACODE_API_ID }}"
vkey: "${{ secrets.ORG_VERACODE_API_KEY }}"
vid: '${{ secrets.VERACODE_API_ID || secrets.ORG_VERACODE_API_ID }}'
vkey: '${{ secrets.VERACODE_API_KEY || secrets.ORG_VERACODE_API_KEY }}'
12 changes: 2 additions & 10 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Support environment variables are:
const ENV_VARS_MAPPING = {
CATENAX_PORTAL_KEYCLOAK_URL: 'keycloakUrl',
CATENAX_PORTAL_CLIENT_ID: 'clientId',
CATENAX_PORTAL_DEFAULT_REALM: 'defaultRealm',
CATENAX_PORTAL_REALM_LOGO: 'realmLogo',
CATENAX_PORTAL_API_URL: 'apiUrl',
CATENAX_PORTAL_BASE_URL: 'baseUrl',
};
Expand All @@ -19,12 +17,6 @@ This variable is used to set up and use keycloak
`CATENAX_PORTAL_CLIENT_ID`
This variable is used to identify the client on keycloak

`CATENAX_PORTAL_DEFAULT_REALM`
This variable is used the set de default realm of the application

`CATENAX_PORTAL_REALM_LOGO`
This variable is used to replace the logo on the application

`CATENAX_PORTAL_API_URL`
This variable points to the desired api

Expand Down Expand Up @@ -110,7 +102,7 @@ When running the build docker image you are able to pass through multiple enviro
### Example command:
```shell
$ docker run -d -p 4200:8080 -e CATENAX_PORTAL_DEFAULT_REALM=TEST ${dockerImage}
$ docker run -d -p 4200:8080 -e ENV_VAR=VAR_VALUE ${dockerImage}
```

#### `Docker run`
Expand All @@ -125,7 +117,7 @@ To start a container in detached mode, you use `-d=true` or just `-d` option. By

To expose a container’s internal port, an operator can start the container with the `-P` or `-p` flag. The exposed port is accessible on the host and the ports are available to any client that can reach the host.

#### `-e CATENAX_PORTAL_DEFAULT_REALM=TEST`
#### `-e ENV_VAR=VAR_VALUE`

The operator can set any environment variable in the container by using one or more `-e` flags, even overriding already defined flags by the developer with a Dockerfile `ENV`.

Expand Down
11 changes: 11 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@
}
]
},
"localBackendNoAuth": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.localBackendNoAuth.ts"
}
]
},
"production": {
"fileReplacements": [
{
Expand Down Expand Up @@ -154,6 +162,9 @@
"localBackend": {
"browserTarget": "trace-x:build:dev,localBackend"
},
"localBackendNoAuth": {
"browserTarget": "trace-x:build:dev,localBackendNoAuth"
},
"production": {
"browserTarget": "trace-x:build:production"
},
Expand Down
2 changes: 0 additions & 2 deletions charts/traceability-foss-frontend/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ spec:
value: "{{ .Values.image.CATENAX_PORTAL_KEYCLOAK_URL }}"
- name: CATENAX_PORTAL_CLIENT_ID
value: "{{ .Values.image.CATENAX_PORTAL_CLIENT_ID }}"
- name: CATENAX_PORTAL_DEFAULT_REALM
value: "{{ .Values.image.CATENAX_PORTAL_DEFAULT_REALM }}"
ports:
- name: http
containerPort: {{ .Values.service.port }}
Expand Down
2 changes: 0 additions & 2 deletions charts/traceability-foss-frontend/values-dev-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ image:
tag: $ARGOCD_APP_REVISION
CATENAX_PORTAL_API_URL: 'https://traceability-test.dev.demo.catena-x.net/api'
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.dev.demo.catena-x.net/auth'
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'

nameOverride: "traceability-foss-test-frontend"
fullnameOverride: "traceability-foss-test-frontend"
Expand Down
2 changes: 0 additions & 2 deletions charts/traceability-foss-frontend/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ image:
tag: $ARGOCD_APP_REVISION
CATENAX_PORTAL_API_URL: 'https://traceability.dev.demo.catena-x.net/api'
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.dev.demo.catena-x.net/auth'
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'

ingress:
enabled: true
Expand Down
2 changes: 0 additions & 2 deletions charts/traceability-foss-frontend/values-int-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ image:
tag: $ARGOCD_APP_REVISION
CATENAX_PORTAL_API_URL: 'https://traceability-test.int.demo.catena-x.net/api'
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.int.demo.catena-x.net/auth'
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'

nameOverride: "traceability-foss-test-frontend"
fullnameOverride: "traceability-foss-test-frontend"
Expand Down
2 changes: 0 additions & 2 deletions charts/traceability-foss-frontend/values-int.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ image:
tag: $ARGOCD_APP_REVISION
CATENAX_PORTAL_API_URL: 'https://traceability.int.demo.catena-x.net/api'
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.int.demo.catena-x.net/auth'
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'

ingress:
enabled: true
Expand Down
2 changes: 0 additions & 2 deletions charts/traceability-foss-frontend/values-pen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ image:
tag: $ARGOCD_APP_REVISION
CATENAX_PORTAL_API_URL: 'https://traceability-pen.dev.demo.catena-x.net/api'
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp-pen.dev.demo.catena-x.net/auth'
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'

# important to not conflict with dev env (both use same ArgoCD instance)
namespace: product-traceability-foss-pen
Expand Down
2 changes: 0 additions & 2 deletions charts/traceability-foss-frontend/values-pre-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ image:
tag: $ARGOCD_APP_REVISION
CATENAX_PORTAL_API_URL: 'https://traceability.pre-prod.demo.catena-x.net/api'
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.pre-prod.demo.catena-x.net/auth'
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'

ingress:
enabled: true
Expand Down
38 changes: 8 additions & 30 deletions docs/authentication.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
## Authentication

The user authentication is managed by keycloak and each organization has its own realm.
The user authentication is managed by the central keycloak instance managed by catena.
You can configure your IDP there.

The app supports multi tenancy-authentication, so a realm must be specified on the URL.
[Here is a link on how to do that.](https://github.com/catenax-ng/tx-portal-assets/blob/main/docs/02.%20Technical%20Integration/02.%20Identity%20Provider%20Management/02.%20Configure%20Company%20IdP.md)

```bash
http://localhost:4200/${REALM}
http://localhost:4200/
```

In the app module, there is a function which is executed during the app bootstrap.
That function retrieves the realm provided on the URL, which is used to set up the Keycloak configurations.
That function retrieves the realm provided in the environment variables,
which is used to set up the Keycloak configurations.

### App module provider

Expand All @@ -28,36 +30,12 @@ That function retrieves the realm provided on the URL, which is used to set up t
keycloak.init({
config: {
url: environment.keycloakUrl,
realm,
clientId: 'ui',
realm: environment.defaultRealm,
clientId: environment.clientId,
},
initOptions: {
onLoad: 'login-required',
checkLoginIframe: false,
},
});
```

If multi-tenancy is disabled, the default realm is considered.
Those configurations are retrieved from the environment variables.

```typescript
export const environment = {
defaultRealm: '${REALM}',
...
};
```

> **Note:** For a deployed app those realms are already configured in the platform chart configurations:
```yaml
ui:
fullnameOverride: ui
image: ${IMAGE}
hosts:
${REALM}: ui.${COMPANY-X}.test.catenax.partchain.dev
nodeSelector:
agentpool: application
```
When a user navigates to that URL, the realm is mapped with the URL's company name.
9 changes: 0 additions & 9 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ export const environment = {
defaultRealm: 'mock',
realmLogo: '/assets/images/logo.png',
apiUrl: '/api', // specify where is placed backend API
realmRegExp: '^https?://[^/]+/([-a-z-A-Z-0-9]+)',
baseUrl: '/',
mapStyles: 'mapbox://styles/mapbox/light-v10',
};
Expand Down Expand Up @@ -288,8 +287,6 @@ Support environment variables are:
const ENV_VARS_MAPPING = {
CATENAX_PORTAL_KEYCLOAK_URL: 'keycloakUrl',
CATENAX_PORTAL_CLIENT_ID: 'clientId',
CATENAX_PORTAL_DEFAULT_REALM: 'defaultRealm',
CATENAX_PORTAL_REALM_LOGO: 'realmLogo',
CATENAX_PORTAL_API_URL: 'apiUrl',
CATENAX_PORTAL_BASE_URL: 'baseUrl',
};
Expand All @@ -301,12 +298,6 @@ This variable is used to set up and use keycloak
`CATENAX_PORTAL_CLIENT_ID`
This variable is used to identify the client on keycloak

`CATENAX_PORTAL_DEFAULT_REALM`
This variable is used the set de default realm of the application

`CATENAX_PORTAL_REALM_LOGO`
This variable is used to replace the logo on the application

`CATENAX_PORTAL_API_URL`
This variable points to the desired api

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"start:auth": "ng serve --configuration=dev,auth",
"start:auth:mock": "ng serve --configuration=authMock",
"start:auth:local": "ng serve --configuration=authLocal",
"start:auth:localBe": "ng serve --configuration=localBackend",
"start:noAuth:localBe": "ng serve --configuration=localBackendNoAuth",
"env:mock": "docker-compose up",
"test": "ng test",
"test:ci": "ng test --no-watch --no-progress --browsers=ChromeHeadless",
Expand Down
2 changes: 0 additions & 2 deletions scripts/inject-dynamic-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const fs = require('fs');
const ENV_VARS_MAPPING = {
CATENAX_PORTAL_KEYCLOAK_URL: 'keycloakUrl',
CATENAX_PORTAL_CLIENT_ID: 'clientId',
CATENAX_PORTAL_DEFAULT_REALM: 'defaultRealm',
CATENAX_PORTAL_REALM_LOGO: 'realmLogo',
CATENAX_PORTAL_API_URL: 'apiUrl',
CATENAX_PORTAL_BASE_URL: 'baseUrl',
};
Expand Down
6 changes: 0 additions & 6 deletions src/app/modules/core/core.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LayoutComponent } from '@layout/layout/layout.component';
import { PageNotFoundComponent } from '@page/page-not-found/presentation/page-not-found.component';
import { defaultRealm, realm } from './api/api.service.properties';
import { AuthGuard } from './auth/auth.guard';

export /** @type {*} */
const routes: Routes = [
{
path: '',
redirectTo: defaultRealm,
pathMatch: 'full',
},
{
path: realm || defaultRealm,
component: LayoutComponent,
canActivate: [AuthGuard],
data: { breadcrumb: 'home' },
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/core/layout/nav-bar/nav-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<div (click)="this.expand($event)">
<button class="navbar-menu-btn" data-testid="user-menu" id="user-menu" aria-haspopup="true">
<span class="sr-only">{{ 'layout.nav.openUserMenu' | i18n }}</span>
<app-avatar [imageUrl]="realmLogo"></app-avatar>
<app-avatar [imageUrl]="'/assets/images/logo.png'"></app-avatar>
</button>
</div>
<div
Expand All @@ -52,7 +52,7 @@
>
<section class="flex flex-row p-2">
<span class="navbar-menu-items__icon">
<app-avatar [imageUrl]="realmLogo"></app-avatar>
<app-avatar [imageUrl]="'/assets/images/logo.png'"></app-avatar>
</span>
<section class="flex flex-col p-1">
<p class="component-headline text-primary break-words">{{ this.userDetails.role }}</p>
Expand Down
6 changes: 2 additions & 4 deletions src/app/modules/core/layout/nav-bar/nav-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import { Component, HostListener } from '@angular/core';
import { Router } from '@angular/router';
import { realm, realmLogo as _realmLogo } from 'src/app/modules/core/api/api.service.properties';
import { LayoutFacade } from 'src/app/modules/shared/abstraction/layout-facade';

@Component({
Expand All @@ -30,13 +29,12 @@ import { LayoutFacade } from 'src/app/modules/shared/abstraction/layout-facade';
styleUrls: ['./nav-bar.component.scss'],
})
export class NavBarComponent {
public readonly realmLogo = _realmLogo;
public isExpanded = false;
public userInitials = '';
public userDetails = { name: '', email: '', role: '' };

constructor(private readonly layoutFacade: LayoutFacade, private readonly router: Router) {
this.userInitials = this.layoutFacade.realmName;
this.userInitials = this.layoutFacade.realName;
this.userDetails = this.layoutFacade.userInformation;
}

Expand All @@ -52,7 +50,7 @@ export class NavBarComponent {
}

public navigateToHome(): void {
this.router.navigate([`/${realm}`]).then();
this.router.navigate(['']).then();
}

@HostListener('window:click', [])
Expand Down
3 changes: 1 addition & 2 deletions src/app/modules/core/user/role.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
UrlTree,
} from '@angular/router';
import { Observable } from 'rxjs';
import { realm } from '../api/api.service.properties';
import { Role } from './role.model';
import { RoleService } from './role.service';

Expand Down Expand Up @@ -66,7 +65,7 @@ export class RoleGuard implements CanActivate, CanActivateChild, CanDeactivate<u
return true;
}

void this.router.navigate([realm]);
void this.router.navigate(['']);
return false;
}
}
3 changes: 1 addition & 2 deletions src/app/modules/page/about/about-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { realm } from '@core/api/api.service.properties';
import { PageRoute } from '@shared/model/page-route.model';

export const ABOUT_BASE_ROUTE = 'about';

export const getAboutRoute = (): PageRoute => ({
link: `${realm}/${ABOUT_BASE_ROUTE}`,
link: `${ABOUT_BASE_ROUTE}`,
});
Loading

0 comments on commit adb2bc0

Please sign in to comment.