Add OAuth2 authentication (#147)

- Added Site settings > Authentication section
- Create/edit/delete your custom oauth2 configurations
- Login or signup with oauth2
This commit is contained in:
Riccardo Graziosi
2022-08-05 18:15:17 +02:00
committed by GitHub
parent 3bda6dee08
commit 4c73b398e8
65 changed files with 2096 additions and 129 deletions

View File

@@ -40,6 +40,17 @@
<div class="actions">
<%= f.submit t('common.forms.auth.sign_up'), class: "btn btn-dark btn-block" %>
</div>
<hr />
<% if not @o_auths.empty? %>
<% @o_auths.each do |o_auth| %>
<p>
<%= link_to t('common.forms.auth.sign_up_with', { o_auth: o_auth.name }),
o_auth_start_path(o_auth, reason: 'user') %>
</p>
<% end %>
<% end %>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -29,6 +29,17 @@
<div class="actions">
<%= f.submit t('common.forms.auth.log_in'), class: "btn btn-dark btn-block" %>
</div>
<hr />
<% if not @o_auths.empty? %>
<% @o_auths.each do |o_auth| %>
<p>
<%= link_to t('common.forms.auth.log_in_with', { o_auth: o_auth.name }),
o_auth_start_path(o_auth, reason: 'user') %>
</p>
<% end %>
<% end %>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<title><%= t('site_settings.authentication.test_page.title', { name: @o_auth.name }) %></title>
</head>
<body>
<h1><%= t('site_settings.authentication.test_page.title', { name: @o_auth.name }) %></h1>
<div>
<h2><%= t('site_settings.authentication.test_page.fetched_user_data') %></h2>
<pre><%= JSON.pretty_generate(@user_profile, { indent: " ", object_nl: "\n" }) %></pre>
</div>
<div>
<h2><%= t('activerecord.attributes.user.email') %> <%= @email_valid ? "✅" : "❌" %></h2>
<ul>
<li><b><%= t('site_settings.authentication.form.jsonUserEmailPath') %>:</b> <%= @o_auth.json_user_email_path %></li>
<li><b><%= t('site_settings.authentication.test_page.found') %>:</b> <%= @user_email %></li>
</ul>
</div>
<div>
<h2><%= t('activerecord.attributes.user.full_name') %> <%= @name_valid ? "✅" : "⚠️" %></h2>
<ul>
<li><b><%= t('site_settings.authentication.form.jsonUserNamePath') %>:</b> <%= @o_auth.json_user_name_path %></li>
<li><b><%= t('site_settings.authentication.test_page.found') %>:</b> <%= @user_name %></li>
</ul>
</div>
<div>
<h2><%= t('site_settings.authentication.test_page.summary') %> <%= !@email_valid ? "❌" : !@name_valid ? "⚠️" : "✅" %></h2>
<% if @email_valid and @name_valid %>
<p><%= t('site_settings.authentication.test_page.valid_configuration') %></p>
<% end %>
<% if @email_valid and not @name_valid %>
<p><%= t('site_settings.authentication.test_page.warning_configuration', { name: t('defaults.user_full_name') }) %></p>
<% end %>
<% if not @email_valid %>
<p><%= t('site_settings.authentication.test_page.invalid_configuration') %></p>
<% end %>
</div>
</body>
</html>

View File

@@ -5,6 +5,7 @@
<div class="verticalNavigation" role="tablist" aria-orientation="vertical">
<% if current_user.admin? %>
<%= render 'menu_link', label: t('site_settings.menu.general'), path: site_settings_general_path %>
<%= render 'menu_link', label: t('site_settings.menu.authentication'), path: site_settings_authentication_path %>
<%= render 'menu_link', label: t('site_settings.menu.boards'), path: site_settings_boards_path %>
<%= render 'menu_link', label: t('site_settings.menu.post_statuses'), path: site_settings_post_statuses_path %>
<%= render 'menu_link', label: t('site_settings.menu.roadmap'), path: site_settings_roadmap_path %>

View File

@@ -0,0 +1,13 @@
<div class="twoColumnsContainer">
<%= render 'menu' %>
<div>
<%=
react_component(
'SiteSettings/Authentication',
{
authenticityToken: form_authenticity_token
}
)
%>
</div>
</div>