Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Using common-utils for Security plugin transient thread context key #234

Merged
merged 1 commit into from
Dec 2, 2020
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 reports-scheduler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ 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:${opendistroVersion}.1"
compile "${group}:common-utils:${opendistroVersion}.2"
compileOnly "${group}:opendistro-job-scheduler-spi:${opendistroVersion}.0"
compile group: 'com.google.guava', name: 'guava', version: '15.0'
testImplementation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.amazon.opendistroforelasticsearch.reportsscheduler.action

import com.amazon.opendistroforelasticsearch.commons.ConfigConstants.OPENDISTRO_SECURITY_USER_INFO_THREAD_CONTEXT
import com.amazon.opendistroforelasticsearch.commons.authuser.User
import com.amazon.opendistroforelasticsearch.reportsscheduler.ReportsSchedulerPlugin.Companion.LOG_PREFIX
import com.amazon.opendistroforelasticsearch.reportsscheduler.util.logger
Expand Down Expand Up @@ -49,7 +50,6 @@ abstract class PluginBaseAction<Request : ActionRequest, Response : ActionRespon
companion object {
private val log by logger(PluginBaseAction::class.java)
private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
private const val OPENDISTRO_SECURITY_USER_AND_ROLES = "_opendistro_security_user_and_roles"
}

/**
Expand All @@ -61,7 +61,7 @@ abstract class PluginBaseAction<Request : ActionRequest, Response : ActionRespon
request: Request,
listener: ActionListener<Response>
) {
val userStr: String? = client.threadPool().threadContext.getTransient<String>(OPENDISTRO_SECURITY_USER_AND_ROLES)
val userStr: String? = client.threadPool().threadContext.getTransient<String>(OPENDISTRO_SECURITY_USER_INFO_THREAD_CONTEXT)
val user: User? = User.parse(userStr)
scope.launch {
try {
Expand Down