mirror of
https://github.com/outline/outline.git
synced 2026-11-28 16:19:46 +03:00
fix: jwt.verify handles expiration
This commit is contained in:
1 parent
dc5c90b69a
commit
8c30c3fb10
2 files changed
+4
-11
No files matched your search
@@ -85,12 +85,12 @@ export default class LocalStorage extends BaseStorage {
|
||||
const sig = JWT.sign(
|
||||
{
|
||||
key,
|
||||
expiresAt: expiresIn
|
||||
? new Date(Date.now() + expiresIn * 1000)
|
||||
: undefined,
|
||||
type: "attachment",
|
||||
},
|
||||
env.SECRET_KEY
|
||||
env.SECRET_KEY,
|
||||
{
|
||||
expiresIn,
|
||||
}
|
||||
);
|
||||
return Promise.resolve(`/api/files.get?sig=${sig}`);
|
||||
};
|
||||
|
||||
@@ -105,13 +105,6 @@ export async function getAttachmentForJWT(token: string): Promise<Attachment> {
|
||||
throw AuthenticationError("Invalid token");
|
||||
}
|
||||
|
||||
// check the token is within it's expiration time
|
||||
if (payload.expiresAt) {
|
||||
if (new Date(payload.expiresAt) < new Date()) {
|
||||
throw AuthenticationError("Expired token");
|
||||
}
|
||||
}
|
||||
|
||||
const attachmentId = payload.key.split("/")[2];
|
||||
const attachment = await Attachment.findByPk(attachmentId, {
|
||||
rejectOnEmpty: true,
|
||||
|
||||
Reference in new issue
Block a user