Skip to content
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

fix: obtain token from authorization header #132

Merged
merged 2 commits into from
Apr 9, 2023
Merged
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
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