Skip to content

Commit

Permalink
chore: bump rsproto version
Browse files Browse the repository at this point in the history
  • Loading branch information
y9vad9 committed Dec 28, 2023
1 parent d61436c commit c35e5f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ grpc-netty = "1.55.1"
grpc-services = "1.55.1"
koin = "3.4.0"
rsocket = "0.15.4"
rsproto = "0.3.2"
rsproto = "0.3.3"

[libraries]
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
Expand Down Expand Up @@ -88,4 +88,4 @@ cashapp-sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
shadow-jar = { id = "com.github.johnrengelman.shadow", version.require = "8.1.1" }
jvm-module-convention = { id = "jvm-module-convention", version.require = "SNAPSHOT" }
conventions-multiplatform-library = { id = "multiplatform-library-convention", version.require = "SNAPSHOT" }
timemates-rsproto = { id = "io.timemates.rsproto", version.ref = "rsproto" }
timemates-rsproto = { id = "io.timemates.rsproto", version.require = "0.3.2" }
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package io.timemates.api.rsocket.auth

import io.rsocket.kotlin.payload.Payload
import io.timemates.backend.authorization.usecases.GetAuthorizationUseCase
import io.timemates.rsproto.metadata.ExtraMetadata
import io.timemates.rsproto.metadata.Metadata
import io.timemates.rsproto.server.annotations.ExperimentalInterceptorsApi
import io.timemates.rsproto.server.interceptors.Interceptor
import io.timemates.rsproto.server.interceptors.InterceptorScope
import kotlin.coroutines.CoroutineContext

/**
* Interceptor class that handles authentication for RSocket requests.
*
* @param getUserIdByAccessTokenUseCase The use case responsible for retrieving user ID by access token.
*/
@OptIn(ExperimentalInterceptorsApi::class)
class AuthInterceptor(
Expand All @@ -22,8 +20,8 @@ class AuthInterceptor(
companion object Key : CoroutineContext.Key<Data>
}

override fun intercept(coroutineContext: CoroutineContext, incoming: Payload): CoroutineContext {
val accessHash = coroutineContext[ExtraMetadata]?.extra?.get("access_hash")?.decodeToString()
override fun InterceptorScope.intercept(coroutineContext: CoroutineContext, metadata: Metadata): CoroutineContext {
val accessHash = metadata.extra["access_hash"]?.decodeToString()
return coroutineContext + Data(accessHash, getAuthorizationUseCase)
}
}
Expand Down

0 comments on commit c35e5f8

Please sign in to comment.