mirror of
https://github.com/docmost/docmost.git
synced 2025-11-19 02:51:12 +10:00
refactor: switch to HttpOnly cookie (#660)
* Switch to httpOnly cookie * create endpoint to retrieve temporary collaboration token * cleanups
This commit is contained in:
@ -12,6 +12,7 @@ import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
||||
import { findHighestUserSpaceRole } from '@docmost/db/repos/space/utils';
|
||||
import { SpaceRole } from '../../common/helpers/types/permission';
|
||||
import { getPageId } from '../collaboration.util';
|
||||
import { JwtCollabPayload, JwtType } from '../../core/auth/dto/jwt-payload';
|
||||
|
||||
@Injectable()
|
||||
export class AuthenticationExtension implements Extension {
|
||||
@ -28,12 +29,15 @@ export class AuthenticationExtension implements Extension {
|
||||
const { documentName, token } = data;
|
||||
const pageId = getPageId(documentName);
|
||||
|
||||
let jwtPayload = null;
|
||||
let jwtPayload: JwtCollabPayload;
|
||||
|
||||
try {
|
||||
jwtPayload = await this.tokenService.verifyJwt(token);
|
||||
} catch (error) {
|
||||
throw new UnauthorizedException('Could not verify jwt token');
|
||||
throw new UnauthorizedException('Invalid collab token');
|
||||
}
|
||||
if (jwtPayload.type !== JwtType.COLLAB) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
const userId = jwtPayload.sub;
|
||||
|
||||
Reference in New Issue
Block a user