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

MBL-1157: Add additional tests and checks for PKCE #1936

Merged
merged 2 commits into from
Feb 7, 2024

Conversation

amy-at-kickstarter
Copy link
Contributor

@amy-at-kickstarter amy-at-kickstarter commented Feb 7, 2024

📲 What

I'm adding some additional checks to the OAuth PKCE code, just to make it airtight.

🤔 Why

I want to keep iOS and Android as closely in-line as we can - this is a truly cross-platform feature, and it makes sense to keep our code equivalent. These changes are inspired by this PR on Android: https://github.com/kickstarter/android-oss/pull/1943/files

📓 Please note

You can ignore the first commit in this PR; I'm merging that separately in #1935. You can view just the relevant commit here: af9bc2b

@amy-at-kickstarter amy-at-kickstarter changed the title Feat/adyer/mbl 1157/pkce upgrades MBL-1157: Add additional tests and checks for PKCE Feb 7, 2024
@amy-at-kickstarter amy-at-kickstarter self-assigned this Feb 7, 2024
@amy-at-kickstarter amy-at-kickstarter marked this pull request as ready for review February 7, 2024 15:56
@@ -0,0 +1,57 @@
import CryptoKit
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy-pasted from the existing/previously reviewed code in PKCE.swift, just thought that file was getting a little long.

@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/MBL-1157/pkce-upgrades branch from af9bc2b to 5e76b0d Compare February 7, 2024 16:11
KsApi/PKCE.swift Outdated

/// PKCE stands for Proof Key for Code Exchange.
/// The code verifier, and its associated challenge, are used to ensure that an oAuth request is valid.
/// See this documentation for more details: https://www.oauth.com/oauth2-servers/mobile-and-native-apps/authorization/
public struct PKCE {
public static let minCodeVerifierLength = 43
public static let maxCodeVerifierLength = 128
public static let codeVerifierRegexPattern = "^[0-9a-zA-Z\\-._~]{43,128}$"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Instead of hardcoding 43 and 128 twice it might be nice to use \(minCodeVerifierLength) and same for the max.

@amy-at-kickstarter amy-at-kickstarter force-pushed the feat/adyer/MBL-1157/pkce-upgrades branch from 0fbc16a to 0013f77 Compare February 7, 2024 21:44
@amy-at-kickstarter amy-at-kickstarter merged commit 662f95f into main Feb 7, 2024
5 checks passed
@amy-at-kickstarter amy-at-kickstarter deleted the feat/adyer/MBL-1157/pkce-upgrades branch February 7, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants