{"id":14066278,"url":"https://github.com/myominnoo/shinyAuthX","last_synced_at":"2025-07-29T22:31:40.370Z","repository":{"id":169943190,"uuid":"646017092","full_name":"myominnoo/shinyAuthX","owner":"myominnoo","description":"R Package for Simplifying User Authentication in Shiny Apps","archived":false,"fork":false,"pushed_at":"2023-06-07T23:49:55.000Z","size":303,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-13T07:11:11.647Z","etag":null,"topics":["authentication","r","shiny"],"latest_commit_sha":null,"homepage":"https://myominnoo.github.io/shinyAuthX/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/myominnoo.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-27T03:04:56.000Z","updated_at":"2024-05-23T14:21:33.000Z","dependencies_parsed_at":"2023-10-03T10:28:01.112Z","dependency_job_id":null,"html_url":"https://github.com/myominnoo/shinyAuthX","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"c257194420505bbfe136703d9abd6fb32f8d1294"},"previous_names":["myominnoo/shinyauthx"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myominnoo%2FshinyAuthX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myominnoo%2FshinyAuthX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myominnoo%2FshinyAuthX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myominnoo%2FshinyAuthX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myominnoo","download_url":"https://codeload.github.com/myominnoo/shinyAuthX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228052751,"owners_count":17862107,"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":["authentication","r","shiny"],"created_at":"2024-08-13T07:05:01.439Z","updated_at":"2024-12-04T05:31:35.244Z","avatar_url":"https://github.com/myominnoo.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# shinyAuthX \u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/shinyAuthX)](https://CRAN.R-project.org/package=shinyAuthX)\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n[![R-CMD-check](https://github.com/myominnoo/shinyAuthX/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/myominnoo/shinyAuthX/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/myominnoo/shinyAuthX/branch/main/graph/badge.svg)](https://app.codecov.io/gh/myominnoo/shinyAuthX?branch=main)\n\u003c!-- badges: end --\u003e\n\n## Simplify User Authentication in Shiny Apps with `ShinyAuthX`\n\n`ShinyAuthX` is a powerful R package specifically designed for user authentication within Shiny apps. It provides a comprehensive suite of authentication features including user sign-in, sign-up, sign-out, and password recovery, seamlessly integrating user-friendly UI and Server components. It empowers shiny app developers to create secure and user-friendly authentication systems.   \n\n**Authentication Modules**: The sign-in module (`signinUI`, `signinServer`) enables users to authenticate themselves securely, while the sign-up feature (`signupUI`, `signupServer`) allows for hassle-free registration and account creation. With the sign-out module (`signoutUI`, `signoutServer`), users can conveniently sign out from your application, ensuring their privacy and security. In the event of a forgotten password, the password recovery module (`forgotpwUI`, `forgotpwServer`) facilitates a straightforward and efficient recovery process.\n\n\n**Password Encryption**: Passwords are hashed using the `sodium` package, providing an additional layer of protection for user credentials. The source code of your main application is also protected until authentication is successful, ensuring that sensitive information remains secure.\n\n**UI Integration**: `ShinyAuthX`'s modern UI designs are carefully crafted to provide a visually appealing and intuitive authentication experience for your users. The compatibility with Bootstrap themes ensures seamless integration with your existing Shiny app design, maintaining a consistent and professional look and feel throughout.\n\n**Data integration**: Its flexibility in data storage options, both local and online database `MongoDB` using the `mongolite` package. This allows you to choose the database solution that best suits your application's needs and infrastructure.\n\n**Verification Code via Email**: To further enhance the authentication experience, `shinyAuthX` leverages the `blastula` package to send custom emails, such as code verification during the sign-up process and password recovery emails. This ensures that users receive personalized and secure communications during critical steps of their authentication journey.\n\nIt's important to note that currently, `shinyAuthX` supports only `MongoDB` for database connection. The signup and password recovery features are optimized for `MongoDB` usage, providing the best experience and performance in this setup.\n\n**Let's Get Started Today**: Experience the power and simplicity of `ShinyAuthX`, the ultimate suite of modules for user authentication in Shiny apps. Unlock the full potential of secure and user-friendly authentication and elevate your Shiny applications to new heights.\n\nPlease feel free to reach out to us with any questions or concerns. We're here to support you as you incorporate `shinyAuthX` into your Shiny apps.\n\n\n## Demo Live!\n\n[To add later]\n\n### Installation\n\nYou can install the development version of shinyAuthX from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"myominnoo/shinyAuthX\")\n```\n\n\n## Run example apps\n\nCode for example apps in various contexts can be found in [inst/examples](inst/examples). You can launch these example apps with the `runExample` function. \n\nYou can use the following `user`/`password` pairs: \n- `admin`/`admin`\n- `user1`/`pass1`\n- `user2`/`pass2`\n\nSee `?create_dummy_users` for dummy user credentials that are used in these examples.  \n\n``` r\n  runExample(\"basic-signin\")\n  runExample(\"basic-signin-mongodb\")\n  runExample(\"basic-signin-theme\")\n  runExample(\"basic-signup\")\n  runExample(\"signup-pw-reset\")\n  runExample(\"test-app\")\n```\n\n## Usage\n\nThe package provides four module functions with corresponding UI and server elements:\n\n- sign-in: `signinUI`, `signinServer`\n- sign-out: `signoutUI`, `signoutServer`\n- sign-up: `signupUI`, `signupServer`\n- password recovery: `forgotpwUI`, `forgotpwServer`\n\n### Basic sign-in and sign-out authentications \n\nBelow is a minimal reproducible example of how to use basic authentications in a shiny app. The code sets up a Shiny app with user authentication, allowing users to sign in, sign out, and view their user data. \n\n\n```{r, eval=FALSE}\n\nlibrary(shiny)\nlibrary(shinyAuthX)\n\n# dataframe that holds usernames, passwords and other user data\nusers_base \u003c- create_dummy_users()\n\nui \u003c- fluidPage(\n\t# add signout button UI\n\tdiv(class = \"pull-right\", signoutUI(id = \"signout\")),\n\n  # add signin panel UI function without signup or password recovery panel\n  signinUI(id = \"signin\", .add_forgotpw = FALSE, .add_btn_signup = FALSE),\n\n  # setup output to show user info after signin\n  verbatimTextOutput(\"user_data\")\n)\n\nserver \u003c- function(input, output, session) {\n\t# Export reactive values for testing\n\texportTestValues(\n\t\tauth_status = credentials()$user_auth,\n\t\tauth_info   = credentials()$info\n\t)\n\n\t# call the signout module with reactive trigger to hide/show\n\tsignout_init \u003c- signoutServer(\n\t\tid = \"signout\",\n\t\tactive = reactive(credentials()$user_auth)\n\t)\n\n  # call signin module supplying data frame,\n  credentials \u003c- signinServer(\n    id = \"signin\",\n    users_db = users_base,\n    sodium_hashed = TRUE,\n    reload_on_signout = FALSE,\n    signout = reactive(signout_init())\n  )\n\n  output$user_data \u003c- renderPrint({\n    # use req to only render results when credentials()$user_auth is TRUE\n    req(credentials()$user_auth)\n    str(credentials())\n  })\n}\n\nshinyApp(ui = ui, server = server)\n```\n\n\n### Using mongodb via `mongolite`\n\nThe following code demonstrates how to integrate user authentication and authorization features into a Shiny application using `shinyAuthX` and a `MongoDB` database. It establishes a connection to `MongoDB`, initializes the database with dummy user data, defines the application's UI, implements the server logic for sign-in and sign-out functionality, and renders user information based on authentication status. The code serves as a foundation for building secure and authenticated Shiny applications with `MongoDB` as the user data storage backend.\n\n```{r, eval=FALSE}\n\nlibrary(shiny)\nlibrary(mongolite)\nlibrary(shinyAuthX)\n\n## default mongodb database server for testing: works only with `mtcars`\ncon \u003c- mongo(\"mtcars\", url = \"mongodb+srv://readwrite:test@cluster0-84vdt.mongodb.net/test\")\n## remove any existing rows\ncon$drop()\n## check\ncon$count()\n\n# add users_base to con\ncreate_dummy_users() |\u003e\n\tcon$insert()\ncon$count()\n\n\n\nui \u003c- fluidPage(\n\t# add signout button UI\n\tdiv(class = \"pull-right\", signoutUI(id = \"signout\")),\n\n\t# add signin panel UI function without signup or password recovery panel\n\tsigninUI(id = \"signin\", .add_forgotpw = FALSE, .add_btn_signup = FALSE),\n\n\t# setup output to show user info after signin\n\tverbatimTextOutput(\"user_data\")\n)\n\nserver \u003c- function(input, output, session) {\n\t# Export reactive values for testing\n\texportTestValues(\n\t\tauth_status = credentials()$user_auth,\n\t\tauth_info   = credentials()$info\n\t)\n\n\t# call the signout module with reactive trigger to hide/show\n\tsignout_init \u003c- signoutServer(\n\t\tid = \"signout\",\n\t\tactive = reactive(credentials()$user_auth)\n\t)\n\n\t# call signin module supplying data frame,\n\tcredentials \u003c- signinServer(\n\t\tid = \"signin\",\n\t\tusers_db = con$find('{}'), ## add mongodb connection instead of tibble\n\t\tsodium_hashed = TRUE,\n\t\treload_on_signout = FALSE,\n\t\tsignout = reactive(signout_init())\n\t)\n\n\toutput$user_data \u003c- renderPrint({\n\t\t# use req to only render results when credentials()$user_auth is TRUE\n\t\treq(credentials()$user_auth)\n\t\tstr(credentials())\n\t})\n}\n\nshinyApp(ui = ui, server = server)\n\n```\n\n\n### Extended Sign-up and Password-reset modules \n\nThe extended code below demonstrates the integration of sign-up and password-reset features into a Shiny application with user authentication and authorization. It leverages the `shinyAuthX` package and a `MongoDB` database to store and manage user data. The application allows users to sign up, sign in, reset their passwords, and view user information upon authentication. The code serves as a foundation for developing more comprehensive and secure web applications with user management capabilities.\n\n```{r, eval=FALSE}\n\nlibrary(shiny)\nlibrary(mongolite)\nlibrary(shinyAuthX)\n\n## default mongodb database server for testing: works only with `mtcars`\ncon \u003c- mongo(\"mtcars\", url = \"mongodb+srv://readwrite:test@cluster0-84vdt.mongodb.net/test\")\n## remove any existing rows\ncon$drop()\n## check\ncon$count()\n\n# add users_base to con\ncreate_dummy_users() |\u003e\n\tcon$insert()\ncon$count()\n\n\n\n\nui \u003c- fluidPage(\n\t# add signout button UI\n\tdiv(class = \"pull-right\", signoutUI(id = \"signout\")),\n\n\t# add signin panel UI function with signup panel\n\tsigninUI(id = \"signin\", .add_forgotpw = TRUE, .add_btn_signup = TRUE),\n\t# add signup panel\n\tsignupUI(\"signup\"),\n\t# add password-reset panel\n\tforgotpwUI(\"pw-reset\"),\n\n\t# setup output to show user info after signin\n\tverbatimTextOutput(\"user_data\")\n)\n\nserver \u003c- function(input, output, session) {\n\t# Export reactive values for testing\n\texportTestValues(\n\t\tauth_status = credentials()$user_auth,\n\t\tauth_info   = credentials()$info\n\t)\n\n\t# call the signout module with reactive trigger to hide/show\n\tsignout_init \u003c- signoutServer(\n\t\tid = \"signout\",\n\t\tactive = reactive(credentials()$user_auth)\n\t)\n\n\t# call signin module supplying data frame,\n\tcredentials \u003c- signinServer(\n\t\tid = \"signin\",\n\t\tusers_db = con$find('{}'), ## add mongodb connection instead of tibble\n\t\tsodium_hashed = TRUE,\n\t\treload_on_signout = FALSE,\n\t\tsignout = reactive(signout_init())\n\t)\n\n\t# call signup module supplying credentials() reactive and mongodb\n\tsignupServer(\n\t\tid = \"signup\", credentials = credentials, mongodb = con\n\t)\n\t# call password-reset module supplying credentials() reactive and mongodb\n\tforgotpwServer(\n\t\tid = \"pw-reset\", credentials = credentials, mongodb = con\n\t)\n\n\toutput$user_data \u003c- renderPrint({\n\t\t# use req to only render results when credentials()$user_auth is TRUE\n\t\treq(credentials()$user_auth)\n\t\tstr(credentials())\n\t})\n}\n\nshinyApp(ui = ui, server = server)\n\n```\n\n\n## TODO:\n\n1. add demo shiny apps hosted on shinyapps.io\n2. add runExample(). \n3. add examples for each use case\n\t1. simple user signin \n\t2. user signin with data.frame\n\t3. user signin with mongolite\n\t4. user signup with mongolite \n\t5. user signup with mongolite plus email option [just codes; not run]\n\n\n## Credits: \n\nWe would like to extend our sincere gratitude and acknowledgments to the following individuals for their contributions to the development of `shinyAuthX`:\n\n- Paul Campbell: The author of the `shinyauthr` package, from which we borrowed the `login` and `logout` module functions (`loginUI()`, `loginServer()`, `logoutUI()`, `logoutServer()`). Paul's work and dedication have significantly influenced the functionality and usability of `shinyAuthX`.\n\nWe would also like to specifically credit the following individuals for their contributions to the cookie-based authentication aspect of `shinyAuthX`:\n\n- Michael Dewar: His expertise and contributions have played a crucial role in shaping the implementation of the cookie-based authentication mechanism in `shinyAuthX`. His insights have greatly enhanced the security and functionality of this feature.\n\n- Calligross: Their valuable input and contributions have contributed to the development and improvement of the cookie-based authentication functionality in `shinyauthr`. \n\nFor further information about their specific roles and contributions, we recommend visiting the [`shinyauthr`](https://github.com/PaulC91/shinyauthr) GitHub page, where you can find additional details about the original package and its contributors.\n\n## Disclaimer: \n\nIt is important to note that the security of any authentication system is a complex matter, and while we have taken great care in developing `shinyAuthX`, we cannot guarantee its foolproof security. The authentication process provided by `shinyAuthX` should be used with caution, and we strongly recommend implementing additional security measures based on your specific requirements. We endorse Paul Campbell's disclaimer statement regarding the security risks associated with the package. Please use `shinyAuthX` at your own risk.\n\nWe are grateful for the contributions and support from all the individuals mentioned above, as well as the wider community that has provided feedback and suggestions to help improve `shinyAuthX`. Thank you for your valuable contributions and continued support!\n\n## Related work\n\nBoth package [`shinyauthr`](https://github.com/PaulC91/shinyauthr) and [shinymanager](https://github.com/datastorm-open/shinymanager/) provide a nice shiny module to add an authentication layer to your shiny apps.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyominnoo%2FshinyAuthX","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyominnoo%2FshinyAuthX","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyominnoo%2FshinyAuthX/lists"}