Don't put a JWT in core.user.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4348 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
6ef466f3ed
commit
eb203c7e62
@ -61,8 +61,7 @@ function socket(request, response, client) {
|
|||||||
let process;
|
let process;
|
||||||
let options = {};
|
let options = {};
|
||||||
let credentials = auth.query(request.headers);
|
let credentials = auth.query(request.headers);
|
||||||
let refresh_token = credentials?.refresh?.token;
|
let refresh = auth.make_refresh(credentials);
|
||||||
let refresh_interval = credentials?.refresh?.interval;
|
|
||||||
|
|
||||||
response.onClose = async function() {
|
response.onClose = async function() {
|
||||||
if (process && process.task) {
|
if (process && process.task) {
|
||||||
@ -198,9 +197,9 @@ function socket(request, response, client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refresh_token) {
|
if (refresh) {
|
||||||
return {
|
return {
|
||||||
'Set-Cookie': `session=${refresh_token}; path=/; Max-Age=${refresh_interval}; Secure; SameSite=Strict`,
|
'Set-Cookie': `session=${refresh.token}; path=/; Max-Age=${refresh.interval}; Secure; SameSite=Strict`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
core/auth.js
15
core/auth.js
@ -260,12 +260,17 @@ function query(headers) {
|
|||||||
return {
|
return {
|
||||||
session: entry,
|
session: entry,
|
||||||
permissions: autologin ? getPermissionsForUser(autologin) : getPermissions(session),
|
permissions: autologin ? getPermissionsForUser(autologin) : getPermissions(session),
|
||||||
refresh: {
|
|
||||||
token: makeJwt({name: entry.name}),
|
|
||||||
interval: kRefreshInterval,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { handler, query };
|
function make_refresh(credentials) {
|
||||||
|
if (credentials?.session?.name) {
|
||||||
|
return {
|
||||||
|
token: makeJwt({name: credentials.session.name}),
|
||||||
|
interval: kRefreshInterval,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { handler, query, make_refresh };
|
||||||
|
Loading…
Reference in New Issue
Block a user