diff --git a/config/config.example.yml b/config/config.example.yml index 47a17c4f..92180620 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -562,6 +562,15 @@ log: #enable_single_sign_out: true +##### SERVICES ################################################################# + +# The default service is used when no service is passed in the request + +# This is not part of the CAS specification. If no defualt service is set, and +# no service is passed in the request, behaviour is per the CAS specification. + +#default_service: 'https://au.edu.burnet.launchpad.dev/people/service' + ##### OTHER #################################################################### # You can set various ticket expiry times (specify the value in seconds). diff --git a/lib/casserver/server.rb b/lib/casserver/server.rb index 12d1f756..9a70bf98 100644 --- a/lib/casserver/server.rb +++ b/lib/casserver/server.rb @@ -310,7 +310,7 @@ def self.init_database! headers['Expires'] = (Time.now - 1.year).rfc2822 # optional params - @service = clean_service_url(params['service']) + @service = clean_service_url(params['service']) || settings.config[:default_service] @renew = params['renew'] @gateway = params['gateway'] == 'true' || params['gateway'] == '1' @@ -400,7 +400,7 @@ def self.init_database! Utils::log_controller_action(self.class, params) # 2.2.1 (optional) - @service = clean_service_url(params['service']) + @service = clean_service_url(params['service']) || settings.config[:default_service] # 2.2.2 (required) @username = params['username'] @@ -516,7 +516,8 @@ def self.init_database! # "logout" page, we take the user back to the login page with a "you have been logged out" # message, allowing for an opportunity to immediately log back in. This makes it # easier for the user to log out and log in as someone else. - @service = clean_service_url(params['service'] || params['destination']) + @service = clean_service_url(params['service']) + @destination = params['destination'] @continue_url = params['url'] @gateway = params['gateway'] == 'true' || params['gateway'] == '1' @@ -559,10 +560,12 @@ def self.init_database! @lt = generate_login_ticket - if @gateway && @service + if @gateway && @destination + redirect @destination, 303 + elsif @gateway && @service redirect @service, 303 elsif @continue_url - render @template_engine, :logout + render @template_engine, :login else render @template_engine, :login end