Repository navigation
feat: Add SHINYPROXY_AUTH_BACKEND runtime value - #105
Open
WahiduzzamanKhan wants to merge 1 commit into
Open
WahiduzzamanKhan wants to merge 1 commit into
WahiduzzamanKhan wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
SHINYPROXY_AUTH_BACKENDruntime valueCloses openanalytics/shinyproxy#486
Motivation
Apps currently can't tell whether the user is authenticated. With
proxy.authentication: none,SHINYPROXY_USERNAMEis a random UUID, which looks like a real username to the app.In #486, @LEDfan suggested adding a
SHINYPROXY_AUTH_BACKENDenvironment variable with the name of theauthentication backend that was used. This PR implements that suggestion.
What it does
Every app container gets a new environment variable:
<name>is the value ofproxy.authentication, as returned byIAuthenticationBackend#getName():none,simple,ldap,openid,saml,webserviceorcustomHeader.For example, in a Shiny app:
The value can also be used in SpEL, e.g.:
Implementation
AuthBackendKeyruntime value (SHINYPROXY_AUTH_BACKEND/openanalytics.eu/sp-auth-backend),registered in
RuntimeValueKeyRegistry. Its flags matchUserIdKey: stored as an annotation and an env var, and not exposed in the API.RuntimeValueService#addRuntimeValuesBeforeSpelsets the value, so it's also available in SpEL.ProxySharingScalersets it on pre-initialized (delegate) containers. The auth backend is the same for the wholeserver, so it's already known before a user claims a seat.
IAuthenticationBackendis injected with@Lazy, as inUserService.No backend-specific changes are needed: Docker, Docker Swarm, Kubernetes and ECS all receive the value via
AbstractContainerBackend#buildEnv.Tests
NoAuthenticationTest#authBackendIsExposedToApp(Docker): withnoneauth, the container hasSHINYPROXY_AUTH_BACKEND=none.TestIntegrationProxySharing#testAuthBackendOnDelegateProxy(Docker): the delegate container hasSHINYPROXY_AUTH_BACKEND=simple.TestIntegrationOnKube: added an assertion next to the existingSHINYPROXY_USERNAMEchecks (not run locally, no cluster).NoAuthenticationTest,SimpleAuthenticationTestandTestIntegrationOnDockerpass.noneandsimpleauth: env var and SpEL value are both correct.Suggested documentation
The docs aren't public, so here's suggested text for the list of environment variables available to apps on shinyproxy.io: