mirror of https://github.com/docusealco/docuseal
Adds omniauth_openid_connect with Clerk as the IdP, gated on CLERK_DISCOVERY_URL / CLERK_CLIENT_ID / CLERK_CLIENT_SECRET. When unset, behaves identically to upstream. Password login + 2FA preserved as fallback. Access gate (v1): email-domain allowlist via CLERK_ALLOWED_EMAIL_DOMAINS. First-time login auto-creates the User on the singleton Account with role=admin. Drops into the empty _omniauthable.html.erb partial DocuSeal already reserved in the login view.pull/688/head
parent
60082655d4
commit
ed1fbc681a
@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Users
|
||||
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
skip_before_action :verify_authenticity_token, only: [:clerk_oidc]
|
||||
|
||||
def clerk_oidc
|
||||
user = User.from_clerk_oidc(request.env['omniauth.auth'])
|
||||
|
||||
if user&.persisted?
|
||||
sign_in_and_redirect(user, event: :authentication)
|
||||
set_flash_message(:notice, :success, kind: 'Clerk') if is_navigational_format?
|
||||
else
|
||||
flash[:alert] = I18n.t('clerk_oidc_login_not_allowed',
|
||||
default: 'Sign-in not permitted for this account.')
|
||||
redirect_to new_user_session_path
|
||||
end
|
||||
end
|
||||
|
||||
def failure
|
||||
flash[:alert] = I18n.t('clerk_oidc_login_failed', default: 'Clerk sign-in failed. Please try again.')
|
||||
redirect_to new_user_session_path
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,8 @@
|
||||
<% if Docuseal.clerk_oidc_enabled? %>
|
||||
<div class="divider text-base-content/40 text-sm my-6"><%= t(:or, default: 'or') %></div>
|
||||
<%= button_to user_clerk_oidc_omniauth_authorize_path,
|
||||
data: { turbo: false },
|
||||
class: 'base-button base-button-outline w-full flex items-center justify-center gap-2' do %>
|
||||
<span><%= t(:sign_in_with_clerk, default: 'Sign in with Clerk') %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
Loading…
Reference in new issue