Source code for deephaven_enterprise.auth_context
# Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
"""This module provides tools for getting the current context's authenticated and effective user."""
import jpy
from deephaven.execution_context import get_exec_ctx
[docs]
def get_auth_context():
"""
Get the authentication context for the current execution context.
:return: the authentication context
"""
return get_exec_ctx().j_exec_ctx.getAuthContext()
[docs]
def get_dhe_auth_context():
"""
Get the authentication context for the current execution context as a DheAuthContext.
:return: the authentication context as a DheAuthContext
"""
return jpy.cast(
get_auth_context(),
jpy.get_type("io.deephaven.enterprise.dnd.authentication.DheAuthContext"),
)
[docs]
def get_authenticated_user():
"""
Get the authenticated user for the current execution context.
:return: the authenticated user
"""
return get_dhe_auth_context().getAuthenticatedUser()
[docs]
def get_effective_user():
"""
Get the effective user for the current execution context.
:return: the effective user
"""
return get_dhe_auth_context().getEffectiveUser()