Skip to content

Commit 57da03c

Browse files
author
Eric Herbrandson
committed
Fixing regression with invalid jwt being passed to the 'watch' apis
1 parent a512596 commit 57da03c

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

client/src/services/apiProxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function request(path, params, autoLogoutOnAuthError = true) {
1212
const opts = Object.assign({headers: {}}, params);
1313

1414
const token = getToken();
15-
if (token) opts.headers.Authorization = token;
15+
if (token) opts.headers.Authorization = `Bearer ${token}`;
1616

1717
const url = combinePath(BASE_HTTP_URL, path);
1818
const response = await fetch(url, opts);

client/src/services/auth.js

-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ if (authorizationCookie) {
1111
}
1212

1313
export function getToken() {
14-
// This line deals with backwards compatability from when we used to only store the actual jwt
15-
if (localStorage.authToken && !localStorage.authToken.startsWith('Bearer ')) {
16-
localStorage.authToken = `Bearer ${localStorage.authToken}`;
17-
}
18-
1914
return localStorage.authToken;
2015
}
2116

client/src/views/auth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function oidcLogin(code, returnedState) {
9797

9898
async function login(token, redirectUri) {
9999
try {
100-
setToken(`Bearer ${token}`);
100+
setToken(token);
101101
await api.testAuth();
102102

103103
if (redirectUri) {

server/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function preAuth(req, res, next) {
5858

5959
// If the request already contains an authorization header, pass it through to the client (as a cookie)
6060
if (auth) {
61-
res.cookie('Authorization', auth, {maxAge: 60, httpOnly: false});
61+
const value = auth.replace('Bearer ', '');
62+
res.cookie('Authorization', value, {maxAge: 60, httpOnly: false});
6263
console.log('Authorization header found. Passing through to client.');
6364
}
6465

0 commit comments

Comments
 (0)