Module: GovukPersonalisation::Urls
- Defined in:
- lib/govuk_personalisation/urls.rb
Constant Summary collapse
- DIGITAL_IDENTITY_ENVIRONMENT_MAP =
DI/One Login’s environments don’t map exactly to ours - their staging points to our integration and vice versa. So translate here.
{ "production" => "production", "staging" => "integration", "integration" => "staging", }.freeze
Class Method Summary collapse
- .digital_identity_domain(host) ⇒ Object
- .digital_identity_environment ⇒ Object
- .feedback ⇒ Object
-
.find_external_url(var:, url:) ⇒ String
Finds a URL outside www.gov.uk.
-
.find_govuk_url(var:, application:, path:) ⇒ String
Finds a URL on www.gov.uk.
- .manage ⇒ Object
-
.manage_email ⇒ String
Find the GOV.UK URL for the “email manager” page.
-
.one_login_feedback ⇒ String
Find the external URL for the “feedback” page on One Login.
-
.one_login_security ⇒ String
Find the external URL for the “security” page on One Login.
-
.one_login_your_services ⇒ String
Find the external URL for the “your services” page on One Login.
- .security ⇒ Object
-
.sign_in ⇒ String
Find the GOV.UK URL for the “sign in” page.
-
.sign_out ⇒ String
Find the GOV.UK URL for the “sign out” page.
- .your_account ⇒ Object
Class Method Details
.digital_identity_domain(host) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/govuk_personalisation/urls.rb', line 103 def self.digital_identity_domain(host) if ["production", nil].include?(digital_identity_environment) "#{host}.account.gov.uk" else "#{host}.#{digital_identity_environment}.account.gov.uk" end end |
.digital_identity_environment ⇒ Object
119 120 121 122 123 |
# File 'lib/govuk_personalisation/urls.rb', line 119 def self.digital_identity_environment return ENV["DIGITAL_IDENTITY_ENVIRONMENT"] if ENV["DIGITAL_IDENTITY_ENVIRONMENT"] DIGITAL_IDENTITY_ENVIRONMENT_MAP[ENV["GOVUK_ENVIRONMENT"]] || ENV["GOVUK_ENVIRONMENT"] end |
.feedback ⇒ Object
58 59 60 |
# File 'lib/govuk_personalisation/urls.rb', line 58 def self.feedback one_login_feedback end |
.find_external_url(var:, url:) ⇒ String
Finds a URL outside www.gov.uk
If ‘GOVUK_PERSONALISATION_#var_URI` is in the environment, that will be returned.
Otherwise, an application URL generated by Plek will be returned.
99 100 101 |
# File 'lib/govuk_personalisation/urls.rb', line 99 def self.find_external_url(var:, url:) ENV.fetch("GOVUK_PERSONALISATION_#{var}_URI", url) end |
.find_govuk_url(var:, application:, path:) ⇒ String
Finds a URL on www.gov.uk. This method is used so we can have links which work both in production (where the website root is returned) and in local development (where an application URL is returned).
If ‘GOVUK_PERSONALISATION_#var_URI` is in the environment, that will be returned.
Otherwise, a ‘www.gov.uk` URL will be returned (a `dev.gov.uk` domain in development mode)
78 79 80 81 82 83 84 85 86 |
# File 'lib/govuk_personalisation/urls.rb', line 78 def self.find_govuk_url(var:, application:, path:) value_from_env_var = ENV["GOVUK_PERSONALISATION_#{var}_URI"] if value_from_env_var value_from_env_var else plek_application_uri = Rails.env.development? ? Plek.find(application) : Plek.new.website_root "#{plek_application_uri}#{path}" end end |
.manage ⇒ Object
43 44 45 |
# File 'lib/govuk_personalisation/urls.rb', line 43 def self.manage one_login_security end |
.manage_email ⇒ String
Find the GOV.UK URL for the “email manager” page
21 22 23 |
# File 'lib/govuk_personalisation/urls.rb', line 21 def self.manage_email find_govuk_url(var: "SIGN_OUT", application: "email-alert-frontend", path: "/email/manage") end |
.one_login_feedback ⇒ String
Find the external URL for the “feedback” page on One Login
54 55 56 |
# File 'lib/govuk_personalisation/urls.rb', line 54 def self.one_login_feedback find_external_url(var: "ONE_LOGIN_FEEDBACK", url: "https://#{digital_identity_domain('signin')}/support?supportType=PUBLIC") end |
.one_login_security ⇒ String
Find the external URL for the “security” page on One Login
39 40 41 |
# File 'lib/govuk_personalisation/urls.rb', line 39 def self.one_login_security find_external_url(var: "ONE_LOGIN_SECURITY", url: "https://#{digital_identity_domain('home')}/security") end |
.one_login_your_services ⇒ String
Find the external URL for the “your services” page on One Login
28 29 30 |
# File 'lib/govuk_personalisation/urls.rb', line 28 def self.one_login_your_services find_external_url(var: "ONE_LOGIN_YOUR_SERVICES", url: "https://#{digital_identity_domain('home')}") end |
.security ⇒ Object
47 48 49 |
# File 'lib/govuk_personalisation/urls.rb', line 47 def self.security one_login_security end |
.sign_in ⇒ String
Find the GOV.UK URL for the “sign in” page
7 8 9 |
# File 'lib/govuk_personalisation/urls.rb', line 7 def self.sign_in find_govuk_url(var: "SIGN_IN", application: "frontend", path: "/account") end |
.sign_out ⇒ String
Find the GOV.UK URL for the “sign out” page
14 15 16 |
# File 'lib/govuk_personalisation/urls.rb', line 14 def self.sign_out find_govuk_url(var: "SIGN_OUT", application: "frontend", path: "/sign-out") end |
.your_account ⇒ Object
32 33 34 |
# File 'lib/govuk_personalisation/urls.rb', line 32 def self.your_account one_login_your_services end |