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

Properly handle + and / replacements in state value generation #29

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { randomBytes } from 'crypto';

function bytesToBase64url(s: Buffer): string {
return s.toString('base64').replace('+', '-').replace('/', '_');
return s.toString('base64').replace(/\+/g, 'Z').replace(/\//g, 'Z');
driverjb marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm mildly concerned with the loss of randomness that this introduces; I remember our security team being very diligent about us using as random a string as possible. As we discussed, despite the name, there is no real reason the output needs to actually be valid Base64, so it's probably best if we go back to the old replacement characters. At the very least, the two replacement characters should be different.

}

export const generateRandomString = (length: number): string => {
Expand Down
Loading