Skip to content

Commit

Permalink
Mint v2 tokens for regular users now that all callers can accept them
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeiser committed Jan 3, 2025
1 parent b85d66d commit 67caf41
Showing 1 changed file with 1 addition and 14 deletions.
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

0 comments on commit 67caf41

Please sign in to comment.