<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/user-authentication-in-r-shiny-sneak-peek-of-shiny-users-and-shiny-admin-packages/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://appsilondatascience.com/blog/rstats/2018/05/30/user-authentication-in-r-shiny.html"> Appsilon Data Science Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>At Appsilon we frequently build advanced R/Shiny dashboards that need user authentication. I would like to share with you how we implement user management – user accounts, the authorization process and gather usage statistics to have a better understanding of how the app is used.</p>
<p>For user authentication, we created the <strong>shiny.users</strong> package. For user administration and usage statistics, we created the <strong>shiny.admin</strong> package. We will show you a sneak peek of how these packages work. They are not released yet – but we opened an <a rel="nofollow" href="https://go.appsilondatascience.com/shiny.users/" target="_blank">Early Adopter Waitlist</a> – sign up and we will contact you as soon as these packages will be ready for production testing!</p>
<h2>Shiny.users – convenient authentication on the application level</h2>
<p>Here is an example of how shiny.users works when you add it to your shiny application:</p>
<p><img src="https://i2.wp.com/appsilondatascience.com/blog/assets/article_images/shiny.users/demo.gif?w=50%25" data-recalc-dims="1"></p>
<p>Below you can view the code of this example:</p>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>shiny</span><span>)</span><span>
</span><span>library</span><span>(</span><span>shiny.users</span><span>)</span><span>
</span><span>demo_users</span><span> </span><span>&lt;-</span><span> </span><span>list</span><span>(</span><span>
</span><span>list</span><span>(</span><span>
</span><span>username</span><span> </span><span>=</span><span> </span><span>&quot;demo-appsilon&quot;</span><span>,</span><span> </span><span>password</span><span> </span><span>=</span><span> </span><span>&quot;QZt85C46Ab&quot;</span><span>,</span><span> </span><span>roles</span><span> </span><span>=</span><span> </span><span>list</span><span>(</span><span>&quot;basic&quot;</span><span>,</span><span> </span><span>&quot;admin&quot;</span><span>)</span><span>
</span><span>),</span><span>
</span><span>list</span><span>(</span><span>
</span><span>username</span><span> </span><span>=</span><span> </span><span>&quot;john&quot;</span><span>,</span><span> </span><span>password</span><span> </span><span>=</span><span> </span><span>&quot;C4SRx3xJcy&quot;</span><span>,</span><span> </span><span>roles</span><span> </span><span>=</span><span> </span><span>list</span><span>(</span><span>&quot;basic&quot;</span><span>)</span><span>
</span><span>)</span><span>
</span><span>)</span><span>
</span><span>ui</span><span> </span><span>&lt;-</span><span> </span><span>shinyUI</span><span>(</span><span>fluidPage</span><span>(</span><span>
</span><span>div</span><span>(</span><span>class</span><span> </span><span>=</span><span> </span><span>&quot;container&quot;</span><span>,</span><span> </span><span>style</span><span> </span><span>=</span><span> </span><span>&quot;padding: 4em&quot;</span><span>,</span><span>
</span><span>login_screen_ui</span><span>(</span><span>'login_screen'</span><span>),</span><span>
</span><span>uiOutput</span><span>(</span><span>&quot;authorized_content&quot;</span><span>)</span><span>
</span><span>)</span><span>
</span><span>))</span><span>
</span><span>server</span><span> </span><span>&lt;-</span><span> </span><span>shinyServer</span><span>(</span><span>function</span><span>(</span><span>input</span><span>,</span><span> </span><span>output</span><span>)</span><span> </span><span>{</span><span>
</span><span>users</span><span> </span><span>&lt;-</span><span> </span><span>initialize_users</span><span>(</span><span>demo_users</span><span>)</span><span>
</span><span>callModule</span><span>(</span><span>login_screen</span><span>,</span><span> </span><span>'login_screen'</span><span>,</span><span> </span><span>users</span><span>)</span><span>
</span><span>output</span><span>$</span><span>authorized_content</span><span> </span><span>&lt;-</span><span> </span><span>renderUI</span><span>({</span><span>
</span><span>if</span><span> </span><span>(</span><span>!</span><span>is.null</span><span>(</span><span>users</span><span>$</span><span>user</span><span>())</span><span> </span><span>{</span><span>
</span><span>...</span><span> </span><span># application content
</span><span> </span><span>}</span><span>
</span><span>})</span><span>
</span><span>})</span><span>
</span><span>shinyApp</span><span>(</span><span>ui</span><span>,</span><span> </span><span>server</span><span>)</span></code></pre>
</figure>
<p>This is a simple demo with users defined in a list. In a real-world scenario, you would store user credentials in a database or authenticate users with an external API. This is also covered in shiny.users.</p>
<p>In bigger apps with more users, you will also need user management, authorization management (different roles e.g. admin, writer, reader, etc) and usage statistics. For such advanced use cases, we created <strong>shiny.admin</strong> package.</p>
<h2>Shiny.admin – user management and usage statistics</h2>
<p>This package is an extension to the shiny.users package. When you add it to your Shiny app, you instantly get admin panel under the url <code>http://application-url/#!/admin</code>. This panel is only accessible by the users with “admin” role.</p>
<p>Features of shiny.admin:</p>
<ul>
<li>Adding and removing users</li>
<li>Managing existing users – their passwords, roles and metadata</li>
<li>Statistics – counting unique users and sessions (similar to Google Analytics)</li>
<li>Session recording – recording defined actions e.g. provided input values and clicked elements. You can view all sessions details (similar to <a rel="nofollow" href="https://www.hotjar.com/" target="_blank">Hotjar</a>)</li>
</ul>
<p>We observed huge gains from above features. We exactly understood how our apps were used by our users. Here are some screenshots from shiny.admin:</p>
<p><img src="https://i0.wp.com/appsilondatascience.com/blog/assets/article_images/shiny.users/shinyadmin.jpg?w=100%25" data-recalc-dims="1"></p>
<p><img src="https://i1.wp.com/appsilondatascience.com/blog/assets/article_images/shiny.users/shinyadmin2.jpg?w=100%25" data-recalc-dims="1"></p>
<p>I hope you like the idea of shiny.users and shiny.admin packages. Let us know what would you expect from user accounts and admin panel features. Do you think there is a need for developing such packages? Tell us about your use cases and needs in the comments or contact us at dev@appsilondatascience.com.</p>
<p>Also, don’t forget to sign up to <a rel="nofollow" href="https://go.appsilondatascience.com/shiny.users/" target="_blank">shiny.users and shiny.admin waitlist!</a></p>
<div>
<a rel="nofollow" href="https://go.appsilondatascience.com/shiny.users/" target="_blank"><br>
<br>
</a>
</div>
<p>Read the original post at<br>
<a rel="nofollow" href="http://appsilondatascience.com/blog/rstats/2018/05/30/user-authentication-in-r-shiny.html" target="_blank">Appsilon Data Science Blog</a>.</p>
<h3>Follow Appsilon Data Science</h3>
<ul>
<li><a rel="nofollow" href="https://twitter.com/appsilonds" target="_blank">Follow us</a> on Twitter!</li>
<li>Check us out on <a rel="nofollow" href="https://www.facebook.com/appsilon.poland/" target="_blank">Facebook page</a>!</li>
<li>Follow us on <a rel="nofollow" href="https://www.linkedin.com/company/3516349/" target="_blank">LinkedIn</a>!</li>
<li>Star our <a rel="nofollow" href="https://github.com/Appsilon/" target="_blank">GitHub packages</a>, including <code>shiny.semantic</code>, <code>shiny.router</code>, <code>shiny.collections</code>, <code>shiny.i18n</code> and <code>semantic.dashboard</code>!</li>
<li>Sign up for <a rel="nofollow" href="https://appsilondatascience.com/scrum-in-data-science" target="_blank">our newsletter</a> and get free e-book!</li>
</ul>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://appsilondatascience.com/blog/rstats/2018/05/30/user-authentication-in-r-shiny.html"> Appsilon Data Science Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/zydHEdTuWws" height="1"></a></div>