-
Notifications
You must be signed in to change notification settings - Fork 26
Assume Viewer Credentials when running on Connect #384
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
Comments
In |
Random thought: perhaps this will need to be implemented as "When |
Proposals to simplify usage and make visitor auth feel more "default" on Connect. tl;dr: If the As currently implementedRequires that the user explicitly pass in the token header. Even I, the person who wrote it, don't remember what the header is called. library(shiny)
library(connectapi)
library(glue)
ui <- fluidPage(
textOutput("who_am_i")
)
server <- function(input, output, session) {
# Visitor authenticated client when running on Connect
token <- session$request$HTTP_POSIT_CONNECT_USER_SESSION_TOKEN
client <- connect(token = token)
me <- client$me()
output$who_am_i <- renderText(
glue("Authenticated as {me$first_name} {me$last_name} ({me$email})")
)
}
shinyApp(ui, server) Proposal: Automatically get the session when in a reactive contextIn Shiny, there's already a pattern of function, such as Using this, we could have library(shiny)
library(connectapi)
library(glue)
ui <- fluidPage(
textOutput("who_am_i")
)
server <- function(input, output, session) {
# Visitor authenticated client when running on Connect
client <- connect()
me <- client$me()
output$who_am_i <- renderText(
glue("Authenticated as {me$first_name} {me$last_name} ({me$email})")
)
}
shinyApp(ui, server) If we don't want this behavior, we could still improve the user experience by just requiring users to pass in the NotesThis doesn't solve other R contexts on Connect — it doesn't get us anything in R Markdown or Quarto documents, or in |
💯 yeah, I'm all for implementing this even if it's just interesting in the shiny context. Also, FWIW, there isn't a concept of a visitor API key on rendered content like Quarto or R Markdown (modulo those being run with shiny runtime), since they are rendered once and then the rendering is shared with whoever visits. |
Awesome, I'll do it this week! Yeah, I was wondering if it made sense to think about this in the context of Plumber APIs. Probably conceptually it works (whoever's API key is authenticating the request, show them the data that key has access to), but definitely less critical. Off the top of my head, I think it'd be pretty hacky to get the request, and idk if it'd even be possible if it wasn't provided as an argument in an endpoint's definition. |
The general expectation when running applications on Connect is that the application is running using the visitor's credentials. This is not the current behavior. Instead,
connectapi
uses theCONNECT_API_KEY
variable, which belongs to the content owner, not the visitor.Therefore, the default behavior should be as follows:
When running on Connect, assume that a visitor integration is configured. If the integration is not set, provide a sensible error message that directs the user to create the integration or explicitly overrides this behavior. When the integration is set, it assumes the visitor's credentials via the HTTP header.
When running off Connect, assume the current behavior (e.g.,
CONNECT_API_KEY
is set).(Sibling issue to posit-dev/posit-sdk-py#398)
The text was updated successfully, but these errors were encountered: