govuk_personalisation 0.8.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +15 -0
 - data/lib/govuk_personalisation/controller_concern.rb +21 -0
 - data/lib/govuk_personalisation/redirect.rb +23 -0
 - data/lib/govuk_personalisation/urls.rb +19 -8
 - data/lib/govuk_personalisation/version.rb +1 -1
 - data/lib/govuk_personalisation.rb +1 -0
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 72e80d8e2a45cc9b258a963263e91468d69372505d0452205393eb735cf569fa
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 6cb230637923f915ef5117b812f6790ba244a07c45a29823ad52c51e6ae33f03
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: f527d1acb925660f6b975ceab7bfc87b188578ddecef6e5af15dd340128daed02a84d2c5d042248c79a8b9c9e007a2238c7242fe41cf1dbd4070bea481230eca
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 67b6f46b435a2e9480515cd41f98e6381286ede5d0f2c16d97e4f30f248dd52657d2bd95de056515c1c2a3ec5e24a9f51076cf71cdad285d41bdf5d3fb0e9d2a
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # 0.11.0
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            - Remove references to the account manager from the URLs module ([#26](https://github.com/alphagov/govuk_personalisation/pull/26))
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # 0.10.1
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            - Make session-change events uncacheable ([#24](https://github.com/alphagov/govuk_personalisation/pull/24))
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            # 0.10.0
         
     | 
| 
      
 10 
     | 
    
         
            +
            - Add `url_with_analytics` helper to allow apps to access the URL used for `redirect_with_analytics` ([#22](https://github.com/alphagov/govuk_personalisation/pull/22))
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            # 0.9.0
         
     | 
| 
      
 13 
     | 
    
         
            +
            - Add `redirect_with_analytics` helper, attaches _ga and cookie_consent values from existing params to redirects. ([#19](https://github.com/alphagov/govuk_personalisation/pull/19))
         
     | 
| 
      
 14 
     | 
    
         
            +
            - Add `GovukPersonalisation::Redirect` and `.build_url` helper to construct valid URLs with additional parameters. ([#19](https://github.com/alphagov/govuk_personalisation/pull/19))
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       1 
16 
     | 
    
         
             
            # 0.8.0
         
     | 
| 
       2 
17 
     | 
    
         | 
| 
       3 
18 
     | 
    
         
             
            - Change sign in path to `/sign-in/redirect` ([#17](https://github.com/alphagov/govuk_personalisation/pull/17))
         
     | 
| 
         @@ -83,6 +83,8 @@ module GovukPersonalisation 
     | 
|
| 
       83 
83 
     | 
    
         
             
                  session_with_flash = GovukPersonalisation::Flash.encode_session(@account_session_header, @new_account_flash.keys)
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
85 
     | 
    
         
             
                  response.headers[ACCOUNT_SESSION_HEADER_NAME] = session_with_flash
         
     | 
| 
      
 86 
     | 
    
         
            +
                  response.headers["Cache-Control"] = "no-store"
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
       86 
88 
     | 
    
         
             
                  if Rails.env.development?
         
     | 
| 
       87 
89 
     | 
    
         
             
                    cookies[ACCOUNT_SESSION_DEV_COOKIE_NAME] = {
         
     | 
| 
       88 
90 
     | 
    
         
             
                      value: session_with_flash,
         
     | 
| 
         @@ -95,7 +97,10 @@ module GovukPersonalisation 
     | 
|
| 
       95 
97 
     | 
    
         
             
                # header.
         
     | 
| 
       96 
98 
     | 
    
         
             
                def logout!
         
     | 
| 
       97 
99 
     | 
    
         
             
                  response.headers[ACCOUNT_END_SESSION_HEADER_NAME] = "1"
         
     | 
| 
      
 100 
     | 
    
         
            +
                  response.headers["Cache-Control"] = "no-store"
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
       98 
102 
     | 
    
         
             
                  @account_session_header = nil
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
       99 
104 
     | 
    
         
             
                  if Rails.env.development?
         
     | 
| 
       100 
105 
     | 
    
         
             
                    cookies[ACCOUNT_SESSION_DEV_COOKIE_NAME] = {
         
     | 
| 
       101 
106 
     | 
    
         
             
                      value: "",
         
     | 
| 
         @@ -125,5 +130,21 @@ module GovukPersonalisation 
     | 
|
| 
       125 
130 
     | 
    
         
             
                  @new_account_flash = @account_flash.merge(@new_account_flash)
         
     | 
| 
       126 
131 
     | 
    
         
             
                  set_account_session_header
         
     | 
| 
       127 
132 
     | 
    
         
             
                end
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                # Redirect to a URL adding parameters necessary for cross-domain analytics
         
     | 
| 
      
 135 
     | 
    
         
            +
                # and cookie consent
         
     | 
| 
      
 136 
     | 
    
         
            +
                #
         
     | 
| 
      
 137 
     | 
    
         
            +
                # @param url [String] The URL to redirect to
         
     | 
| 
      
 138 
     | 
    
         
            +
                def redirect_with_analytics(url)
         
     | 
| 
      
 139 
     | 
    
         
            +
                  redirect_to url_with_analytics(url)
         
     | 
| 
      
 140 
     | 
    
         
            +
                end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                # Build a URL adding parameters necessary for cross-domain analytics
         
     | 
| 
      
 143 
     | 
    
         
            +
                # and cookie consent
         
     | 
| 
      
 144 
     | 
    
         
            +
                #
         
     | 
| 
      
 145 
     | 
    
         
            +
                # @param url [String] The URL
         
     | 
| 
      
 146 
     | 
    
         
            +
                def url_with_analytics(url)
         
     | 
| 
      
 147 
     | 
    
         
            +
                  GovukPersonalisation::Redirect.build_url(url, params.permit(:_ga, :cookie_consent).to_h)
         
     | 
| 
      
 148 
     | 
    
         
            +
                end
         
     | 
| 
       128 
149 
     | 
    
         
             
              end
         
     | 
| 
       129 
150 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GovukPersonalisation::Redirect
         
     | 
| 
      
 2 
     | 
    
         
            +
              # Builds a URL with additional query parameters
         
     | 
| 
      
 3 
     | 
    
         
            +
              #
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Allows for a simple method call to add params on to an existing
         
     | 
| 
      
 5 
     | 
    
         
            +
              # URL, for instance when adding _ga tracking params to a redirect
         
     | 
| 
      
 6 
     | 
    
         
            +
              #
         
     | 
| 
      
 7 
     | 
    
         
            +
              # @param          base_url          [String] The URL to attach additional parameters to
         
     | 
| 
      
 8 
     | 
    
         
            +
              # @param optional additional_params [Hash{String,Symbol => String}] additional parameters
         
     | 
| 
      
 9 
     | 
    
         
            +
              #                                   to be added to the URL. If empty, returns the base URL.
         
     | 
| 
      
 10 
     | 
    
         
            +
              #
         
     | 
| 
      
 11 
     | 
    
         
            +
              # @return                           [String] a new URL with additional parameters
         
     | 
| 
      
 12 
     | 
    
         
            +
              def self.build_url(base_url, additional_params = {})
         
     | 
| 
      
 13 
     | 
    
         
            +
                return base_url if additional_params.empty?
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                additional_query = additional_params.to_a.map { |param| param.join("=") }.join("&")
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                if base_url.include? "?"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  "#{base_url}&#{additional_query}"
         
     | 
| 
      
 19 
     | 
    
         
            +
                else
         
     | 
| 
      
 20 
     | 
    
         
            +
                  "#{base_url}?#{additional_query}"
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -26,21 +26,21 @@ module GovukPersonalisation::Urls 
     | 
|
| 
       26 
26 
     | 
    
         
             
              #
         
     | 
| 
       27 
27 
     | 
    
         
             
              # @return [String] the URL
         
     | 
| 
       28 
28 
     | 
    
         
             
              def self.manage
         
     | 
| 
       29 
     | 
    
         
            -
                find_external_url(var: "MANAGE",  
     | 
| 
      
 29 
     | 
    
         
            +
                find_external_url(var: "MANAGE", url: "https://#{digital_identity_domain}?link=manage-account")
         
     | 
| 
       30 
30 
     | 
    
         
             
              end
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
              # Find the external URL for the "security" page
         
     | 
| 
       33 
33 
     | 
    
         
             
              #
         
     | 
| 
       34 
34 
     | 
    
         
             
              # @return [String] the URL
         
     | 
| 
       35 
35 
     | 
    
         
             
              def self.security
         
     | 
| 
       36 
     | 
    
         
            -
                find_external_url(var: "SECURITY",  
     | 
| 
      
 36 
     | 
    
         
            +
                find_external_url(var: "SECURITY", url: "https://#{digital_identity_domain}?link=security-privacy")
         
     | 
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
              # Find the external URL for the "feedback" page
         
     | 
| 
       40 
40 
     | 
    
         
             
              #
         
     | 
| 
       41 
41 
     | 
    
         
             
              # @return [String] the URL
         
     | 
| 
       42 
42 
     | 
    
         
             
              def self.feedback
         
     | 
| 
       43 
     | 
    
         
            -
                find_external_url(var: "FEEDBACK",  
     | 
| 
      
 43 
     | 
    
         
            +
                find_external_url(var: "FEEDBACK", url: "https://signin.account.gov.uk/support")
         
     | 
| 
       44 
44 
     | 
    
         
             
              end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
              # Finds a URL on www.gov.uk.  This method is used so we can have
         
     | 
| 
         @@ -76,12 +76,23 @@ module GovukPersonalisation::Urls 
     | 
|
| 
       76 
76 
     | 
    
         
             
              #
         
     | 
| 
       77 
77 
     | 
    
         
             
              # Otherwise, an application URL generated by Plek will be returned.
         
     | 
| 
       78 
78 
     | 
    
         
             
              #
         
     | 
| 
       79 
     | 
    
         
            -
              # @param var 
     | 
| 
       80 
     | 
    
         
            -
              # @param  
     | 
| 
       81 
     | 
    
         
            -
              # @param path        [String] the path to use (if the env var is set this is ignored)
         
     | 
| 
      
 79 
     | 
    
         
            +
              # @param var [String] the name of the variable to look up
         
     | 
| 
      
 80 
     | 
    
         
            +
              # @param url [String] the url to default to if there is no environment variable set
         
     | 
| 
       82 
81 
     | 
    
         
             
              #
         
     | 
| 
       83 
82 
     | 
    
         
             
              # @return [String] the URL
         
     | 
| 
       84 
     | 
    
         
            -
              def self.find_external_url(var:,  
     | 
| 
       85 
     | 
    
         
            -
                ENV.fetch("GOVUK_PERSONALISATION_#{var}_URI",  
     | 
| 
      
 83 
     | 
    
         
            +
              def self.find_external_url(var:, url:)
         
     | 
| 
      
 84 
     | 
    
         
            +
                ENV.fetch("GOVUK_PERSONALISATION_#{var}_URI", url)
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              # Gets the Digital Identity domain for the current environment
         
     | 
| 
      
 88 
     | 
    
         
            +
              #
         
     | 
| 
      
 89 
     | 
    
         
            +
              # @return [String] the domain
         
     | 
| 
      
 90 
     | 
    
         
            +
              def self.digital_identity_domain
         
     | 
| 
      
 91 
     | 
    
         
            +
                environment = ENV["DIGITAL_IDENTITY_ENVIRONMENT"]
         
     | 
| 
      
 92 
     | 
    
         
            +
                if environment
         
     | 
| 
      
 93 
     | 
    
         
            +
                  "#{environment}.account.gov.uk"
         
     | 
| 
      
 94 
     | 
    
         
            +
                else
         
     | 
| 
      
 95 
     | 
    
         
            +
                  "account.gov.uk"
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
       86 
97 
     | 
    
         
             
              end
         
     | 
| 
       87 
98 
     | 
    
         
             
            end
         
     | 
| 
         @@ -3,6 +3,7 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require "govuk_personalisation/version"
         
     | 
| 
       4 
4 
     | 
    
         
             
            require "govuk_personalisation/controller_concern"
         
     | 
| 
       5 
5 
     | 
    
         
             
            require "govuk_personalisation/flash"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "govuk_personalisation/redirect"
         
     | 
| 
       6 
7 
     | 
    
         
             
            require "govuk_personalisation/test_helpers/features"
         
     | 
| 
       7 
8 
     | 
    
         
             
            require "govuk_personalisation/test_helpers/requests"
         
     | 
| 
       8 
9 
     | 
    
         
             
            require "govuk_personalisation/urls"
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: govuk_personalisation
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.11.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - GOV.UK Dev
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-12-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: plek
         
     | 
| 
         @@ -146,6 +146,7 @@ files: 
     | 
|
| 
       146 
146 
     | 
    
         
             
            - lib/govuk_personalisation.rb
         
     | 
| 
       147 
147 
     | 
    
         
             
            - lib/govuk_personalisation/controller_concern.rb
         
     | 
| 
       148 
148 
     | 
    
         
             
            - lib/govuk_personalisation/flash.rb
         
     | 
| 
      
 149 
     | 
    
         
            +
            - lib/govuk_personalisation/redirect.rb
         
     | 
| 
       149 
150 
     | 
    
         
             
            - lib/govuk_personalisation/test_helpers/features.rb
         
     | 
| 
       150 
151 
     | 
    
         
             
            - lib/govuk_personalisation/test_helpers/requests.rb
         
     | 
| 
       151 
152 
     | 
    
         
             
            - lib/govuk_personalisation/urls.rb
         
     |