Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mint v2 tokens for regular users now that all callers can accept them #5206

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions bin/auth-api/src/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,7 @@ export function createSdfAuthToken(
payload: Omit<SdfAuthTokenPayloadV2, "version">,
options?: Omit<SignOptions, 'algorithm' | 'subject'>,
) {
function createPayload(): SdfAuthTokenPayload {
switch (payload.role) {
case "web":
// For web tokens, generate the old version until prod is able to handle new ones.
return { user_pk: payload.userId, workspace_pk: payload.workspaceId };
case "automation":
// Expire automation tokens quickly right now
return { version: "2", ...payload };
default:
return payload.role satisfies never;
}
}

return createJWT(createPayload(), { subject: payload.userId, ...(options ?? {}) });
return createJWT({ version: "2", ...payload }, { subject: payload.userId, ...(options ?? {}) });
}

export async function decodeSdfAuthToken(token: string) {
Expand Down
Loading