-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
764dd5a
commit 55d19cf
Showing
6 changed files
with
28 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 26 additions & 6 deletions
32
app/controllers/core_data_connector/authentication_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
require 'typhoeus' | ||
|
||
module CoreDataConnector | ||
class AuthenticationController < ApplicationController | ||
# No user authentication | ||
skip_before_action :authenticate_request | ||
before_action :bypass_authorization | ||
def login | ||
base_url = 'https://keycloak.archivengine.com/realms/core-data/protocol/openid-connect/token' | ||
|
||
puts 'hi' | ||
form_data = { | ||
code: request.params['code'], | ||
client_id: ENV['SSO_CLIENT_ID'], | ||
client_secret: ENV['SSO_CLIENT_SECRET'], | ||
grant_type: 'authorization_code', | ||
redirect_uri: request.original_url.split('?')[0] | ||
} | ||
|
||
def login | ||
render json: { motd: 'hello' } | ||
token_req = Typhoeus::Request.new( | ||
base_url, | ||
headers: {'Content-Type'=> "application/x-www-form-urlencoded"}, | ||
method: :post, | ||
body: form_data | ||
) | ||
|
||
token_res = token_req.run | ||
|
||
puts token_res.body | ||
|
||
# backend authentication logic goes here | ||
|
||
# redirect_to ENV['SSO_REDIRECT_URL'] | ||
render json: token_res.body | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters