mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
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:
committed by
GitHub
parent
3bda6dee08
commit
4c73b398e8
30
app/models/o_auth.rb
Normal file
30
app/models/o_auth.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
class OAuth < ApplicationRecord
|
||||
include TenantOwnable
|
||||
include ApplicationHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
attr_accessor :state
|
||||
|
||||
validates :name, presence: true, uniqueness: { scope: :tenant_id }
|
||||
validates :is_enabled, inclusion: { in: [true, false] }
|
||||
validates :client_id, presence: true
|
||||
validates :client_secret, presence: true
|
||||
validates :authorize_url, presence: true
|
||||
validates :token_url, presence: true
|
||||
validates :profile_url, presence: true
|
||||
validates :scope, presence: true
|
||||
validates :json_user_email_path, presence: true
|
||||
|
||||
def callback_url
|
||||
add_subdomain_to(method(:o_auth_callback_url), id)
|
||||
end
|
||||
|
||||
def authorize_url_with_query_params
|
||||
"#{authorize_url}?"\
|
||||
"response_type=code&"\
|
||||
"client_id=#{client_id}&"\
|
||||
"redirect_uri=#{callback_url()}&"\
|
||||
"scope=#{scope}&"\
|
||||
"state=#{state}"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user