Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use shinymanager with reCaptcha? #141

Open
RafaelEduardoDiaz opened this issue May 11, 2022 · 1 comment
Open

How to use shinymanager with reCaptcha? #141

RafaelEduardoDiaz opened this issue May 11, 2022 · 1 comment

Comments

@RafaelEduardoDiaz
Copy link

I'm using shinymanager in conjunction with reCaptcha V3, however I can't get it to work properly. My goal is to display the credentials of the user who logged in.

# define some credentials
credentials <- data.frame(user = "shiny", password = "1", start = "2019-04-15", expire = NA, admin = FALSE, stringsAsFactors = FALSE)

library(shiny)
library(shinymanager)
library(shinyjs)
library(shinygCAPTCHAv3)

ui <- fluidPage(
  useShinyjs(),
  GreCAPTCHAv3Ui(siteKey = "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","homepage","responseReceived"),
  tags$h2("My secure application"),
  verbatimTextOutput("auth_output")
)

ui <- secure_app(ui, fab_position = "bottom-left")

server <- function(input, output, session) {
  res_auth <- secure_server(check_credentials = check_credentials(credentials))
  observeEvent(input$responseReceived,{
    result <- GreCAPTCHAv3Server(secretKey = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe",input$responseReceived)
    if(result$success){
      output$auth_output <- renderPrint({reactiveValuesToList(res_auth)})
      }
  })
}

shinyApp(ui, server)

Expected output

image

@RafaelEduardoDiaz RafaelEduardoDiaz changed the title [email protected] How to use shinymanager with reCaptcha? May 11, 2022
@sciordia
Copy link

Hello Rafael,

Have you managed to successfully incorporate reCaptcha in Shinymanager?. I've tried to do it too but I can't get it to work properly.

I've used your code as a base but the first thing I've seen is that if you run your example the reCaptcha(v3) appears in the UI after confirming the credentials. To avoid the attack by bots, shouldn't recaptcha be loaded in the login page? After that I don't think it makes sense.

I hope you can help me.

Thank you very much for your example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants