Skip to content

Commit

Permalink
fix: obtain token from authorization header (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSPRH committed Apr 9, 2023
1 parent a4f6359 commit 700bcbd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export abstract class AuthUserExtractorStrategy {

export class ExtractUserFromMsPrincipleHeader extends AuthUserExtractorStrategy {
getUserFromRequest(req: Request): AuthUser | null {
const headerValue = req.headers['authentication'];
const headerValue = req.headers['authorization'];

if (!headerValue) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('ExtractUserFromMsPrincipleHeader', () => {
extractStrat = new ExtractUserFromMsPrincipleHeader();
});

it('should return null if the authentication header is not present', () => {
it('should return null if the authorization header is not present', () => {
const req = createMock<Omit<KordisRequest, 'user'>>({
headers: {},
});
Expand All @@ -28,7 +28,7 @@ describe('ExtractUserFromMsPrincipleHeader', () => {
'Bearer eyJhbGciOiJIUzI1NiJ9.eyJvaWQiOiJjMGNjNDQwNC03OTA3LTQ0ODAtODZkMy1iYTRiZmM1MTNjNmQiLCJzdWIiOiJjMGNjNDQwNC03OTA3LTQ0ODAtODZkMy1iYTRiZmM1MTNjNmQiLCJnaXZlbl9uYW1lIjoiVGVzdCIsImZhbWlseV9uYW1lIjoiVXNlciIsImVtYWlscyI6WyJ0ZXN0QHRpbW9ubWFzYmVyZy5jb20iXX0.9FXjgT037QkeE0KptQo3MzMriuXGzqCNfBDVEkWbJaA';

const req = createMock<Omit<KordisRequest, 'user'>>({
headers: { authentication: headerValue },
headers: { authorization: headerValue },
});

expect(extractStrat.getUserFromRequest(req)).toEqual({
Expand Down

0 comments on commit 700bcbd

Please sign in to comment.