From fdbd30570e459d8135c9427ee9ae35828d441af6 Mon Sep 17 00:00:00 2001 From: Anantha Krishna Bhatta Date: Tue, 24 Nov 2020 16:50:55 -0800 Subject: [PATCH] Using request tenant info from common-utils to filter --- reports-scheduler/build.gradle | 4 ++-- .../reportsscheduler/security/UserAccessManager.kt | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/reports-scheduler/build.gradle b/reports-scheduler/build.gradle index 5e9dcca1..daf701e6 100644 --- a/reports-scheduler/build.gradle +++ b/reports-scheduler/build.gradle @@ -124,8 +124,8 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" compile "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}" compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9" - compile "${group}:common-utils:${version}" - compileOnly "${group}:opendistro-job-scheduler-spi:${opendistroVersion}.0" // TODO: use ${version} when available + compile "${group}:common-utils:${opendistroVersion}.1" + compileOnly "${group}:opendistro-job-scheduler-spi:${opendistroVersion}.0" compile group: 'com.google.guava', name: 'guava', version: '15.0' testImplementation( 'org.assertj:assertj-core:3.16.1', diff --git a/reports-scheduler/src/main/kotlin/com/amazon/opendistroforelasticsearch/reportsscheduler/security/UserAccessManager.kt b/reports-scheduler/src/main/kotlin/com/amazon/opendistroforelasticsearch/reportsscheduler/security/UserAccessManager.kt index 0d01f2d2..a178bd4e 100644 --- a/reports-scheduler/src/main/kotlin/com/amazon/opendistroforelasticsearch/reportsscheduler/security/UserAccessManager.kt +++ b/reports-scheduler/src/main/kotlin/com/amazon/opendistroforelasticsearch/reportsscheduler/security/UserAccessManager.kt @@ -31,7 +31,7 @@ internal object UserAccessManager { private const val ROLE_TAG = "Role:" private const val BACKEND_ROLE_TAG = "BERole:" private const val ALL_ACCESS_ROLE = "all_access" - private const val KIBANA_SERVER_USER = "kibanaserver" + private const val KIBANA_SERVER_USER = "kibanaserver" // TODO: Change it to background user when created. private const val PRIVATE_TENANT = "__user__" const val DEFAULT_TENANT = "" @@ -92,7 +92,10 @@ internal object UserAccessManager { * Get tenant info from user object. */ fun getUserTenant(user: User?): String { - return DEFAULT_TENANT // TODO: extract from user object + return when (val requestedTenant = user?.requestedTenant) { + null -> DEFAULT_TENANT + else -> requestedTenant + } } /**