{"id":14066173,"url":"https://github.com/openanalytics/shinyproxy-shiny-demo-auth","last_synced_at":"2026-01-29T16:40:55.439Z","repository":{"id":252897284,"uuid":"803927369","full_name":"openanalytics/shinyproxy-shiny-demo-auth","owner":"openanalytics","description":"Demo of retrieving username and groups using Shiny in ShinyProxy","archived":false,"fork":false,"pushed_at":"2024-11-12T08:58:36.000Z","size":84,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-12T09:40:31.517Z","etag":null,"topics":["containers","docker","kubernetes","r","shiny","shinyproxy"],"latest_commit_sha":null,"homepage":"https://shinyproxy.io","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openanalytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-21T16:15:12.000Z","updated_at":"2024-11-12T08:58:39.000Z","dependencies_parsed_at":"2024-08-13T07:11:12.328Z","dependency_job_id":"7f5c2e83-ae85-4fb7-9b85-f970787f10ac","html_url":"https://github.com/openanalytics/shinyproxy-shiny-demo-auth","commit_stats":null,"previous_names":["openanalytics/shinyproxy-shiny-demo-auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openanalytics%2Fshinyproxy-shiny-demo-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openanalytics%2Fshinyproxy-shiny-demo-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openanalytics%2Fshinyproxy-shiny-demo-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openanalytics%2Fshinyproxy-shiny-demo-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openanalytics","download_url":"https://codeload.github.com/openanalytics/shinyproxy-shiny-demo-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228052707,"owners_count":17862106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","docker","kubernetes","r","shiny","shinyproxy"],"created_at":"2024-08-13T07:04:58.374Z","updated_at":"2026-01-29T16:40:55.433Z","avatar_url":"https://github.com/openanalytics.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# ShinyProxy Authentication demo\n\nThis repository explains how to retrieve the username and group of the current\nuser when deploying a Shiny app using ShinyProxy. The corresponding app can be\nrun in ShinyProxy and shows the available values.\n\n![Screenshot](.github/screenshots/screenshot.png)\n\n## Using environment variables\n\nWhen ShinyProxy creates a container, it passes the username and groups to the\ncontainer using environment variables. This method is supported in all versions\nof ShinyProxy. However, it does not work when using\n[container pre-initialization and sharing](https://shinyproxy.io/documentation/configuration/#container-pre-initialization-and-sharing)\nintroduced in ShinyProxy 3.1.0.\n\nExample code:\n\n```R\nSys.getenv(\"SHINYPROXY_USERNAME\")\nSys.getenv(\"SHINYPROXY_USERGROUPS\")\n```\n\nSee [`app.r`](example/app.r) for a complete example.\n\n## Using HTTP headers\n\nStarting with version 3.1.0, ShinyProxy adds the username (and groups) as HTTP\nheaders to every request sent to an app. This method is always supported, even\nwhen\nusing [container pre-initialization and sharing](https://shinyproxy.io/documentation/configuration/#container-pre-initialization-and-sharing).\n\n```R\nsession$request$HTTP_X_SP_USERID\nsession$request$HTTP_X_SP_USERGROUPS\n```\n\nSee [`app.r`](example/app.r) for a complete example.\n\n## Building the Docker image\n\nTo pull the image made in this repository from Docker Hub, use\n\n```bash\nsudo docker pull openanalytics/shinyproxy-shiny-demo-auth\n```\n\nThe relevant Docker Hub repository can be found\nat \u003chttps://hub.docker.com/r/openanalytics/shinyproxy-shiny-demo-auth\u003e.\n\nTo build the image from the Dockerfile, navigate into the root directory of this\nrepository and run\n\n```bash\nsudo docker build -t openanalytics/shinyproxy-shiny-demo-auth .\n```\n\nRunning the image for testing purposes outside ShinyProxy can be done using e.g.\n\n```bash\nsudo docker run -it -p 3838:3838 openanalytics/shinyproxy-shiny-demo-auth\n```\n\n## ShinyProxy Configuration\n\nCreate a ShinyProxy configuration file (see [application.yml](application.yml)\nfor a complete file), containing:\n\n```yaml\nproxy:\n  specs:\n    - id: shiny-auth\n      container-image: openanalytics/shinyproxy-shiny-demo-auth\n```\n\n## UTF-8 characters\n\nThe HTTP standard specifies that\nonly [printable ASCII characters](https://www.ascii-code.com/characters/printable-characters)\nare allowed in HTTP headers. Therefore, if a username contains any other\ncharacter, the app may fail to start. This can be solved by encoding the values\nusing [base64](https://en.wikipedia.org/wiki/Base64):\n\n```yaml\nproxy:\n  specs:\n    - id: shiny-auth\n      container-image: openanalytics/shinyproxy-shiny-demo-auth\n      add-default-http-headers: false\n      http_headers:\n        X-SP-UserId: \"#{T(java.util.Base64).getEncoder().encodeToString(proxy.getRuntimeValue('SHINYPROXY_USERNAME').getBytes())}\"\n        X-SP-UserGroups: \"#{proxy.getRuntimeValue('SHINYPROXY_USERGROUPS')}\"\n```\n\nNext, in R this values must be decoded using\nthe [`base64enc`](https://cran.r-project.org/web/packages/base64enc/index.html)\nlibrary:\n\n```R\nrawToChar(base64enc::base64decode(session$request$HTTP_X_SP_USERID))\n```\n\nThe next version of ShinyProxy will ignore these headers and log a warning,\nsee \u003chttps://github.com/openanalytics/shinyproxy/issues/533\u003e.\n\n## References\n\n- [ShinyProxy.io](https://shinyproxy.io/)\n- [All demos](https://shinyproxy.io/documentation/demos/)\n\n**(c) Copyright Open Analytics NV, 2024.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenanalytics%2Fshinyproxy-shiny-demo-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenanalytics%2Fshinyproxy-shiny-demo-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenanalytics%2Fshinyproxy-shiny-demo-auth/lists"}