Skip to content

fix(model-client): tokens generated for one repository where used for…#2450

Open
slisson wants to merge 1 commit intomainfrom
fix/token-per-branch
Open

fix(model-client): tokens generated for one repository where used for…#2450
slisson wants to merge 1 commit intomainfrom
fix/token-per-branch

Conversation

@slisson
Copy link
Member

@slisson slisson commented Mar 5, 2026

… all

JWT tokens can have permission only for the repository they were generated for. But the client wasn't able to manage multiple tokens for different repositories.

@slisson slisson force-pushed the fix/token-per-branch branch from a22b75f to 7c84bd2 Compare March 5, 2026 15:26
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Test Results

  249 files    249 suites   50m 19s ⏱️
1 420 tests 1 409 ✅ 11 💤 0 ❌
1 430 runs  1 419 ✅ 11 💤 0 ❌

Results for commit 6615c2b.

♻️ This comment has been updated with latest results.

… all

JWT tokens can have permission only for the repository they were generated for.
But the client wasn't able to manage multiple tokens for different repositories.
@slisson slisson force-pushed the fix/token-per-branch branch from 7c84bd2 to 6615c2b Compare March 5, 2026 18:59
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

JVM coverage report

Overall Project 59.22% -0.06%
Files changed 86.14% 🍏

File Coverage
ModelClientV2PlatformSpecificBuilder.kt 100% 🍏
ModelClientV2.kt 83.97% -0.7% 🍏
ModelixAuthClient.kt 81.59% 🍏
ModelSyncService.kt 73.88% -0.44%
OAuthConfig.kt 67.19% -12.5%
IModelSyncService.kt 58.72% 🍏
RestWebModelClient.kt 49.16% 🍏

package org.modelix.model.client2

internal actual interface Closable : java.io.Closeable {
actual interface Closable : java.io.Closeable {

Check warning

Code scanning / detekt

Closable is missing required documentation. Warning

Closable is missing required documentation.
private val httpTransport: HttpTransport = NetHttpTransport()
private val jsonFactory: JsonFactory = GsonFactory()
private var lastCredentials: Credential? = null
private var lastCredentials = HashMap<TokenCacheKey, Credential>()

Check warning

Code scanning / detekt

Variable lastCredentials is declared as var with a mutable type java.util.HashMap. Consider using val or an immutable collection or value type Warning

Variable lastCredentials is declared as var with a mutable type java.util.HashMap. Consider using val or an immutable collection or value type
private val httpTransport: HttpTransport = NetHttpTransport()
private val jsonFactory: JsonFactory = GsonFactory()
private var lastCredentials: Credential? = null
private var lastCredentials = HashMap<TokenCacheKey, Credential>()

Check warning

Code scanning / detekt

Variable 'lastCredentials' could be val. Warning

Variable 'lastCredentials' could be val.
fun getTokens(): Credential? {
return lastCredentials?.takeIf { !it.isExpired() }
@Synchronized
fun getTokens(config: OAuthConfig): Credential? {

Check warning

Code scanning / detekt

The function getTokens is missing documentation. Warning

The function getTokens is missing documentation.
suspend fun getAndMaybeRefreshTokens(): Credential? {
return lastCredentials?.refreshIfExpired()
@Synchronized
fun getAndMaybeRefreshTokens(config: OAuthConfig): Credential? {

Check warning

Code scanning / detekt

The function getAndMaybeRefreshTokens is missing documentation. Warning

The function getAndMaybeRefreshTokens is missing documentation.
repositoryId?.let { repository ->
ModelServerPermissionSchema.repository(repository).write.fullId
},
branchName?.let { branchName ->

Check warning

Code scanning / detekt

Name shadowed: branchName Warning test

Name shadowed: branchName
interface IServerConnection : Closeable {
@Deprecated("Provide an ITokenProvider")
fun setTokenProvider(tokenProvider: (suspend () -> String?))
fun setTokenProvider(tokenProvider: ITokenProvider)

Check warning

Code scanning / detekt

The function setTokenProvider is missing documentation. Warning

The function setTokenProvider is missing documentation.
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.

1 participant