govuk_personalisation 0.7.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ba6e9b0f0533ecc545582e031f6faf0f734d727e42478ffea40ddac7635986e
4
- data.tar.gz: '0974635ac43c8dfacb6894787db3d36b2608438117b41640364bfd40dcecb125'
3
+ metadata.gz: e6aba4a93adaa9cf995e9933fb12276d84e8d0e3011c17ec4689a63a5cf8f4a0
4
+ data.tar.gz: 97b6c20b940afef6fb31671187b619b89f58222922b7b2b8c9ae6233d2dcec0e
5
5
  SHA512:
6
- metadata.gz: 0fdb4622d551eae409978cac47ea4dfc78205a33d6e6b324b0a4eae4ab97eb5730571cd038a49ae9d74167a50093771aa96e60062a8fadfe33dc9b57206da2a1
7
- data.tar.gz: f11fc215ac0ab1bb8147c973398b1bba72a1f58a7ea838473ea05f305a2ac169bd527fb61e8eb7e5676be14fb02fde5ef821800868488b6250b0591e64e6aab0
6
+ metadata.gz: f431ca7c35aca6f808d968d82eca6420ce0fab31c00766ec39226284790c7a46f8a49bf2d1dda60784853c85a8f836972d628b21ee7a77d213b6d5d0090a1715
7
+ data.tar.gz: 43eb1db4b1c9cbd2c7a44d8610dc22f33e0ddd37e844038d5b0ca32140cc9c42f0d9519be395d5f247df9963ce17736b106dddd05de0a8f34e1d30366561c3ec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # 0.10.1
2
+
3
+ - Make session-change events uncacheable ([#24](https://github.com/alphagov/govuk_personalisation/pull/24))
4
+
5
+ # 0.10.0
6
+ - 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))
7
+
8
+ # 0.9.0
9
+ - 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))
10
+ - Add `GovukPersonalisation::Redirect` and `.build_url` helper to construct valid URLs with additional parameters. ([#19](https://github.com/alphagov/govuk_personalisation/pull/19))
11
+
12
+ # 0.8.0
13
+
14
+ - Change sign in path to `/sign-in/redirect` ([#17](https://github.com/alphagov/govuk_personalisation/pull/17))
15
+
1
16
  # 0.7.0
2
17
 
3
18
  - Add `GovukPersonalisation::Urls` module ([#14](https://github.com/alphagov/govuk_personalisation/pull/14) [#16](https://github.com/alphagov/govuk_personalisation/pull/16))
@@ -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
@@ -5,7 +5,7 @@ module GovukPersonalisation::Urls
5
5
  #
6
6
  # @return [String] the URL
7
7
  def self.sign_in
8
- find_govuk_url(var: "SIGN_IN", application: "frontend", path: "/sign-in")
8
+ find_govuk_url(var: "SIGN_IN", application: "frontend", path: "/sign-in/redirect")
9
9
  end
10
10
 
11
11
  # Find the GOV.UK URL for the "sign out" page
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GovukPersonalisation
4
- VERSION = "0.7.0"
4
+ VERSION = "0.10.1"
5
5
  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.7.0
4
+ version: 0.10.1
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-08-31 00:00:00.000000000 Z
11
+ date: 2021-11-23 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