From 48031dde29d6dc4a0ba84c445ae4c07627257d4a Mon Sep 17 00:00:00 2001 From: hellekin Date: Mon, 5 Oct 2020 21:51:37 +0200 Subject: Configure Discourse SSO We're creating a minimal User model that will be filled from SSO. We also configure Inflections so we can use SSO instead of Sso which looks weird for a module named after an acronym. Use Discourse as SSO: https://meta.discourse.org/t/using-discourse-as-a-sso-provider/32974 --- config/initializers/inflections.rb | 6 ++++++ config/initializers/session_store.rb | 6 ++++++ config/initializers/sso_config.rb | 2 ++ 3 files changed, 14 insertions(+) create mode 100644 config/initializers/session_store.rb (limited to 'config') diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ac033bf..13e8739 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -14,3 +14,9 @@ # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end + +ActiveSupport::Inflector.inflections do |inflect| + inflect.irregular 'human', 'humans' + inflect.acronym 'API' + inflect.acronym 'SSO' +end diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 0000000..4af1519 --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,6 @@ +if Rails.env.production? + # Only serve session cookies over HTTPS + Rails.application.config.session_store :cookie_store, key: 'map_session', expire_after: 7.days, httponly: true, secure: true +else + Rails.application.config.session_store :cookie_store, key: 'map_session', expire_after: 7.days +end diff --git a/config/initializers/sso_config.rb b/config/initializers/sso_config.rb index b3f23f7..f5413ff 100644 --- a/config/initializers/sso_config.rb +++ b/config/initializers/sso_config.rb @@ -9,6 +9,8 @@ # end # end +require 'sso/from_discourse' + SSO::FromDiscourse.config = { sso_url: 'https://talk.incommon.cc/session/sso_provider', return_url: "http://localhost:3000/authenticate", -- cgit v1.2.3