-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Single tenant support with Osso Mock IDP
- Loading branch information
Showing
6 changed files
with
47 additions
and
3 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
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,9 +1,46 @@ | ||
class ApplicationController < ActionController::Base | ||
before_action :authenticate_user!, except: :index | ||
|
||
before_action :authenticate_user!, only: :logged_in | ||
skip_before_action :verify_authenticity_token, only: :saml_callback | ||
|
||
def index | ||
end | ||
|
||
def logged_in | ||
end | ||
|
||
def saml_login | ||
request = OneLogin::RubySaml::Authrequest.new | ||
redirect_to(request.create(saml_settings)) | ||
end | ||
|
||
def saml_callback | ||
response = OneLogin::RubySaml::Response.new( | ||
params[:SAMLResponse], | ||
:settings => saml_settings | ||
) | ||
|
||
if response.is_valid? | ||
@user = User.create_or_find_by!(email: response.nameid) | ||
sign_in(@user) | ||
redirect_to(:logged_in) | ||
else | ||
raise response.errors.inspect | ||
end | ||
end | ||
|
||
private | ||
|
||
def saml_settings | ||
settings = OneLogin::RubySaml::Settings.new | ||
|
||
# You provide to IDP | ||
settings.assertion_consumer_service_url = "http://#{request.host_with_port}/saml_callback" | ||
settings.sp_entity_id = "my-single-tenant" | ||
|
||
# IDP provides to you | ||
settings.idp_sso_target_url = "https://idp.ossoapp.com/saml-login" | ||
settings.idp_cert = Rails.application.credentials.idp_cert | ||
|
||
settings | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
</div> | ||
<% end %> | ||
<% end %> | ||
<%= button_to 'Sign in with SAML SSO', action: :saml_login %> | ||
</div> | ||
</div> |
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 +1 @@ | ||
LoBR8TSHJK0BeDFOdfU7tlvB4G3THK2eve5Dm9vs6n2T8c72co5FJl4htY4fe8ruCh4SDwy7SiQY5IxIRPKtVdrepfX8ngUi6dmvAeG9PCdL+ED10FLYgH85d8jX96aguFcd1aOMNMpSP2S0fynJRz/jN1LzkXdBamZLkXJRMTpboiQhQkjGT8XxcoHKuPUpUIU4eqLiZKU5gnEumiUOI1EGED6i96vb5dbZeLn/FFLGWydsPdaXQ1/ezLuQcBlDNNT6ktU9Vonh0htec4FjAeE0OgdMEp1j1wIUgXqczKKE62JgYG4wOHxdLQfD5xcAfgUz3tyYMx9c/8FmICU+BC/1+rwJEqUkRKpQ5Beth88qVr0mlVj+AKwuTPjx+ttDYpOxu3F3N8DUWZBHtxs7vNOHIucRiUE+aiNu--4BKS5tyJINb9izXo--cuhyNutIIr4Mk49ha/IlrA== | ||
+m9jnjlYX6OtiMaMDZeoasxSCgwsFTclpn9iQB06meOa6vZTf7Ys1RfpwuafcBcB1zZLPHB7K50jw4Z67awKqknbTseSW9F6ECkgYKZtF5JhN1M00YO9TRGVRPf7FHS8czY3gabIoIy9YPlbgeOlHzHeKQzAnzp7voqx4JfdNixFkSEjUr4f98+NKSNdWiZkHqsl6bYBZ6QxcKb5Y9FaclkaodVZL3RCZo21dgZ+Pdt970JsbnfQqqJRetAz6inj5lffk/NpREtXx5Gh/upuiYXvyxSXnIGpu0oUfu9oR/Fdwfi83sIrhwmCHHLb1iDuPjRpFVtdgIE6nET8Sf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Cp+jTGQLCyap+Y0G4wy095hfCKclLR9Pw1Bh0dWvmH+XHJtqjmvyFDLw2ULEYxDxsU8A8kJawlU18iHmyOo3VrFpUeRhvtwHYpeEd2UPzPACCvXEvrKB52xbXEliBI/JVlK73Qab62H6WKpVr2111egGaKKR8XNoBQIkH1ZIiMv46vKvnaeGOg2ExAafP7Fg/H4dgX9r0njVw5QhdGYe+3xBPb7xsFwFQhJ3crHckFr7AEcG6qh+YW8bmFbgtm+sMoY51kp7htQlzaJTht5LxDDnA6Hny/313B+ZTsUK90A1/u/52buMafcEikI8XttmhBs/BPr1kietvmmDi6QieDMpJ4eM2nJaSdsveQFobED8vc9TOYo2XODPTylYcoskyVQsSOjP/AdgTjco4TpQAu1Nwrgng2E9zdVuf6hUll4zbApvJch2EdXQuhe+8Y7vQ/unsb/AvRt9M9HwEMkCbTdVr1hJ95A5DYZq74qBBQ5C3jbFGPegNAWj6/p6qQueyX9y00rXY2uJ4ySQAR2aLY715XUd9bTyV9jI2Gi8XLzYrAGSDi93qkZFSPMELIL+G02ngoE2uVkLwBxQ4iPpCtHHEIb2ObW+uOePk5agViwbT3VO7vJfPo/8lRqliFBA7eheZsDTt2a7pUmHjTVCQmNigJZ1vJtK44L1cI14D4Hs7yZ7VUQUBB6/N8Ind1W1SJ2g=--wdvUEmbANQOadESQ--tBIEkesbLGCOAs+TlNT6/A== |
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