From aae08c5abc44e4c3efe123922f0e60274adcfd23 Mon Sep 17 00:00:00 2001 From: andreavargasmon <53089319+andreavargasmon@users.noreply.github.com> Date: Tue, 2 Jan 2024 20:59:19 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20ixpantia?= =?UTF-8?q?/tapLock@f99ddaa765c51b57c5420e35b471eb9b508d2bd2=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 404.html | 16 +- LICENSE-text.html | 15 +- LICENSE.html | 17 +- articles/en_securing_shiny_google.html | 215 ++++++++++++++++++++++ articles/es_asegura_shiny_con_google.html | 215 ++++++++++++++++++++++ articles/index.html | 77 ++++++++ authors.html | 20 +- index.html | 28 ++- pkgdown.yml | 6 +- reference/access_token.html | 17 +- reference/build_cookie.html | 17 +- reference/build_redirect_uri.html | 17 +- reference/decode_token.html | 17 +- reference/expires_at.html | 17 +- reference/expires_in.html | 17 +- reference/get_access_token.html | 17 +- reference/get_bearer.html | 17 +- reference/get_client_id.html | 17 +- reference/get_login_url.html | 17 +- reference/get_logout_url.html | 17 +- reference/get_token_field.html | 17 +- reference/index.html | 15 +- reference/is_expired.html | 17 +- reference/is_valid.html | 17 +- reference/new_openid_config.html | 17 +- reference/parse_cookies.html | 17 +- reference/print.access_token.html | 17 +- reference/refresh_jwks.html | 17 +- reference/remove_bearer.html | 17 +- reference/request_token.html | 17 +- reference/sso_shiny_app.html | 17 +- reference/token.html | 17 +- search.json | 2 +- sitemap.xml | 9 + 34 files changed, 951 insertions(+), 58 deletions(-) create mode 100644 articles/en_securing_shiny_google.html create mode 100644 articles/es_asegura_shiny_con_google.html create mode 100644 articles/index.html diff --git a/404.html b/404.html index e27847d..a8cf119 100644 --- a/404.html +++ b/404.html @@ -35,13 +35,27 @@ - + diff --git a/LICENSE-text.html b/LICENSE-text.html index 8a25afb..6bdb7cd 100644 --- a/LICENSE-text.html +++ b/LICENSE-text.html @@ -20,11 +20,24 @@ + diff --git a/LICENSE.html b/LICENSE.html index f0a32f0..43bd5be 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -20,11 +20,24 @@ + @@ -32,7 +45,7 @@
diff --git a/articles/en_securing_shiny_google.html b/articles/en_securing_shiny_google.html new file mode 100644 index 0000000..2ecc61b --- /dev/null +++ b/articles/en_securing_shiny_google.html @@ -0,0 +1,215 @@ + + + + + + + + +(English) Securing Shiny with Google Auth • tapLock + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + +
+

Introduction +

+

This vignette provides a step-by-step tutorial on how to secure a +Shiny application using Google authentication through the tapLock R +package. tapLock simplifies the integration of OpenID Connect and OAuth +2.0 into Shiny applications, ensuring robust security with minimal +coding effort.

+
+
+

Prerequisites +

+

Before proceeding, ensure you have the following: - A basic +understanding of R and Shiny. - A Shiny application ready for +deployment. - Access to Google Developer Console for OAuth credentials. +- (Optional) A server with HTTPS enabled.

+
+
+

Step 1: Install tapLock +

+

Install tapLock from GitHub using the pak package:

+
+pak::pak("ixpantia/taplock")
+
+
+

Step 2: Create Google OAuth Credentials +

+
    +
  1. Go to the Google +Developer Console.
  2. +
  3. Create a new project or select an existing one.
  4. +
  5. Navigate to ‘Credentials’ and create ‘OAuth client ID’ +credentials.
  6. +
  7. Set the Authorized JavaScript origins +to your Shiny application URL.
  8. +
  9. Set the Authorized redirect URIs to +your Shiny application URL with the suffix /login.
  10. +
  11. Note down the client_id and +client_secret.
  12. +
+
+
+

Step 3: Configure Authentication in R +

+

Load tapLock and set up the authentication configuration:

+
+library(taplock)
+
+auth_config <- new_openid_config(
+  provider = "google",
+  client_id = Sys.getenv("GOOGLE_CLIENT_ID"),
+  client_secret = Sys.getenv("GOOGLE_CLIENT_SECRET"),
+  app_url = Sys.getenv("SHINY_APP_URL")
+)
+

Replace GOOGLE_CLIENT_ID, +GOOGLE_CLIENT_SECRET, and SHINY_APP_URL with +your actual credentials and application URL in your environment +variables.

+
+
+

Step 4: Modify Shiny Application +

+

Modify your Shiny app to use sso_shiny_app:

+
+library(shiny)
+library(tapLock)
+
+# Authentication configuration
+auth_config <- new_openid_config(
+  provider = "google",
+  client_id = Sys.getenv("GOOGLE_CLIENT_ID"),
+  client_secret = Sys.getenv("GOOGLE_CLIENT_SECRET"),
+  app_url = Sys.getenv("SHINY_APP_URL")
+)
+
+# UI
+ui <- fluidPage(
+  tags$h1("Welcome to the Secure Shiny App"),
+  textOutput("userInfo")
+)
+
+# Server
+server <- function(input, output, session) {
+  output$userInfo <- renderText({
+    user_email <- get_token_field(token(), "email")
+    glue::glue("Logged in as: {user_email}")
+  })
+}
+
+# Secure Shiny app with tapLock
+sso_shiny_app(auth_config, ui, server)
+
+
+

Step 5: Deploy the Application +

+

Deploy your Shiny application as you normally would. The tapLock +package handles the authentication process. We recommend deploying your +application with a solution like Shiny Server (Open Source or Pro) or +with Faucet. +Solutions like Posit Connect already include authentication and do not +require tapLock.

+
+
+

Conclusion +

+

By following these steps, you have successfully secured your Shiny +application with Google authentication using tapLock. This ensures that +only authenticated users can access your application, enhancing its +security and privacy.

+
+
+
+ + + +
+ + + +
+
+ + + + + + + diff --git a/articles/es_asegura_shiny_con_google.html b/articles/es_asegura_shiny_con_google.html new file mode 100644 index 0000000..8f58969 --- /dev/null +++ b/articles/es_asegura_shiny_con_google.html @@ -0,0 +1,215 @@ + + + + + + + + +(Español) Asegurando Shiny con Google Auth • tapLock + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + +
+

Introducción +

+

Esta viñeta proporciona un tutorial paso a paso sobre cómo asegurar +una aplicación Shiny utilizando la autenticación de Google a través del +paquete R tapLock. tapLock simplifica la integración de OpenID Connect y +OAuth 2.0 en aplicaciones Shiny, asegurando una robusta seguridad con un +esfuerzo mínimo de codificación.

+
+
+

Prerrequisitos +

+

Antes de proceder, asegúrate de tener lo siguiente: - Un conocimiento +básico de R y Shiny. - Una aplicación Shiny lista para ser desplegada. - +Acceso a Google Developer Console para las credenciales OAuth. - +(Opcional) Un servidor con HTTPS habilitado.

+
+
+

Paso 1: Instalar tapLock +

+

Instala tapLock desde GitHub usando el paquete pak:

+
+pak::pak("ixpantia/taplock")
+
+
+

Paso 2: Crear Credenciales OAuth de Google +

+
    +
  1. Ve a Google +Developer Console.
  2. +
  3. Crea un nuevo proyecto o selecciona uno existente.
  4. +
  5. Navega a ‘Credenciales’ y crea credenciales ‘OAuth client ID’.
  6. +
  7. Establece los +Authorized JavaScript origins en la URL de +tu aplicación Shiny.
  8. +
  9. Establece los Authorized redirect URIs +en la URL de tu aplicación Shiny con el sufijo /login.
  10. +
  11. Anota el client_id y el +client_secret.
  12. +
+
+
+

Paso 3: Configurar Autenticación en R +

+

Carga tapLock y configura la autenticación:

+
+library(taplock)
+
+auth_config <- new_openid_config(
+  provider = "google",
+  client_id = Sys.getenv("GOOGLE_CLIENT_ID"),
+  client_secret = Sys.getenv("GOOGLE_CLIENT_SECRET"),
+  app_url = Sys.getenv("SHINY_APP_URL")
+)
+

Reemplaza GOOGLE_CLIENT_ID, +GOOGLE_CLIENT_SECRET, y SHINY_APP_URL con tus +credenciales reales y la URL de tu aplicación en tus variables de +entorno.

+
+
+

Paso 4: Modificar Aplicación Shiny +

+

Modifica tu aplicación Shiny para usar +sso_shiny_app:

+
+library(shiny)
+library(tapLock)
+
+# Configuración de autenticación
+auth_config <- new_openid_config(
+  provider = "google",
+  client_id = Sys.getenv("GOOGLE_CLIENT_ID"),
+  client_secret = Sys.getenv("GOOGLE_CLIENT_SECRET"),
+  app_url = Sys.getenv("SHINY_APP_URL")
+)
+
+# UI
+ui <- fluidPage(
+  tags$h1("Bienvenido a la Aplicación Shiny Segura"),
+  textOutput("userInfo")
+)
+
+# Server
+server <- function(input, output, session) {
+  output$userInfo <- renderText({
+    user_email <- get_token_field(token(), "email")
+    glue::glue("Conectado como: {user_email}")
+  })
+}
+
+# Asegurar aplicación Shiny con tapLock
+sso_shiny_app(auth_config, ui, server)
+
+
+

Paso 5: Desplegar la Aplicación +

+

Despliega tu aplicación Shiny como lo harías normalmente. El paquete +tapLock maneja el proceso de autenticación. Recomendamos desplegar tu +aplicación con una solución como Shiny Server (Open Source o Pro) o con +Faucet. Soluciones +como Posit Connect ya incluyen autenticación y no requieren tapLock.

+
+
+

Conclusión +

+

Siguiendo estos pasos, has asegurado con éxito tu aplicación Shiny +con autenticación de Google utilizando tapLock. Esto asegura que solo +los usuarios autenticados puedan acceder a tu aplicación, mejorando su +seguridad y privacidad.

+
+
+
+ + + +
+ + + +
+
+ + + + + + + diff --git a/articles/index.html b/articles/index.html new file mode 100644 index 0000000..c3c6a81 --- /dev/null +++ b/articles/index.html @@ -0,0 +1,77 @@ + +Articles • tapLock + Skip to contents + + +
+ + + +
+ + + +
+ + + + + + + diff --git a/authors.html b/authors.html index 39b3529..ae9adca 100644 --- a/authors.html +++ b/authors.html @@ -20,11 +20,24 @@ +
@@ -49,17 +62,18 @@

Authors

Citation

-

+

Source: DESCRIPTION

Quintero A (2024). tapLock: Seamless SSO for R applications. -R package version 0.1.0. +R package version 0.1.0, https://github.com/ixpantia/tapLock.

@Manual{,
   title = {tapLock: Seamless SSO for R applications},
   author = {Andres Quintero},
   year = {2024},
   note = {R package version 0.1.0},
+  url = {https://github.com/ixpantia/tapLock},
 }