Skip to content

Commit f8f1b63

Browse files
committed
Version 4.1.0
1 parent de3f815 commit f8f1b63

File tree

6 files changed

+49
-25
lines changed

6 files changed

+49
-25
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ cache: bundler
44
rvm:
55
- 2.5.7
66
- 2.6.5
7+
- 2.7.0
78

89
before_install:
910
- gem update bundler
1011

1112
env:
1213
- 'TEST_RAILS_VERSION="~> 5.1.6"'
1314
- 'TEST_RAILS_VERSION="~> 5.2.3"'
14-
- 'TEST_RAILS_VERSION="~> 6.0.0"'
15+
- 'TEST_RAILS_VERSION="~> 6.0.0"'

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 4.1.0 (03-Feb-20)
4+
5+
* Added a new [`angular_rails_csrf_secure` option](https://github.com/jsanders/angular_rails_csrf#secure-cookie) (thanks, [@DougKeller](https://github.com/DougKeller))
6+
* Tested against Ruby 2.7
7+
38
## 4.0.1 (23-Dec-19)
49

510
* Updated dependencies, tested against more recent Rubies and Rails

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2018 James Sanders, Ilya Bodrov
1+
Copyright 2020 James Sanders, Ilya Bodrov
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,28 @@ end
5252

5353
If `angular_rails_csrf_domain` is not set, it defaults to `nil`.
5454

55+
### Secure Cookie
56+
57+
To set a "secure" flag for the cookie, set the `angular_rails_csrf_secure` option to `true`:
58+
59+
```ruby
60+
# application.rb
61+
class Application < Rails::Application
62+
#...
63+
config.angular_rails_csrf_secure = true
64+
end
65+
```
66+
67+
`angular_rails_csrf_secure` defaults to `false`.
68+
5569
### Exclusions
5670

5771
Sometimes you will want to skip setting the XSRF token for certain controllers (for example, when using SSE or ActionCable, as discussed [here](https://github.com/jsanders/angular_rails_csrf/issues/7)):
5872

5973
```ruby
6074
class ExclusionsController < ApplicationController
6175
exclude_xsrf_token_cookie
62-
76+
6377
# your actions here...
6478
end
6579
```
@@ -78,6 +92,6 @@ and then
7892
$ rake test
7993
```
8094

81-
## License
95+
## License
8296

8397
Licensed under the [MIT License](https://github.com/jsanders/angular_rails_csrf/blob/master/LICENSE).

lib/angular_rails_csrf/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module AngularRailsCsrf
4-
VERSION = '4.0.1'
4+
VERSION = '4.1.0'
55
end

test/angular_rails_csrf_test.rb

+24-20
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,36 @@ class AngularRailsCsrfTest < ActionController::TestCase
3232
end
3333

3434
test 'the domain is used if present' do
35-
config = Rails.application.config
36-
def config.angular_rails_csrf_domain
37-
:all
38-
end
35+
begin
36+
config = Rails.application.config
37+
def config.angular_rails_csrf_domain
38+
:all
39+
end
3940

40-
get :index
41-
assert @response.headers['Set-Cookie'].include?('.test.host')
42-
assert_valid_cookie
43-
assert_response :success
44-
ensure
45-
config.instance_eval('undef :angular_rails_csrf_domain')
41+
get :index
42+
assert @response.headers['Set-Cookie'].include?('.test.host')
43+
assert_valid_cookie
44+
assert_response :success
45+
ensure
46+
config.instance_eval('undef :angular_rails_csrf_domain', __FILE__, __LINE__)
47+
end
4648
end
4749

4850
test 'the secure flag is set if configured' do
49-
@request.headers['HTTPS'] = 'on'
51+
begin
52+
@request.headers['HTTPS'] = 'on'
5053

51-
config = Rails.application.config
52-
config.define_singleton_method(:angular_rails_csrf_secure) { true }
54+
config = Rails.application.config
55+
config.define_singleton_method(:angular_rails_csrf_secure) { true }
5356

54-
get :index
55-
assert @response.headers['Set-Cookie'].include?('secure')
56-
assert_valid_cookie
57-
assert_response :success
58-
ensure
59-
@request.headers['HTTPS'] = nil
60-
config.instance_eval('undef :angular_rails_csrf_secure')
57+
get :index
58+
assert @response.headers['Set-Cookie'].include?('secure')
59+
assert_valid_cookie
60+
assert_response :success
61+
ensure
62+
@request.headers['HTTPS'] = nil
63+
config.instance_eval('undef :angular_rails_csrf_secure', __FILE__, __LINE__)
64+
end
6165
end
6266

6367
test 'a custom name is used if present' do

0 commit comments

Comments
 (0)