Skip to content

Commit

Permalink
Merge pull request #34 from passageidentity/PSG-3833-new-auth-methods
Browse files Browse the repository at this point in the history
Added support for WebAuthn Authenticator Attachments
  • Loading branch information
rickycpadilla authored Apr 25, 2024
2 parents 1b75561 + 07e8a62 commit 1b9dfc6
Show file tree
Hide file tree
Showing 69 changed files with 2,563 additions and 143 deletions.
14 changes: 12 additions & 2 deletions passage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,23 @@ openApiGenerate {
apiPackage = "id.passage.android.api"
modelPackage = "id.passage.android.model"
configOptions = [
useCoroutines: "true",
"apiSuffix": "API",
"enumPropertyNaming": "camelCase",
"moshiCodeGen": "true",
"packageName": "id.passage.client",
"moshiCodeGen": "true"
"useCoroutines": "true",
]
}

tasks.register('updateGeneratedCode', Exec) {
dependsOn 'openApiGenerate'
workingDir "$projectDir"
commandLine "python3", "fix_generated_code.py"
doLast {
println 'updateGeneratedCode script executed successfully.'
}
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down
46 changes: 46 additions & 0 deletions passage/fix_generated_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os

# Define a list of tuples for replacements where each tuple is ('file_path', 'old_text', 'new_text')
replacements = [

# Authenticator attachment "cross-platform" gets misleading name "crossMinusPlatform":
(
'./generated/src/main/kotlin/id/passage/android/model/AuthenticatorAttachment.kt',
'crossMinusPlatform',
'crossPlatform'
),

# appleOauth2Callback functions wrongfully assume "error" is NOT null:
(
'./generated/src/main/kotlin/id/passage/android/api/OAuth2API.kt',
'"error" to PartConfig(body = error.value, headers = mutableMapOf())',
'"error" to PartConfig(body = error?.value, headers = mutableMapOf())'
),

# User model requires `webauthn_types` property, but webauthn start returns user WITHOUT it, so we must make it optional.
(
'./generated/src/main/kotlin/id/passage/android/model/User.kt',
'val webauthnTypes: kotlin.collections.List<WebAuthnType>',
'val webauthnTypes: kotlin.collections.List<WebAuthnType>?'
),

# Add more replacements here as needed
# ('oldText', 'newText'),
]

def replace_in_file(replacement):
file_path, old_text, new_text = replacement
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()

updated_content = content
# for old_text, new_text in replacements:
updated_content = updated_content.replace(old_text, new_text)

if content != updated_content:
with open(file_path, 'w', encoding='utf-8') as file:
file.write(updated_content)
print(f"Updated {file_path}")

for replacement in replacements:
replace_in_file(replacement)
42 changes: 34 additions & 8 deletions passage/generated/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,29 @@ docs/403Code.md
docs/403Error.md
docs/404Code.md
docs/404Error.md
docs/409Code.md
docs/409Error.md
docs/500Code.md
docs/500Error.md
docs/ActivateMagicLinkRequest.md
docs/ActivateOneTimePasscodeRequest.md
docs/AddDeviceFinishRequest.md
docs/AddDeviceStartResponse.md
docs/App.md
docs/AppleSocialConnection.md
docs/AppsAPI.md
docs/AuthErrorCode.md
docs/AuthMethods.md
docs/AuthResponse.md
docs/AuthResult.md
docs/AuthenticateAPI.md
docs/AuthenticateWebAuthnFinishWithTransactionRequest.md
docs/AuthenticateWebAuthnStartWithTransactionRequest.md
docs/AuthenticateWebAuthnStartWithTransactionResponse.md
docs/AuthenticatorAttachment.md
docs/CreateUserParams.md
docs/Credential.md
docs/CredentialAssertionChallenge.md
docs/CredentialAssertionChallenge1.md
docs/CredentialAssertionResponse.md
docs/CredentialAssertionResponseResponse.md
docs/CredentialCreation.md
Expand All @@ -48,6 +55,7 @@ docs/GetAppResponse.md
docs/GetMagicLinkStatusRequest.md
docs/GithubSocialConnection.md
docs/GoogleSocialConnection.md
docs/IdTokenRequest.md
docs/JWKResponse.md
docs/JWKResponseKeysInner.md
docs/JWKSAPI.md
Expand All @@ -63,16 +71,18 @@ docs/LoginWebAuthnStartResponse.md
docs/MagicLink.md
docs/MagicLinkAPI.md
docs/MagicLinkAuthMethod.md
docs/MagicLinkLoginWebAuthnStartResponse.md
docs/MagicLinkResponse.md
docs/Nonce.md
docs/OAuth2API.md
docs/OAuth2ConnectionType.md
docs/OTPAPI.md
docs/OneTimePasscodeResponse.md
docs/OpenIDAPI.md
docs/OpenIdConfiguration.md
docs/OtpAuthMethod.md
docs/ProtocolCredentialAssertion.md
docs/ProtocolCredentialAssertion1.md
docs/ProtocolCredentialAssertion1PublicKey.md
docs/ProtocolCredentialAssertion1PublicKeyAllowCredentialsInner.md
docs/ProtocolCredentialAssertionPublicKey.md
docs/ProtocolCredentialAssertionPublicKeyAllowCredentialsInner.md
docs/RefreshAuthTokenRequest.md
Expand All @@ -81,10 +91,13 @@ docs/RegisterMagicLinkRequest.md
docs/RegisterMagicLinkResponse.md
docs/RegisterOneTimePasscodeRequest.md
docs/RegisterWebAuthnFinishRequest.md
docs/RegisterWebAuthnFinishWithTransactionRequest.md
docs/RegisterWebAuthnStartRequest.md
docs/RegisterWebAuthnStartResponse.md
docs/SocialConnection.md
docs/RegisterWebAuthnStartWithTransactionRequest.md
docs/RegisterWebAuthnStartWithTransactionResponse.md
docs/SocialConnections.md
docs/SocialConnectionsResponse.md
docs/TokensAPI.md
docs/TtlDisplayUnit.md
docs/UpdateDeviceRequest.md
Expand All @@ -106,6 +119,7 @@ gradlew
gradlew.bat
settings.gradle
src/main/kotlin/id/passage/android/api/AppsAPI.kt
src/main/kotlin/id/passage/android/api/AuthenticateAPI.kt
src/main/kotlin/id/passage/android/api/CurrentuserAPI.kt
src/main/kotlin/id/passage/android/api/JWKSAPI.kt
src/main/kotlin/id/passage/android/api/LoginAPI.kt
Expand All @@ -121,14 +135,18 @@ src/main/kotlin/id/passage/android/model/ActivateOneTimePasscodeRequest.kt
src/main/kotlin/id/passage/android/model/AddDeviceFinishRequest.kt
src/main/kotlin/id/passage/android/model/AddDeviceStartResponse.kt
src/main/kotlin/id/passage/android/model/App.kt
src/main/kotlin/id/passage/android/model/AuthErrorCode.kt
src/main/kotlin/id/passage/android/model/AppleSocialConnection.kt
src/main/kotlin/id/passage/android/model/AuthMethods.kt
src/main/kotlin/id/passage/android/model/AuthResponse.kt
src/main/kotlin/id/passage/android/model/AuthResult.kt
src/main/kotlin/id/passage/android/model/AuthenticateWebAuthnFinishWithTransactionRequest.kt
src/main/kotlin/id/passage/android/model/AuthenticateWebAuthnStartWithTransactionRequest.kt
src/main/kotlin/id/passage/android/model/AuthenticateWebAuthnStartWithTransactionResponse.kt
src/main/kotlin/id/passage/android/model/AuthenticatorAttachment.kt
src/main/kotlin/id/passage/android/model/CreateUserParams.kt
src/main/kotlin/id/passage/android/model/Credential.kt
src/main/kotlin/id/passage/android/model/CredentialAssertionChallenge.kt
src/main/kotlin/id/passage/android/model/CredentialAssertionChallenge1.kt
src/main/kotlin/id/passage/android/model/CredentialAssertionResponse.kt
src/main/kotlin/id/passage/android/model/CredentialAssertionResponseResponse.kt
src/main/kotlin/id/passage/android/model/CredentialCreation.kt
Expand All @@ -152,6 +170,7 @@ src/main/kotlin/id/passage/android/model/GetAppResponse.kt
src/main/kotlin/id/passage/android/model/GetMagicLinkStatusRequest.kt
src/main/kotlin/id/passage/android/model/GithubSocialConnection.kt
src/main/kotlin/id/passage/android/model/GoogleSocialConnection.kt
src/main/kotlin/id/passage/android/model/IdTokenRequest.kt
src/main/kotlin/id/passage/android/model/JWKResponse.kt
src/main/kotlin/id/passage/android/model/JWKResponseKeysInner.kt
src/main/kotlin/id/passage/android/model/LayoutConfig.kt
Expand All @@ -164,7 +183,6 @@ src/main/kotlin/id/passage/android/model/LoginWebAuthnStartRequest.kt
src/main/kotlin/id/passage/android/model/LoginWebAuthnStartResponse.kt
src/main/kotlin/id/passage/android/model/MagicLink.kt
src/main/kotlin/id/passage/android/model/MagicLinkAuthMethod.kt
src/main/kotlin/id/passage/android/model/MagicLinkLoginWebAuthnStartResponse.kt
src/main/kotlin/id/passage/android/model/MagicLinkResponse.kt
src/main/kotlin/id/passage/android/model/Model400Code.kt
src/main/kotlin/id/passage/android/model/Model400Error.kt
Expand All @@ -174,24 +192,32 @@ src/main/kotlin/id/passage/android/model/Model403Code.kt
src/main/kotlin/id/passage/android/model/Model403Error.kt
src/main/kotlin/id/passage/android/model/Model404Code.kt
src/main/kotlin/id/passage/android/model/Model404Error.kt
src/main/kotlin/id/passage/android/model/Model409Code.kt
src/main/kotlin/id/passage/android/model/Model409Error.kt
src/main/kotlin/id/passage/android/model/Model500Code.kt
src/main/kotlin/id/passage/android/model/Model500Error.kt
src/main/kotlin/id/passage/android/model/OAuth2ConnectionType.kt
src/main/kotlin/id/passage/android/model/Nonce.kt
src/main/kotlin/id/passage/android/model/OneTimePasscodeResponse.kt
src/main/kotlin/id/passage/android/model/OpenIdConfiguration.kt
src/main/kotlin/id/passage/android/model/OtpAuthMethod.kt
src/main/kotlin/id/passage/android/model/ProtocolCredentialAssertion.kt
src/main/kotlin/id/passage/android/model/ProtocolCredentialAssertion1.kt
src/main/kotlin/id/passage/android/model/ProtocolCredentialAssertion1PublicKey.kt
src/main/kotlin/id/passage/android/model/ProtocolCredentialAssertion1PublicKeyAllowCredentialsInner.kt
src/main/kotlin/id/passage/android/model/ProtocolCredentialAssertionPublicKey.kt
src/main/kotlin/id/passage/android/model/ProtocolCredentialAssertionPublicKeyAllowCredentialsInner.kt
src/main/kotlin/id/passage/android/model/RefreshAuthTokenRequest.kt
src/main/kotlin/id/passage/android/model/RegisterMagicLinkRequest.kt
src/main/kotlin/id/passage/android/model/RegisterMagicLinkResponse.kt
src/main/kotlin/id/passage/android/model/RegisterOneTimePasscodeRequest.kt
src/main/kotlin/id/passage/android/model/RegisterWebAuthnFinishRequest.kt
src/main/kotlin/id/passage/android/model/RegisterWebAuthnFinishWithTransactionRequest.kt
src/main/kotlin/id/passage/android/model/RegisterWebAuthnStartRequest.kt
src/main/kotlin/id/passage/android/model/RegisterWebAuthnStartResponse.kt
src/main/kotlin/id/passage/android/model/SocialConnection.kt
src/main/kotlin/id/passage/android/model/RegisterWebAuthnStartWithTransactionRequest.kt
src/main/kotlin/id/passage/android/model/RegisterWebAuthnStartWithTransactionResponse.kt
src/main/kotlin/id/passage/android/model/SocialConnections.kt
src/main/kotlin/id/passage/android/model/SocialConnectionsResponse.kt
src/main/kotlin/id/passage/android/model/TtlDisplayUnit.kt
src/main/kotlin/id/passage/android/model/UpdateDeviceRequest.kt
src/main/kotlin/id/passage/android/model/UpdateMetadataRequest.kt
Expand Down
Loading

0 comments on commit 1b9dfc6

Please sign in to comment.