Skip to content

Commit 25e57be

Browse files
authored
feat: Added authenticatedUser and effectiveUser to serializeRefreshToken (#258)
DH-20880: serializeRefreshToken needs to include authenticatedUser and effectiveUser ### Testing - I tested this against `colin-gplus-grpc-envoy` BHS which has latest grpc changes ```json { "url": "https://colin-gplus-grpc-envoy.int.illumon.com:8000/", "experimentalWorkerConfig": { "heapSize": 0.5 } } ``` - I verified that creating a connection can create a core+ worker and run a query against it
1 parent 58ebc74 commit 25e57be

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/shared/types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export interface ExternalThemeData {
1717
export type SerializableRefreshToken = Brand<
1818
'SerializableRefreshToken',
1919
{
20+
authenticatedUser?: string;
2021
bytes: string;
22+
effectiveUser?: string;
2123
expiry: number;
2224
}
2325
>;

src/util/dataUtils.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@ describe('parseSamlScopes', () => {
2727
});
2828

2929
describe('serializeRefreshToken', () => {
30-
const mockRefreshToken: DhType.RefreshToken = {
30+
const mockRefreshToken: DhType.RefreshToken & {
31+
// TODO: Once the types changes made by DH-17975 have been published, we
32+
// should be able to update @deephaven-enterprise/jsapi-types and use
33+
// the proper RefreshToken type there and get rid of this augmentation.
34+
authenticatedUser?: string;
35+
effectiveUser?: string;
36+
} = {
37+
get authenticatedUser() {
38+
return 'mockAuthenticatedUser';
39+
},
3140
get bytes() {
3241
return 'mockBytes';
3342
},
43+
get effectiveUser() {
44+
return 'mockEffectiveUser';
45+
},
3446
get expiry() {
3547
return 1234567890;
3648
},
@@ -45,7 +57,9 @@ describe('serializeRefreshToken', () => {
4557
expect(result).toBeNull();
4658
} else {
4759
expect(result).toEqual({
60+
authenticatedUser: mockRefreshToken.authenticatedUser,
4861
bytes: mockRefreshToken.bytes,
62+
effectiveUser: mockRefreshToken.effectiveUser,
4963
expiry: mockRefreshToken.expiry,
5064
});
5165
}

src/util/dataUtils.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,25 @@ export function parseSamlScopes(scopes: readonly string[]): {
144144
* @returns The serialized refresh token.
145145
*/
146146
export function serializeRefreshToken(
147-
refreshToken?: DhcType.RefreshToken | null
147+
refreshToken?:
148+
| (DhcType.RefreshToken & {
149+
// TODO: Once the types changes made by DH-17975 have been published, we
150+
// should be able to update @deephaven-enterprise/jsapi-types and use
151+
// the proper RefreshToken type there and get rid of this augmentation.
152+
authenticatedUser?: string;
153+
effectiveUser?: string;
154+
})
155+
| null
148156
): SerializableRefreshToken | null {
149157
if (refreshToken == null) {
150158
return null;
151159
}
152160

153-
const { bytes, expiry } = refreshToken;
161+
const { authenticatedUser, bytes, effectiveUser, expiry } = refreshToken;
154162

155163
return {
164+
effectiveUser,
165+
authenticatedUser,
156166
bytes,
157167
expiry,
158168
} as SerializableRefreshToken;

0 commit comments

Comments
 (0)