Skip to content

Commit 1612df2

Browse files
authored
auth through oathkeeper (#6)
1 parent 8e5731f commit 1612df2

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "whiteboard-collaboration-service",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "Alkemio Whiteboard Collaboration Service for Excalidraw backend",
55
"author": "Alkemio Foundation",
66
"private": false,

src/excalidraw-backend/server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ export class Server {
410410

411411
private getUserInfo(socket: SocketIoSocket): Promise<UserInfo | undefined> {
412412
return this.utilService.getUserInfo({
413+
authorization: socket.handshake.headers.authorization,
413414
cookie: socket.handshake.headers.cookie,
414415
});
415416
}

src/services/util/util.service.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@ export class UtilService {
1616

1717
public async getUserInfo(opts: {
1818
cookie?: string;
19-
authorizationHeader?: string;
19+
authorization?: string;
2020
}): Promise<UserInfo | never> {
21-
const { cookie, authorizationHeader } = opts;
21+
const { cookie, authorization } = opts;
2222

23-
if (cookie) {
24-
return this.integrationService.who(new WhoInputData(cookie));
23+
if (authorization) {
24+
return this.integrationService.who(new WhoInputData({ authorization }));
2525
}
2626

27-
if (authorizationHeader) {
28-
const [, token] = authorizationHeader.split(' ');
29-
return this.integrationService.who(new WhoInputData(token));
27+
if (cookie) {
28+
return this.integrationService.who(new WhoInputData({ cookie }));
3029
}
3130

3231
throw new Error('No cookie or authorization header provided');

src/services/whiteboard-integration/inputs/who.input.data.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { BaseInputData } from './base.input.data';
22

33
export class WhoInputData extends BaseInputData {
44
constructor(
5-
public cookie?: string,
6-
public token?: string,
5+
public auth: {
6+
cookie?: string;
7+
authorization?: string;
8+
},
79
) {
8-
super('who');
10+
super('who-input');
911
}
1012
}

src/services/whiteboard-integration/whiteboard.integration.adapter.service.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class WhiteboardIntegrationAdapterService {
129129
timeInterval(),
130130
map((x) => {
131131
this.logger.debug?.({
132-
method: `sendWithResponse response took ${x.interval}`,
132+
method: `sendWithResponse response took ${x.interval}ms`,
133133
pattern,
134134
data,
135135
value: x.value,
@@ -141,13 +141,13 @@ export class WhiteboardIntegrationAdapterService {
141141

142142
return firstValueFrom(result$).catch((err) => {
143143
this.logger.error(
144-
err?.message ?? err,
145-
err?.stack,
146-
JSON.stringify({
144+
{
145+
message: `Error was received while waiting for response: ${err?.message ?? err}`,
147146
pattern,
148147
data,
149148
timeout: this.timeoutMs,
150-
}),
149+
},
150+
err?.stack,
151151
);
152152

153153
throw new Error('Error while processing integration request.');

0 commit comments

Comments
 (0)