Giter VIP home page Giter VIP logo

Comments (7)

PaulC91 avatar PaulC91 commented on June 1, 2024

Hi Naly, could you provide a reproducible example of how you are using this package with googleAuthR ?

There is no password caching in shinyauthr so you will always have to provide your credentials each time the app is launched.

One workaround would be to use a password manager like Dashlane and save your credentials for the app using shinyauthr. It should then automatically log you in whenever you visit the URL the app is hosted on.

from shinyauthr.

nali-raz avatar nali-raz commented on June 1, 2024

Hello Paul,

Thanks for your answer.

I think what I said was not clear.

Actually, the issues is that I have to re-enter the shinyauthr login/password during the same session.

You can see in the screenshot what's happening during the same session :

Step 1 : Login Page
screen shot 2018-11-28 at 13 54 52

**Step 2 : After Login via shinyauthr **
Succesfully logged in
screen shot 2018-11-28 at 13 57 04

Step 3 : After login with my google account (via googleAuthR)
shinyauthr asks me to enter my id and password again
screen shot 2018-11-28 at 13 58 27

Here's a reproducible example (you just have to add the google console infos)

llibrary(shiny)
library(shinyauthr)
library(shinyjs)
library(googleAuthR)

# set google console infos
options("googleAuthR.webapp.client_id" = "xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com")
options("googleAuthR.webapp.client_secret" = "xxxxxxxxxxxxxxxxxx")


options(shiny.port = 4441)

# dataframe that holds usernames, passwords and other user data
user_base <- data.frame(
  user = c("user1", "user2"),
  password = c("pass1", "pass2"), 
  permissions = c("admin", "standard"),
  name = c("User One", "User Two"),
  stringsAsFactors = FALSE
)

ui <- fluidPage(
  # must turn shinyjs on
  shinyjs::useShinyjs(),
  # add logout button UI 
  div(class = "pull-right", shinyauthr::logoutUI(id = "logout")),
  # add login panel UI function
  shinyauthr::loginUI(id = "login"),
  # setup table output to show user info after login
  conditionalPanel(
    condition = "output.authOK == 'TRUE'",
    
    tableOutput("user_table"),
    
    googleAuthUI("login")
  )
  
  
)

server <- function(input, output, session) {
  
  # call the logout module with reactive trigger to hide/show
  logout_init <- callModule(shinyauthr::logout, 
                            id = "logout", 
                            active = reactive(credentials()$user_auth))
  
  # call login module supplying data frame, user and password cols
  # and reactive trigger
  credentials <- callModule(shinyauthr::login, 
                            id = "login", 
                            data = user_base,
                            user_col = user,
                            pwd_col = password,
                            log_out = reactive(logout_init()))
  
  # pulls out the user information returned from login module
  user_data <- reactive({credentials()$info})
  
  output$user_table <- renderTable({
    # use req to only render results when credentials()$user_auth is TRUE
    req(credentials()$user_auth)
    user_data()
  })
  
  output$authOK <- renderText({
    credentials()$user_auth
  })
  
  outputOptions(output, "authOK", suspendWhenHidden = FALSE)
  
  user <- shiny::callModule(googleAuth, "login")
}

shinyApp(ui = ui, server = server)

Thanks again.

EDIT : I think that, as the googleAuthUI function sends me in another page (external to the shiny app), the user_auth value is reset to FALSE.

from shinyauthr.

PaulC91 avatar PaulC91 commented on June 1, 2024

Hi Naly, yes it looks like the googleAuthR login is resetting the user_auth value.

Is there a reason you need both a shinyauthr login as well as a googleAuthR one?

from shinyauthr.

nali-raz avatar nali-raz commented on June 1, 2024

That's right, I need both of them (actually, maybe I'll need another login, too : facebook for example). The shinyauthrone will be for the whole app, the other ones will be used inside it to extract some data from those sources.

from shinyauthr.

nali-raz avatar nali-raz commented on June 1, 2024

I think I've found a solution : instead of using googleAuthUI, I'll use googleAuth_jsUI(...), from the same package, so the google authentication will be done from a popup JS menu (so I won't be redirected at an external page).

from shinyauthr.

PaulC91 avatar PaulC91 commented on June 1, 2024

OK give that a go and let me know how it goes.

If the shinyauthr login isn't being used for any server-side processes, just simply to limit access to the app, I would suggest switching to something like Nginx authentication with shiny server: https://www.r-bloggers.com/add-authentication-to-shiny-server-with-nginx/

from shinyauthr.

nali-raz avatar nali-raz commented on June 1, 2024

Hello @PaulC91 ,

Thanks for your reply.

Nginx seems to be a good idea.

Thanks a lot.

from shinyauthr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.