https://github.com/epi-interactive/User_Authentication
User authentication in R Shiny
https://github.com/epi-interactive/User_Authentication
hashing login-page r shiny
Last synced: 14 days ago
JSON representation
User authentication in R Shiny
- Host: GitHub
- URL: https://github.com/epi-interactive/User_Authentication
- Owner: epi-interactive
- License: mit
- Created: 2019-05-06T22:53:17.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T02:42:57.000Z (about 1 year ago)
- Last Synced: 2024-11-02T16:08:17.562Z (5 months ago)
- Topics: hashing, login-page, r, shiny
- Language: R
- Size: 82 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - epi-interactive/User_Authentication - User authentication in R Shiny (R)
README
# User Authentication
A sample implementation of a login page for an R Shiny app. It uses the bcrypt R package which provides bindings to the 'blowfish' password hashing algorithm. We've used a similar method with database backend and also implemented a user and permission system on top of it. You can log into the demo app using admin / admin.You can try out the app [here](https://rshiny2.epi-interactive.com/apps/user_authentication)

## How it works
In this snippet we have a preconfigured username and hashed password that gets compared with the submitted username and password using the `bcrypt` package in R.``` r
# The expected username and password are admin/admin
# The long password string in the following variable is generated by hashpw("admin")
credentials <- reactiveValues(userIsAuth = FALSE, username = "admin",
password = "$2a$12$jxoOXWVRB0XPJzfyViVjY.NkgqZlCcW4UbnOjRPvppH0ENRlH8s3y")```
Listen for a click on the login button and compare the result using `checkpw()`
``` r
observeEvent(input$loginbtn, {
if(input$username == credentials$username)
{
credentials$userIsAuth <<- checkpw(input$password, credentials$password)
}
else
{
showModal(modalDialog(
title = "Error",
"Incorrect username or password. please try again! (Hint: admin/admin)"
))
}
})```
---
Code created by [Epi-interactive](https://www.epi-interactive.com)
As always, our expert team is here to help if you want custom training, would like to take your dashboards to the next level or just need an urgent fix to keep things running. Just get in touch for a chat.
[https://www.epi-interactive.com/contact](https://www.epi-interactive.com/contact)