Skip to content

Commit 988cb22

Browse files
authored
changes to add auth clientname as config for sdlc (#4739)
1 parent f9c68c1 commit 988cb22

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

.changeset/wacky-aliens-sin.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@finos/legend-application-studio': patch
3+
'@finos/legend-server-sdlc': patch
4+
---
5+
6+
Adding config to bring optional client_name query param for sdlc auth call

packages/legend-application-studio/src/application/LegendStudioApplicationConfig.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class LegendStudioApplicationCoreOptions {
182182

183183
export interface LegendStudioApplicationConfigurationData
184184
extends LegendApplicationConfigurationData {
185-
sdlc: { url: string; baseHeaders?: RequestHeaders };
185+
sdlc: { url: string; baseHeaders?: RequestHeaders; client?: string };
186186
depot: { url: string };
187187
engine: {
188188
url: string;
@@ -201,6 +201,7 @@ export class LegendStudioApplicationConfig extends LegendApplicationConfig {
201201
readonly depotServerUrl: string;
202202
readonly sdlcServerUrl: string;
203203
readonly sdlcServerBaseHeaders?: RequestHeaders | undefined;
204+
readonly sdlcServerClient?: string | undefined;
204205
readonly queryApplicationUrl?: string | undefined;
205206
readonly showcaseServerUrl?: string | undefined;
206207
readonly pctReportUrl?: string | undefined;
@@ -251,6 +252,7 @@ export class LegendStudioApplicationConfig extends LegendApplicationConfig {
251252
),
252253
);
253254
this.sdlcServerBaseHeaders = input.configData.sdlc.baseHeaders;
255+
this.sdlcServerClient = input.configData.sdlc.client;
254256

255257
// query
256258
if (input.configData.query?.url) {

packages/legend-application-studio/src/stores/LegendStudioBaseStore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class LegendStudioBaseStore {
9292
env: this.applicationStore.config.env,
9393
serverUrl: this.applicationStore.config.sdlcServerUrl,
9494
baseHeaders: this.applicationStore.config.sdlcServerBaseHeaders,
95+
client: this.applicationStore.config.sdlcServerClient,
9596
});
9697
this.sdlcServerClient.setTracerService(this.applicationStore.tracerService);
9798
}
@@ -214,6 +215,7 @@ export class LegendStudioBaseStore {
214215
SDLCServerClient.authorizeCallbackUrl(
215216
this.applicationStore.config.sdlcServerUrl,
216217
this.applicationStore.navigationService.navigator.getCurrentAddress(),
218+
this.applicationStore.config.sdlcServerClient,
217219
),
218220
);
219221
} else {

packages/legend-server-sdlc/src/SDLCServerClient.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export interface SDLCServerClientConfig {
104104
env: string;
105105
serverUrl: string;
106106
baseHeaders?: RequestHeaders | undefined;
107+
client?: string | undefined;
107108
}
108109

109110
export class SDLCServerClient extends AbstractServerClient {
@@ -112,19 +113,25 @@ export class SDLCServerClient extends AbstractServerClient {
112113
private _platformDependencyConfiguration?: Platform[] | undefined;
113114

114115
private env: string;
116+
private client?: string | undefined;
115117

116118
constructor(config: SDLCServerClientConfig) {
117119
super({
118120
baseUrl: config.serverUrl,
119121
baseHeaders: config.baseHeaders,
120122
});
121123
this.env = config.env;
124+
this.client = config.client;
122125
}
123126

124127
setCurrentUser = (value: User): void => {
125128
this.currentUser = value;
126129
};
127130

131+
get clientName(): string | undefined {
132+
return this.client;
133+
}
134+
128135
/**
129136
* NOTE: Should only be used for test
130137
*/
@@ -179,8 +186,13 @@ export class SDLCServerClient extends AbstractServerClient {
179186
static authorizeCallbackUrl = (
180187
authenticationServerUrl: string,
181188
callbackURI: string,
182-
): string =>
183-
`${authenticationServerUrl}/auth/authorize?redirect_uri=${callbackURI}`;
189+
client?: string,
190+
): string => {
191+
const clientParam = client
192+
? `&client_name=${encodeURIComponent(client)}`
193+
: '';
194+
return `${authenticationServerUrl}/auth/authorize?redirect_uri=${callbackURI}${clientParam}`;
195+
};
184196

185197
private _auth = (): string => `${this.baseUrl}/auth`;
186198
isAuthorized = (): Promise<boolean> => this.get(`${this._auth()}/authorized`);

0 commit comments

Comments
 (0)