You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using now including my LDAP login app/misc/rodauth_ldap.rb.disabilitato to get the jwt with
module RodauthLdap
def require_bcrypt?
false
end
# I re-define the password_match? method so it uses LDAP
def password_match?(password)
user_exist_in_ldap?(account[:email], password)
end
def user_exist_in_ldap?(email, password)
...
end
and it works perfectly.
Now we need to enable SSO with Authentik ... so to be able to remove the LDAP login: and it looks to me that this could be a way:
So, you need an OmniAuth strategy for Authentik. I couldn't find one on GitHub, so you might need to write one yourself. If it supports OAuth2, it would be based off of omniauth-oauth2; see other OAuth2-based strategies for inspiration.
So, you just need to integrate Authentik with OmniAuth, and it then should automatically work with rodauth-omniauth. BTW, you don't need the omniauth-rails_csrf_protection gem, rodauth-omniauth already handles CSRF protection for you (it calls Rodauth's CSRF protection, which rodauth-rails overrides to call Rails' CSRF protection).
require 'omniauth-oauth2'
# https://github.com/omniauth/omniauth-oauth2
module OmniAuth
module Strategies
class Authentik < OmniAuth::Strategies::OAuth2
option :name, "authentik"
option :client_options, {}
uid { raw_info['sub'] }
info do
{
email: raw_info['email'],
name: raw_info['name']
}
end
extra do
{ raw_info: raw_info }
end
def raw_info
@raw_info ||= access_token.get('/application/o/userinfo/').parsed
end
end
end
end
class CreateUserIdentities < ActiveRecord::Migration[5.2]
def change
create_table :user_identities do |t|
t.references :user, null: false, foreign_key: { on_delete: :cascade }
t.string :provider, null: false
t.string :email, null: false
t.timestamps
t.index %i[provider email], unique: true
end
end
end
@janko I see I need to add that t.timestamps in my Rails 5.2, maybe it's added automatically in latest Rails version, but if not I guess it's missing in the README
This discussion was converted from issue #24 on November 17, 2024 13:37.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
We are struggling understanding how I can enable SSO with Authentik in my Ruby on Rails application.
My Ruby on Rails works perfectly with your gems (thanks!):
I'm using now including my LDAP login
app/misc/rodauth_ldap.rb.disabilitato
to get the jwt withand it works perfectly.
Now we need to enable SSO with Authentik ... so to be able to remove the LDAP login: and it looks to me that this could be a way:
Authentik supports both generic OAuth2 as well as OpenID Connect.
Are we taking a solution that makes sense?
Beta Was this translation helpful? Give feedback.
All reactions