knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
{shiny.AADB2C} is designed to help you get started with integration Azure Active Directory B2C authentication into your shiny application.
library(shiny.AADB2C)
aadb2c_js()The first required component is the JavaScript code that uses the msal.js library to authenticate a user via a popup.
Most of the code you might want to modify to manage buttons and shiny communication happen in the updateUI() function. There are instructions to show and hide "Sign In" and "Sign Out" buttons and pass a piece of information when authenticated to shiny as an input.
aadb2c_js( output_dir = "inst/app/www", shiny_input = "email", tenant = "demotenant", client_id = "a0cfc440-c766-43db-9ea8-40a1efbe22ac", signin_policy = "B2C_1_signup_signin", scopes = c("email","openid", "https://demotenant.onmicrosoft.com/appname/read" )
To configure the JS script, you need the following pieces of information:
You will want to use your browsers developer tools to help you get any error mesages you might encounter. The scopes in particular can be pesky!
You may also want to / need to provide further configuration details. This documentation can be found at docs.microsoft.com/.../msal-client-application-configuration
Included in this package are functions providing some basic code to demonstrate the minimum needed to provide login functionality and do something based on the authentication.
aadb2c_ui()
This includes how to:
aadb2c_js()shiny::addResourcePath()It's provided in a tagList but the individual functions can be included in a general UI object.
aadb2c_server()
This is pretty simple - it merely translates the input created in the msal.js when someone successfully authenticates into a text output. This code snippet can be added to the server() function.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.