Skip to content

Commit

Permalink
Changes to disable auth and set default tenant (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhamPramanik authored Nov 10, 2022
1 parent 2ba203c commit 4a9b3cf
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 13 deletions.
9 changes: 9 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
# and commit this file to your remote git repository to share the goodness with others.

tasks:
- init: npm install -g @angular/[email protected] && npm install --force
command: ng serve


5 changes: 4 additions & 1 deletion src/app/core/authentication/authentication.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { Router, CanActivate } from '@angular/router';
import { Logger } from '../logger/logger.service';
import { AuthenticationService } from './authentication.service';

/** Environment Configuration */
import { environment } from '../../../environments/environment';

/** Initialize logger */
const log = new Logger('AuthenticationGuard');

Expand All @@ -28,7 +31,7 @@ export class AuthenticationGuard implements CanActivate {
* @returns {boolean} True if user is authenticated.
*/
canActivate(): boolean {
if (this.authenticationService.isAuthenticated()) {
if (this.authenticationService.isAuthenticated() || !environment.auth.enabled) {
return true;
}

Expand Down
6 changes: 6 additions & 0 deletions src/app/core/authentication/authentication.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { switchMap, take, filter, catchError } from 'rxjs/operators';
import { AuthenticationService } from './authentication.service';
import { Router } from '@angular/router';

import { environment } from '../../../environments/environment';

/** Http request options headers. */
const httpOptions = {
headers: {}
Expand Down Expand Up @@ -42,6 +44,10 @@ export class AuthenticationInterceptor implements HttpInterceptor {
*/

this.retrieveAuthData();
if (!environment.auth.enabled) {
return next.handle(this.injectToken(request));
}

if (request.url.indexOf('/oauth/token') !== -1) {
return next.handle(this.injectToken(request));
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/authentication/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class AuthenticationService {
private refreshAccessToken = false;
private loggedIn = false;
private authorizationToken: String;
private tenantId: String;
private tenantId: String = environment.auth.tenant;
private username: String;
private accessTokenExpirationTime = 1;

Expand Down
8 changes: 6 additions & 2 deletions src/app/core/shell/sidenav/sidenav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ export class SidenavComponent implements OnInit {
* @param {AuthenticationService} authenticationService Authentication Service.
*/
constructor(private router: Router,
private authenticationService: AuthenticationService) { }
private authenticationService: AuthenticationService) { }

/**
* Sets the username of the authenticated user.
*/
ngOnInit() {
const credentials = this.authenticationService.getCredentials();
this.username = credentials.username;
if (credentials) {
this.username = credentials.username;
} else {
this.username = 'User';
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export class HomeComponent implements OnInit {
*/
ngOnInit() {
const credentials = this.authenticationService.getCredentials();
this.username = credentials.username;
if (credentials) {
this.username = credentials.username;
} else {
this.username = 'User';
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,11 @@ export class IncomingTransactionsComponent implements OnInit, AfterViewInit {
*/
getTransactions() {
this.dataSource = new TransactionsDataSource(this.transactionsService);
this.dataSource.getTransactions(this.filterTransactionsBy, this.sort.active, this.sort.direction, this.paginator.pageIndex, this.paginator.pageSize);
if (this.sort && this.paginator) {
this.dataSource.getTransactions(this.filterTransactionsBy, this.sort.active, this.sort.direction, this.paginator.pageIndex, this.paginator.pageSize);
} else {
this.dataSource.getTransactions(this.filterTransactionsBy, '', '', 0, 10);
}
}

openRetryResolveDialog(workflowInstanceKey: any, action: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,11 @@ export class OutgoingTransactionsComponent implements OnInit, AfterViewInit {
*/
getTransactions() {
this.dataSource = new TransactionsDataSource(this.transactionsService);
this.dataSource.getTransactions(this.filterTransactionsBy, this.sort.active, this.sort.direction, this.paginator.pageIndex, this.paginator.pageSize);
if (this.sort && this.paginator) {
this.dataSource.getTransactions(this.filterTransactionsBy, this.sort.active, this.sort.direction, this.paginator.pageIndex, this.paginator.pageSize);
} else {
this.dataSource.getTransactions(this.filterTransactionsBy, '', '', 0, 10);
}
}

openRetryResolveDialog(workflowInstanceKey: any, action: string) {
Expand Down
5 changes: 3 additions & 2 deletions src/assets/configuration.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
oauth.enabled true
oauth.enabled false
oauth.serverUrl https://ops-bk.sandbox.fynarfin.io
oauth.basicAuth true
oauth.basicAuthToken Y2xpZW50Og==
serverUrl https://ops-bk.sandbox.fynarfin.io
serverUrl https://ops-bk.sandbox.fynarfin.io
auth.tenant default
6 changes: 5 additions & 1 deletion src/environments/environment.kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ export let environment = {
},
defaultLanguage: "en-US",
supportedLanguages: ["en-US", "fr-FR"],
externalConfigurationFile: "configuration.properties" // When provided, the external configuration file content will override this environment settings based on naming conventions
externalConfigurationFile: "configuration.properties", // When provided, the external configuration file content will override this environment settings based on naming conventions
auth: {
enabled: false,
tenant: "default"
}
};
6 changes: 5 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ export let environment = {
},
defaultLanguage: "en-US",
supportedLanguages: ["en-US", "fr-FR"],
externalConfigurationFile: ""
externalConfigurationFile: "",
auth: {
enabled: true,
tenant: "default"
}
};
8 changes: 6 additions & 2 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ export let environment = {
version: env.npm_package_version + "-dev",
serverUrl: "https://paymenthub.qa.oneacrefund.org/opsapp",
oauth: {
enabled: "true", // For connecting to Mifos X using OAuth2 Authentication change the value to true
enabled: "false", // For connecting to Mifos X using OAuth2 Authentication change the value to true
serverUrl: "https://paymenthub.qa.oneacrefund.org/opsapp",
basicAuth: "true",
basicAuthToken: 'Y2xpZW50Og=='
},
defaultLanguage: "en-US",
supportedLanguages: ["en-US", "fr-FR"],
externalConfigurationFile: "configuration.properties"
externalConfigurationFile: "configuration.properties",
auth: {
enabled: false,
tenant: "default"
}
};

0 comments on commit 4a9b3cf

Please sign in to comment.