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

Update dependencies #8

Merged
merged 18 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
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 .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
- name: Publish artifacts
env:
GITHUB_USERNAME: "Github Action"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sharedTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
- name: cache gradle
uses: actions/cache@v1
with:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ implementation("ch.dreipol.dreiattest.multiplatform:multiplatform-android:<versi
The library uses the `AttestationProvider` - interface to wrap the actual google or apple device attestation services.

#### Android
For android dreiattest is using SafetyNet for your device attestation. To use this service you need to create an api key, which is described [here](https://developer.android.com/training/safetynet/attestation#obtain-api-key).
For android dreiattest is using Play Integrity API for your device attestation.
To use this service you need to activate Integrity API as described [here](https://developer.android.com/google/play/integrity/setup).

### `DreiAttestService`
To use the `DreiAttestService` create a new instance and call the `initWith` - function, as follows:
Expand All @@ -60,20 +61,20 @@ try {

You would typically want to create the `GoogleAttestionProvider` in your application's `onCreate` and the `AppleAttestationProvider` in your `application(_:didFinishLaunchingWithOptions:)` method and pass it to your multiplatform code from there.

### Ktor - feature
There is a ktor-client feature availlable, you can use it as follows:
### Ktor - Plugin
There is a ktor-client plugin available, you can use it as follows:
```kotlin
HttpClient {
...

install(DreiAttestFeature) {
install(DreiAttestPlugin) {
this.attestService = attestService
}

...
}
```
The feature is now signing every request, for which the url matches the configured `baseAddress` in the `DreiAttestService`.
The plugin is now signing every request, for which the url matches the configured `baseAddress` in the `DreiAttestService`.

### Development
During development it may be useful to setup a shared secret on the server to bypass dreiAttest. You can pass this shared secret to the library using the DREIATTEST_BYPASS_SECRET environment variable or by passing it to the AttestServie in its initializer.
15 changes: 8 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ group = "ch.dreipol.attest.android"
version = "1.0"

android {
compileSdkVersion 31
buildToolsVersion "30.0.3"

compileSdk 34

defaultConfig {
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "0.0"
targetSdkVersion 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -31,12 +27,17 @@ android {
kotlinOptions {
freeCompilerArgs += '-Xexplicit-api=strict'
}
namespace 'ch.dreipol.attest.android'

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "androidx.core:core-ktx:1.7.0"
implementation "androidx.core:core-ktx:1.13.1"

testImplementation "junit:junit:4.13.2"
}
Expand Down
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.dreipol.attest.android" />
<manifest />
21 changes: 11 additions & 10 deletions androidtest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ plugins {
}

android {
compileSdkVersion 31
compileSdkVersion 33
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "ch.dreipol.dreiattest.androidtest"
minSdkVersion 23
targetSdkVersion 31
targetSdkVersion 33
versionCode 1
versionName "1.0"

Expand All @@ -30,6 +30,7 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'ch.dreipol.dreiattest.androidtest'
}

dependencies {
Expand All @@ -43,16 +44,16 @@ dependencies {
implementation("io.ktor:ktor-client-core:$versions_ktor")
implementation("io.ktor:ktor-client-json:$versions_ktor")
implementation("io.ktor:ktor-client-logging:$versions_ktor")
implementation("io.ktor:ktor-client-serialization:$versions_ktor")
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$versions_serialization"
implementation("io.ktor:ktor-client-content-negotiation:$versions_ktor")
implementation("io.ktor:ktor-serialization-kotlinx-json:$versions_ktor")
implementation("co.touchlab:kermit:$versions_kermit")
implementation("com.russhwolf:multiplatform-settings-test:$versions_mpf_settings")

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package ch.dreipol.dreiattest.androidtest

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import ch.dreipol.dreiattest.multiplatform.DeviceAttestationService
import ch.dreipol.dreiattest.multiplatform.DreiAttestService
import ch.dreipol.dreiattest.multiplatform.GoogleAttestationProvider
import ch.dreipol.dreiattest.multiplatform.SessionConfiguration
import com.russhwolf.settings.MockSettings
import com.russhwolf.settings.MapSettings
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
Expand All @@ -26,7 +25,7 @@ class DemoApiIT {

@Test
fun testDreiAttestation() {
val attestService = DreiAttestService(settings = MockSettings())
val attestService = DreiAttestService(settings = MapSettings())
attestService.initWith(
baseUrl, SessionConfiguration("test", deviceAttestationProvider = GoogleAttestationProvider(
InstrumentationRegistry.getInstrumentation().context, safetyNetAPIKey)))
Expand Down
3 changes: 1 addition & 2 deletions androidtest/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.dreipol.dreiattest.androidtest">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package ch.dreipol.dreiattest.androidtest

import ch.dreipol.dreiattest.multiplatform.AttestService
import ch.dreipol.dreiattest.multiplatform.DreiAttestFeature
import co.touchlab.kermit.CommonLogger
import co.touchlab.kermit.Kermit
import ch.dreipol.dreiattest.multiplatform.DreiAttestPlugin
import co.touchlab.kermit.Logger
import io.ktor.client.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import io.ktor.client.features.logging.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.logging.*
import io.ktor.client.plugins.logging.Logger as KtorLogger
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.serialization.json.Json

class DemoAPI(private val attestService: AttestService, private val baseUrl: String) {

private val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(
kotlinx.serialization.json.Json {
install(ContentNegotiation) {
json(
Json {
ignoreUnknownKeys = true
}
)
Expand All @@ -26,7 +27,7 @@ class DemoAPI(private val attestService: AttestService, private val baseUrl: Str
logger = HttpLogger()
level = LogLevel.ALL
}
install(DreiAttestFeature) {
install(DreiAttestPlugin) {
attestService = [email protected]
}
}
Expand All @@ -39,17 +40,12 @@ class DemoAPI(private val attestService: AttestService, private val baseUrl: Str

}

internal class HttpLogger : Logger {
internal class HttpLogger : KtorLogger {
override fun log(message: String) {
kermit().d { message }
Logger.d { message }
}
}

internal fun kermit(): Kermit {
return Kermit(CommonLogger())
}



private fun URLBuilder.setBase(base: String): URLBuilder {
val path = encodedPath
Expand Down
27 changes: 0 additions & 27 deletions build.gradle

This file was deleted.

45 changes: 45 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask

plugins {
id("com.github.ben-manes.versions") version "0.47.0"
}
buildscript {
val versions_kotlin: String by project
val versions_linter: String by project
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath("com.android.tools.build:gradle:8.3.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$versions_kotlin")
classpath("com.github.dcendents:android-maven-gradle-plugin:2.1")
classpath("org.jlleitschuh.gradle:ktlint-gradle:$versions_linter")
}
}

allprojects {
repositories {
mavenCentral()
google()
}
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}

fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}


tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
isNonStable(candidate.version)
}
}
25 changes: 14 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,25 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.stability.nowarn=true

# dependency versions

#shared
versions_kotlin=1.6.10
versions_linter=10.2.1
versions_coroutines=1.6.3-native-mt
versions_ktor=1.6.8
versions_serialization=1.3.2
versions_kermit=0.1.9
versions_mpf_settings=0.8.1
versions_kotlin=1.9.24
versions_linter=12.1.1
versions_coroutines=1.8.0
versions_ktor=2.3.10
versions_serialization=1.6.3
versions_kermit=2.0.3
versions_mpf_settings=1.1.1

#android
versions_safety_net=18.0.1
versions_play_services_coroutines=1.6.0
versions_play_integrity=1.3.0
versions_play_services_coroutines=1.8.0

android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false

#iOS
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading