Skip to content

Commit

Permalink
Merge pull request #87 from passageidentity/PSG-5172
Browse files Browse the repository at this point in the history
PSG-5172
  • Loading branch information
SinaSeylani authored Oct 29, 2024
2 parents 4e6f902 + 315a32d commit 89b1bfe
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 15 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/publish-flex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Publish Flex Package

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'

- name: Set up GPG
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
run: |
echo "${GPG_PRIVATE_KEY}" | gpg --batch --import
echo "signing.gnupg.keyName=${GPG_KEY_ID}" >> gradle.properties
echo "signing.gnupg.passphrase=${GPG_PASSPHRASE}" >> gradle.properties
- name: Publish to Maven Central
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_TOKEN_ID }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
run: ./gradlew :passageflex:publish

- name: Wait for Staging Repository to be Created
run: sleep 60

- name: Install xmllint
run: sudo apt-get install -y libxml2-utils

- name: Get Staging Repository ID
id: get_repo_id
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_TOKEN_ID }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
run: |
response=$(curl -u ${{ secrets.OSSRH_USERNAME }}:${{ secrets.OSSRH_PASSWORD }} -X GET "https://s01.oss.sonatype.org/service/local/staging/profile_repositories")
echo "Response: $response"
repo_id=$(echo ${response} | xmllint --xpath "string(//stagingProfileRepository/repositoryId)" -)
echo "Repository ID: $repo_id"
echo "::set-output name=repo_id::$repo_id"
- name: Close and Release Repository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_TOKEN_ID }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
OSSRH_PROFILE_ID: ${{ secrets.OSSRH_PROFILE_ID }}
run: |
repo_id=${{ steps.get_repo_id.outputs.repo_id }}
close_xml="
<promoteRequest>
<data>
<stagedRepositoryId>"${repo_id}"</stagedRepositoryId>
</data>
</promoteRequest>"
echo "Close XML: ${close_xml}"
curl -u ${OSSRH_USERNAME}:${OSSRH_PASSWORD} \
-X POST https://s01.oss.sonatype.org/service/local/staging/profiles/${OSSRH_PROFILE_ID}/finish \
-H "Content-Type: application/xml" \
-d "${close_xml}"
# Wait for repository to close
sleep 120
promote_xml="
<promoteRequest>
<data>
<stagedRepositoryId>"${repo_id}"</stagedRepositoryId>
</data>
</promoteRequest>"
echo "Promote XML: ${promote_xml}"
curl -u ${OSSRH_USERNAME}:${OSSRH_PASSWORD} \
-X POST https://s01.oss.sonatype.org/service/local/staging/profiles/${OSSRH_PROFILE_ID}/promote \
-H "Content-Type: application/xml" \
-d "${promote_xml}"
12 changes: 6 additions & 6 deletions passageflex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

group = "id.passage.android"
version = "0.2.0"
version = "0.3.0"

def localProperties = new Properties()
File localPropertiesFile = rootProject.file('local.properties')
Expand All @@ -30,8 +30,8 @@ android {
defaultConfig {
minSdk 28 // Minimum support for Credentials Manager - ie passkeys
targetSdk 34
versionCode 2
versionName "0.2.0"
versionCode 3
versionName "0.3.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -106,9 +106,9 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:4.10.0"

// For JSON serialization and parsing
implementation "com.squareup.moshi:moshi:1.14.0"
implementation "com.squareup.moshi:moshi-adapters:1.14.0"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.14.0"
implementation "com.squareup.moshi:moshi:1.15.1"
implementation "com.squareup.moshi:moshi-adapters:1.15.1"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.15.1"
}

openApiGenerate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import id.passage.android.passageflex.model.AuthenticatorAttachment
import id.passage.passageflex.exceptions.AuthenticateCancellationException
import id.passage.passageflex.exceptions.AuthenticateException
import id.passage.passageflex.exceptions.RegisterException
import id.passage.passageflex.models.PasskeyCreationOptions
import junit.framework.TestCase
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -68,7 +69,7 @@ internal class PassageFlexTest {
transactionId = transactionId,
activity = testActivity,
appId = FlexTestConfig.APP_ID,
authenticatorAttachment = AuthenticatorAttachment.platform,
options = PasskeyCreationOptions(AuthenticatorAttachment.platform),
apiBasePath = FlexTestConfig.API_BASE_URL,
)
} catch (e: RegisterException) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package id.passage.passageflex

import android.app.Activity
import id.passage.android.passageflex.model.AuthenticatorAttachment
import id.passage.passageflex.models.PasskeyCreationOptions

/**
* The base class for utilizing Android's native passkey APIs and Passage Flex APIs together.
Expand All @@ -17,21 +17,19 @@ public class PassageFlexPasskey(
* register a new passkey for use with your app.
*
* @param transactionId The Passage transaction id provided by your app's server.
* @param authenticatorAttachment (Optional) The type of authentication that will be used in
* this WebAuthN flow request. Defaults to `AuthenticatorAttachment.platform`. Use
* `AuthenticatorAttachment.cross-platform` for physical security key registration.
* @param options optional configuration for passkey creation
* @return A single-use "nonce" from Passage server to be exchanged for an authentication
* token on your app's server.
* @throws RegisterException
*/
public suspend fun register(
transactionId: String,
authenticatorAttachment: AuthenticatorAttachment = AuthenticatorAttachment.platform,
options: PasskeyCreationOptions? = null,
) = PassagePasskeyAuthentication.register(
transactionId,
activity,
appId,
authenticatorAttachment,
options,
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import id.passage.android.passageflex.model.RegisterWebAuthnFinishWithTransactio
import id.passage.android.passageflex.model.RegisterWebAuthnStartWithTransactionRequest
import id.passage.passageflex.exceptions.AuthenticateException
import id.passage.passageflex.exceptions.RegisterException
import id.passage.passageflex.models.PasskeyCreationOptions

object PassagePasskeyAuthentication {
private const val BASE_PATH = "https://auth.passage.id/v1"
Expand All @@ -18,7 +19,7 @@ object PassagePasskeyAuthentication {
transactionId: String,
activity: Activity,
appId: String,
authenticatorAttachment: AuthenticatorAttachment = AuthenticatorAttachment.platform,
options: PasskeyCreationOptions?,
apiBasePath: String? = null,
): String {
try {
Expand All @@ -27,7 +28,7 @@ object PassagePasskeyAuthentication {
val startRequest =
RegisterWebAuthnStartWithTransactionRequest(
transactionId,
authenticatorAttachment,
options?.authenticatorAttachment ?: AuthenticatorAttachment.platform,
)
val startResponse =
registerAPI
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package id.passage.passageflex.models

import id.passage.android.passageflex.model.AuthenticatorAttachment

data class PasskeyCreationOptions(
val authenticatorAttachment: AuthenticatorAttachment,
)

0 comments on commit 89b1bfe

Please sign in to comment.