mirror of
https://github.com/skooner-k8s/skooner.git
synced 2026-02-14 17:49:55 +00:00
Fixing regression with invalid jwt being passed to the 'watch' apis
This commit is contained in:
@@ -12,7 +12,7 @@ export async function request(path, params, autoLogoutOnAuthError = true) {
|
||||
const opts = Object.assign({headers: {}}, params);
|
||||
|
||||
const token = getToken();
|
||||
if (token) opts.headers.Authorization = token;
|
||||
if (token) opts.headers.Authorization = `Bearer ${token}`;
|
||||
|
||||
const url = combinePath(BASE_HTTP_URL, path);
|
||||
const response = await fetch(url, opts);
|
||||
|
||||
@@ -11,11 +11,6 @@ if (authorizationCookie) {
|
||||
}
|
||||
|
||||
export function getToken() {
|
||||
// This line deals with backwards compatability from when we used to only store the actual jwt
|
||||
if (localStorage.authToken && !localStorage.authToken.startsWith('Bearer ')) {
|
||||
localStorage.authToken = `Bearer ${localStorage.authToken}`;
|
||||
}
|
||||
|
||||
return localStorage.authToken;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ async function oidcLogin(code, returnedState) {
|
||||
|
||||
async function login(token, redirectUri) {
|
||||
try {
|
||||
setToken(`Bearer ${token}`);
|
||||
setToken(token);
|
||||
await api.testAuth();
|
||||
|
||||
if (redirectUri) {
|
||||
|
||||
@@ -58,7 +58,8 @@ function preAuth(req, res, next) {
|
||||
|
||||
// If the request already contains an authorization header, pass it through to the client (as a cookie)
|
||||
if (auth) {
|
||||
res.cookie('Authorization', auth, {maxAge: 60, httpOnly: false});
|
||||
const value = auth.replace('Bearer ', '');
|
||||
res.cookie('Authorization', value, {maxAge: 60, httpOnly: false});
|
||||
console.log('Authorization header found. Passing through to client.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user