Skip to content

WEB-267 Remove tenant identifier for OAuth token requests #2580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/app/core/authentication/authentication.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export class AuthenticationInterceptor implements HttpInterceptor {
if (this.settingsService.tenantIdentifier) {
httpOptions.headers['Fineract-Platform-TenantId'] = this.settingsService.tenantIdentifier;
}
if (
environment.oauth.enabled &&
(request.url.includes(`${environment.oauth.serverUrl}/token`) ||
request.url.includes(`${environment.oauth.serverUrl}/logout`))
) {
Copy link
Contributor

@IOhacker IOhacker Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes on this file are not required. Please remove from the PR

// If the request is for OAuth token, we do not set the tenant identifier.
delete httpOptions.headers[authorizationTenantHeader];
}
request = request.clone({ setHeaders: httpOptions.headers });
return next.handle(request);
}
Expand Down
18 changes: 6 additions & 12 deletions src/app/core/authentication/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,12 @@ export class AuthenticationService {
httpParams = httpParams.set('grant_type', 'password');
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/x-www-form-urlencoded');
return this.http
.disableApiPrefix()
.post(`${environment.oauth.serverUrl}/token`, httpParams.toString(), { headers: headers })
.pipe(
map((tokenResponse: OAuth2Token) => {
this.getUserDetails(tokenResponse);
return of(true);
})
);
return this.http.post(`${environment.oauth.serverUrl}/token`, httpParams.toString(), { headers: headers }).pipe(
map((tokenResponse: OAuth2Token) => {
this.getUserDetails(tokenResponse);
return of(true);
})
);
} else {
return this.http
.post('/authentication', { username: loginContext.username, password: loginContext.password })
Expand All @@ -137,7 +134,6 @@ export class AuthenticationService {
let headers = new HttpHeaders();
headers = headers.set('Authorization', 'bearer ' + tokenResponse.access_token);
this.http
.disableApiPrefix()
.get(`${environment.serverUrl}/userdetails`, { headers: headers })
.subscribe((credentials: Credentials) => {
this.onLoginSuccess(credentials);
Expand Down Expand Up @@ -174,7 +170,6 @@ export class AuthenticationService {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/x-www-form-urlencoded');
return this.http
.disableApiPrefix()
.post(`${environment.oauth.serverUrl}/token`, httpParams.toString(), { headers: headers })
.subscribe((tokenResponse: OAuth2Token) => {
this.storage.setItem(this.oAuthTokenDetailsStorageKey, JSON.stringify(tokenResponse));
Expand Down Expand Up @@ -241,7 +236,6 @@ export class AuthenticationService {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/x-www-form-urlencoded');
return this.http
.disableApiPrefix()
.post(`${environment.oauth.serverUrl}/logout`, httpParams.toString(), { headers: headers })
.subscribe();
}
Expand Down