Skip to content

Commit 2a53b37

Browse files
committed
Fix data leakage between authentication logic and server invocation.
Increment project-wide Kotlin version up to 2.2.0
1 parent 563ce3f commit 2a53b37

24 files changed

+498
-484
lines changed

Shrine/app/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ plugins {
2121
alias(libs.plugins.kotlin.android)
2222
id("dagger.hilt.android.plugin")
2323
alias(libs.plugins.ksp)
24+
alias(libs.plugins.kotlin.compose)
2425
}
2526

2627
repositories {
@@ -87,10 +88,6 @@ android {
8788
buildConfig = true
8889
}
8990

90-
composeOptions {
91-
kotlinCompilerExtensionVersion = "1.5.2"
92-
}
93-
9491
packaging {
9592
resources {
9693
excludes += "/META-INF/{AL2.0,LGPL2.1}"

Shrine/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ plugins {
2121
alias(libs.plugins.spotless) apply false
2222
alias(libs.plugins.ksp) apply false
2323
alias(libs.plugins.kotlin.serialization) apply false
24+
alias(libs.plugins.kotlin.compose) apply false
2425
}
2526

2627
tasks.register("clean", Delete::class) {

Shrine/gradle/libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
activity = "1.9.0"
33
androidxAppcompat = "1.7.0"
4-
androidPlugin = "8.11.1"
4+
androidPlugin = "8.12.0"
55
browser = "1.8.0"
66
coil = "2.7.0"
77
coilSvg = "2.6.0"
@@ -14,12 +14,12 @@ googleid = "1.1.1"
1414
hilt = "2.51"
1515
hiltCompiler = "1.2.0"
1616
hiltNavigationCompose = "1.2.0"
17-
horologist = "0.6.23"
18-
kotlin = "1.9.0"
17+
horologist = "0.7.15"
18+
kotlin = "2.2.0"
1919
kotlinCoroutines = "1.0"
2020
kotlinxCoroutines = "1.9.0"
2121
kotlinxSerialization = "1.7.3"
22-
ksp = "1.9.0-1.0.13"
22+
ksp = "2.2.0-2.0.2"
2323
ktlint = "0.50.0"
2424
ktx = "1.13.1"
2525
lifecycle = "2.7.0"

Shrine/wear/build.gradle.kts

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,20 @@ plugins {
22
alias(libs.plugins.android.application)
33
alias(libs.plugins.kotlin.android)
44
alias(libs.plugins.kotlin.serialization)
5-
}
6-
7-
configurations.all {
8-
resolutionStrategy {
9-
// Force kotlin dependencies to use the versions needed for Wear so that I don't need to
10-
// modify mobile dependency versions in this change.
11-
// TODO(johnzoeller): Update mobile dependencies and remove this
12-
force("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
13-
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0")
14-
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0")
15-
force("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
16-
force("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
17-
}
5+
alias(libs.plugins.kotlin.compose)
186
}
197

208
android {
219
namespace = "com.authentication.shrinewear"
22-
compileSdk = 35
10+
compileSdk = 36
2311

2412
defaultConfig {
25-
applicationId = "com.authentication.shrinewear"
13+
applicationId = "com.authentication.shrine"
2614
minSdk = 30
27-
targetSdk = 35
15+
targetSdk = 36
2816
versionCode = 1
2917
versionName = "1.0"
3018
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
31-
3219
buildConfigField("String", "API_BASE_URL", "\"https://project-sesame-426206.appspot.com\"")
3320
}
3421

@@ -51,16 +38,16 @@ android {
5138
sourceCompatibility = JavaVersion.VERSION_1_8
5239
targetCompatibility = JavaVersion.VERSION_1_8
5340
}
54-
kotlinOptions {
55-
jvmTarget = "1.8"
41+
42+
kotlin {
43+
compilerOptions {
44+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8)
45+
}
5646
}
5747
buildFeatures {
5848
compose = true
5949
buildConfig = true
6050
}
61-
composeOptions {
62-
kotlinCompilerExtensionVersion = "1.5.2"
63-
}
6451
packaging {
6552
resources {
6653
excludes += "/META-INF/{AL2.0,LGPL2.1}"
@@ -97,8 +84,8 @@ android {
9784
implementation(libs.kotlinx.serialization.json) // New
9885

9986
// Wear Horologist SIWG composables
100-
implementation(libs.horologist.auth.ui) // New
101-
implementation(libs.horologist.compose.layout) // New
87+
implementation(libs.horologist.auth.ui)
88+
implementation(libs.horologist.compose.layout)
10289

10390
// GMS
10491
implementation(libs.google.id) // NO CHANGE

Shrine/wear/src/main/java/com/authentication/shrinewear/Graph.kt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ package com.authentication.shrinewear
1818
import android.content.Context
1919
import com.authentication.shrinewear.authenticator.AuthenticationServer
2020
import com.authentication.shrinewear.authenticator.CredentialManagerAuthenticator
21+
import kotlinx.coroutines.flow.MutableStateFlow
22+
import kotlinx.coroutines.flow.StateFlow
23+
import kotlinx.coroutines.flow.asStateFlow
24+
25+
26+
/**
27+
* Represents the possible authentication states of the application.
28+
*/
29+
enum class AuthenticationState {
30+
LOGGED_OUT,
31+
LOGGED_IN,
32+
DISMISSED_BY_USER,
33+
MISSING_CREDENTIALS,
34+
FAILED,
35+
UNKNOWN_ERROR,
36+
}
2137

2238
/**
2339
* A simple, manual dependency injection container for application-wide singletons.
@@ -42,13 +58,11 @@ object Graph {
4258
lateinit var authenticationServer: AuthenticationServer
4359
private set
4460

61+
private val _authenticationState = MutableStateFlow(AuthenticationState.LOGGED_OUT)
4562
/**
46-
* Stores the current authentication status code as an Android string resource ID.
47-
* This can be used to reflect the authentication state across different parts of the UI.
48-
*
49-
* Defaults to [R.string.credman_status_logged_out].
63+
* Stores the current authentication status code. Defaults to [AuthenticationState.LOGGED_OUT].
5064
*/
51-
var authenticationStatusCode: Int = R.string.credman_status_logged_out
65+
val authenticationState: StateFlow<AuthenticationState> = _authenticationState.asStateFlow()
5266

5367
/**
5468
* Provides and initializes the core dependencies for the application's [Graph].
@@ -62,4 +76,8 @@ object Graph {
6276
credentialManagerAuthenticator = CredentialManagerAuthenticator(context)
6377
authenticationServer = AuthenticationServer()
6478
}
79+
80+
fun updateAuthenticationState(newState: AuthenticationState) {
81+
_authenticationState.value = newState
82+
}
6583
}

0 commit comments

Comments
 (0)