Skip to content

Commit

Permalink
Merge pull request #5206 from systeminit/jkeiser/eng-2888-remember-to…
Browse files Browse the repository at this point in the history
…-make-auth-api-mint-v2-tokens-for-users-too

Mint v2 tokens for regular users now that all callers can accept them
  • Loading branch information
jkeiser authored Jan 6, 2025
2 parents 301be99 + 67caf41 commit 27dfd67
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 27dfd67

Please sign in to comment.