feat: kickstart basic controller

This commit is contained in:
Shivam Mishra
2025-08-27 12:27:27 +05:30
parent 572df07365
commit f9d4816db1
7 changed files with 285 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
class OmniauthController < ApplicationController
skip_before_action :verify_authenticity_token
skip_before_action :authenticate_user!
skip_before_action :set_current_user
skip_before_action :check_authorization
def request
# This will be handled by OmniAuth middleware
# The request will be redirected to the IdP
end
def callback
auth = request.env['omniauth.auth']
account_id = params[:account_id]
if auth.present?
render json: {
message: 'SAML authentication successful',
account_id: account_id,
provider: auth.provider,
uid: auth.uid,
info: {
email: auth.info.email,
name: auth.info.name,
first_name: auth.info.first_name,
last_name: auth.info.last_name
},
extra: {
raw_info: auth.extra.raw_info
}
}
else
render json: {
error: 'SAML authentication failed',
message: request.env['omniauth.error'] || 'Unknown error'
}, status: :unauthorized
end
end
def failure
render json: {
error: 'SAML authentication failed',
message: params[:message] || request.env['omniauth.error'] || 'Unknown error'
}, status: :unauthorized
end
end