aboutsummaryrefslogtreecommitdiff
path: root/app/lib/sso
diff options
context:
space:
mode:
authorIN COMMON Collective <collective@incommon.cc>2021-03-26 15:24:16 +0100
committerIN COMMON Collective <collective@incommon.cc>2021-03-26 15:24:16 +0100
commit02283fe4979ad055a20131166628a32b3c152897 (patch)
treecaaa9cb10c6b661f9055b9361392d8cfad53176e /app/lib/sso
parentc738e96b2b99bfd92b70d4cec26d6874a7f609e4 (diff)
downloadincommon-map-02283fe4979ad055a20131166628a32b3c152897.tar.gz
[DEV] WIP: explore sso login alternative
Diffstat (limited to 'app/lib/sso')
-rw-r--r--app/lib/sso/from_discourse.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/lib/sso/from_discourse.rb b/app/lib/sso/from_discourse.rb
index 94969c9..8c5eea7 100644
--- a/app/lib/sso/from_discourse.rb
+++ b/app/lib/sso/from_discourse.rb
@@ -14,12 +14,12 @@ module SSO
# This is a hash:
# SSO::FromDiscourse.config = {
# sso_url: 'https://talk.incommon.cc/session/sso_provider',
- # return_url: "#{API_ROOT_URL}/my/account",
+ # return_url: 'https://incommon-map.example/authenticate',
# sso_secret: Rails.application.credentials.sso_secret,
# }
# In config/routes.rb:
# ...
- # get 'my/account/:token' => 'authentications#sso_login'
+ # get 'authenticate/(:token)' => 'authentications#sso_login'
attr_accessor :config
end
@@ -93,5 +93,15 @@ module SSO
def mac_signature(payload = b64_payload)
OpenSSL::HMAC.hexdigest('SHA256', self.class.config[:sso_secret], payload)
end
+
+ def sso_secret
+ @sso_secret = begin
+ self.class.config[:sso_secret].presence ||
+ Rails.application.credentials.sso_secret ||
+ raise
+ rescue MissingConstant
+ raise("Missing SSO Secret! Please set `SSO::FromDiscourse.config[:sso_secret]`")
+ end
+ end
end
end