castle_devise 0.4.1 → 0.6.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/.github/workflows/lint.yml +10 -13
- data/.github/workflows/specs.yml +56 -30
- data/.gitignore +1 -0
- data/.octocov.yml +14 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +31 -1
- data/Gemfile +5 -2
- data/Gemfile.lock +256 -138
- data/README.md +23 -4
- data/bin/console +1 -1
- data/castle_devise.gemspec +6 -8
- data/gemfiles/rails_6.0.gemfile +5 -4
- data/gemfiles/rails_6.1.gemfile +5 -4
- data/gemfiles/rails_7.0.gemfile +18 -0
- data/gemfiles/rails_7.1.gemfile +18 -0
- data/gemfiles/rails_7.2.gemfile +18 -0
- data/gemfiles/{rails_5.2.gemfile → rails_8.0.gemfile} +4 -3
- data/gemfiles/rails_8.1.gemfile +17 -0
- data/lib/castle_devise/configuration.rb +30 -16
- data/lib/castle_devise/hooks/castle_protectable.rb +9 -4
- data/lib/castle_devise/patches/registrations_controller.rb +15 -10
- data/lib/castle_devise/sdk_facade.rb +2 -2
- data/lib/castle_devise/version.rb +1 -1
- metadata +21 -32
- data/Appraisals +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a64b67ee6cdd64729672a54ec1f17457a03ac36833d00fa52ea3c2c8752a4f7a
|
|
4
|
+
data.tar.gz: 56de964e966c6dd76953fffda7b5121b06883aa79b21dc680aaccd64ba94383a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 55d9047b2d6ecfca23badbd25736afa89acc132f2a6d8267eedd936f69d96c33da85a7f7ee2a7ac9e7a9a69f0e250532229d06fc22eb454a76b2a8c493233233
|
|
7
|
+
data.tar.gz: 695ed027ffff37f150a238897d98d2e68d156871895576e5f40cf287fa983964c0a36f378983e88c995080de95ba64d0f342e0e02b3c8b740a11e99d88f776fc
|
data/.github/workflows/lint.yml
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
name: Lint
|
|
2
2
|
|
|
3
|
-
on:
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
4
7
|
|
|
5
8
|
jobs:
|
|
6
9
|
standardrb:
|
|
7
|
-
name:
|
|
10
|
+
name: standardrb
|
|
8
11
|
runs-on: ubuntu-latest
|
|
9
12
|
steps:
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
- name: Give permissions
|
|
13
|
-
run: |
|
|
14
|
-
sudo chown -R root:root $GITHUB_WORKSPACE
|
|
15
|
-
- name: standardrb
|
|
16
|
-
uses: SennaLabs/action-standardrb@v0.0.3
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: ruby/setup-ruby@v1
|
|
17
15
|
with:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rubocop_flags: --format progress
|
|
16
|
+
ruby-version: "3.4"
|
|
17
|
+
bundler-cache: true
|
|
18
|
+
- run: bundle exec standardrb --format progress
|
data/.github/workflows/specs.yml
CHANGED
|
@@ -10,34 +10,60 @@ jobs:
|
|
|
10
10
|
strategy:
|
|
11
11
|
fail-fast: false
|
|
12
12
|
matrix:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
include:
|
|
14
|
+
# Rails 6.0
|
|
15
|
+
- ruby: "3.2"
|
|
16
|
+
rails: "6.0"
|
|
17
|
+
# Rails 6.1
|
|
18
|
+
- ruby: "3.2"
|
|
19
|
+
rails: "6.1"
|
|
20
|
+
# Rails 7.0
|
|
21
|
+
- ruby: "3.2"
|
|
22
|
+
rails: "7.0"
|
|
23
|
+
# Rails 7.1
|
|
24
|
+
- ruby: "3.2"
|
|
25
|
+
rails: "7.1"
|
|
26
|
+
- ruby: "3.3"
|
|
27
|
+
rails: "7.1"
|
|
28
|
+
# Rails 7.2
|
|
29
|
+
- ruby: "3.2"
|
|
30
|
+
rails: "7.2"
|
|
31
|
+
- ruby: "3.3"
|
|
32
|
+
rails: "7.2"
|
|
33
|
+
# Rails 8.0
|
|
34
|
+
- ruby: "3.3"
|
|
35
|
+
rails: "8.0"
|
|
36
|
+
- ruby: "3.4"
|
|
37
|
+
rails: "8.0"
|
|
38
|
+
- ruby: "4.0"
|
|
39
|
+
rails: "8.0"
|
|
40
|
+
# Rails 8.1
|
|
41
|
+
- ruby: "3.3"
|
|
42
|
+
rails: "8.1"
|
|
43
|
+
- ruby: "3.4"
|
|
44
|
+
rails: "8.1"
|
|
45
|
+
- ruby: "4.0"
|
|
46
|
+
rails: "8.1"
|
|
19
47
|
steps:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
with:
|
|
43
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
50
|
+
uses: ruby/setup-ruby@v1
|
|
51
|
+
with:
|
|
52
|
+
ruby-version: ${{ matrix.ruby }}
|
|
53
|
+
- name: Install dependencies
|
|
54
|
+
env:
|
|
55
|
+
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gemfile
|
|
56
|
+
run: |
|
|
57
|
+
bundle config path vendor/bundle
|
|
58
|
+
bundle install
|
|
59
|
+
- name: Run specs
|
|
60
|
+
env:
|
|
61
|
+
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gemfile
|
|
62
|
+
CASTLE_API_SECRET: ${{ secrets.CASTLE_API_SECRET }}
|
|
63
|
+
run: |
|
|
64
|
+
bundle exec rake
|
|
65
|
+
- name: Simplecov Report
|
|
66
|
+
uses: k1LoW/octocov-action@v1
|
|
67
|
+
if: matrix.ruby == '3.4' && matrix.rails == '8.1'
|
|
68
|
+
with:
|
|
69
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
data/.gitignore
CHANGED
data/.octocov.yml
ADDED
data/.standard.yml
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased][main]
|
|
4
4
|
|
|
5
|
+
## [0.6.0] - 2026-05-25
|
|
6
|
+
- Add support for Rails 8.1
|
|
7
|
+
- Add support for Devise 5
|
|
8
|
+
- Allow `castle-rb` 9.x (constraint widened to `>= 7.2, < 10.0`); verified
|
|
9
|
+
against the upcoming 9.0 release — castle_devise uses only the
|
|
10
|
+
`#risk` / `#filter` / `#log` Client APIs and the `Castle::Error` /
|
|
11
|
+
`InvalidParametersError` / `InvalidRequestTokenError` classes, all of
|
|
12
|
+
which remain in 9.0.
|
|
13
|
+
- Bump `castle-rb` to 9.1.0
|
|
14
|
+
- Add Ruby 3.3, 3.4, and 4.0 to the CI matrix
|
|
15
|
+
- Bump minimum required Ruby version to 3.2
|
|
16
|
+
- Replace deprecated `ActiveSupport::Configurable` with plain Ruby attribute accessors (drops the Rails 8.2 deprecation warning)
|
|
17
|
+
- Drop `appraisal` development dependency in favor of hand-maintained `gemfiles/*.gemfile`
|
|
18
|
+
- Bump development Gemfile to Rails 8.1, Devise 5, sqlite3 ~> 2.1, Bundler 2.7.x
|
|
19
|
+
|
|
20
|
+
## [0.5.0] - 2025-06-17
|
|
21
|
+
- Throw a warning instead of an error for the `$login.failed` event when an exception is raised
|
|
22
|
+
- Security fixes and dependency updates
|
|
23
|
+
|
|
24
|
+
## [0.4.3] - 2023-07-11
|
|
25
|
+
- Fix an issue where we would send a `login.failed` event on any attempt of accessing a protected resource, not only when the user failed to log in specifically
|
|
26
|
+
|
|
27
|
+
## [0.4.2] - 2023-07-10
|
|
28
|
+
- Change `params` to contain the email address sent by the user for the `/v1/filter` endpoint
|
|
29
|
+
|
|
5
30
|
## [0.4.1] - 2022-12-13
|
|
6
31
|
- Introduced new configuration options for `castle_sdk_facade_class` and `castle_client`
|
|
7
32
|
|
|
@@ -23,7 +48,12 @@
|
|
|
23
48
|
|
|
24
49
|
- Initial release
|
|
25
50
|
|
|
26
|
-
[main]: https://github.com/castle/castle_devise/compare/v0.
|
|
51
|
+
[main]: https://github.com/castle/castle_devise/compare/v0.6.0...HEAD
|
|
52
|
+
[0.6.0]: https://github.com/castle/castle_devise/compare/v0.5.0...v0.6.0
|
|
53
|
+
[0.5.0]: https://github.com/castle/castle_devise/compare/v0.4.3...v0.5.0
|
|
54
|
+
[0.4.3]: https://github.com/castle/castle_devise/compare/v0.4.2...v0.4.3
|
|
55
|
+
[0.4.2]: https://github.com/castle/castle_devise/compare/v0.4.1...v0.4.2
|
|
56
|
+
[0.4.1]: https://github.com/castle/castle_devise/compare/v0.4.0...v0.4.1
|
|
27
57
|
[0.4.0]: https://github.com/castle/castle_devise/compare/v0.3.0...v0.4.0
|
|
28
58
|
[0.3.0]: https://github.com/castle/castle_devise/compare/v0.2.0...v0.3.0
|
|
29
59
|
[0.2.0]: https://github.com/castle/castle_devise/compare/v0.1.0...v0.2.0
|
data/Gemfile
CHANGED
|
@@ -7,13 +7,16 @@ gemspec
|
|
|
7
7
|
|
|
8
8
|
gem "actionmailer"
|
|
9
9
|
gem "activerecord"
|
|
10
|
+
# Dev/test: track castle-rb upstream develop. Gemspec uses rubygems.
|
|
11
|
+
gem "castle-rb", github: "castle/castle-ruby", branch: "develop"
|
|
10
12
|
gem "byebug"
|
|
11
|
-
gem "
|
|
13
|
+
gem "devise", "~> 5.0"
|
|
14
|
+
gem "railties", "~> 8.1"
|
|
12
15
|
gem "rake"
|
|
13
16
|
gem "rspec"
|
|
14
17
|
gem "rspec-rails"
|
|
15
18
|
gem "simplecov"
|
|
19
|
+
gem "sqlite3", "~> 2.1"
|
|
16
20
|
gem "standard"
|
|
17
|
-
gem "sqlite3"
|
|
18
21
|
gem "vcr"
|
|
19
22
|
gem "webmock"
|
data/Gemfile.lock
CHANGED
|
@@ -1,193 +1,311 @@
|
|
|
1
|
+
GIT
|
|
2
|
+
remote: https://github.com/castle/castle-ruby.git
|
|
3
|
+
revision: 66c0523be56f5f24b8a8933dc522b5487bc77fce
|
|
4
|
+
branch: develop
|
|
5
|
+
specs:
|
|
6
|
+
castle-rb (9.1.0)
|
|
7
|
+
base64 (~> 0.2)
|
|
8
|
+
|
|
1
9
|
PATH
|
|
2
10
|
remote: .
|
|
3
11
|
specs:
|
|
4
|
-
castle_devise (0.
|
|
5
|
-
activesupport (>=
|
|
6
|
-
castle-rb (>= 7.
|
|
7
|
-
devise (>= 4.3.0, <
|
|
12
|
+
castle_devise (0.6.0)
|
|
13
|
+
activesupport (>= 6.0)
|
|
14
|
+
castle-rb (>= 7.2, < 10.0)
|
|
15
|
+
devise (>= 4.3.0, < 6.0)
|
|
8
16
|
|
|
9
17
|
GEM
|
|
10
18
|
remote: https://rubygems.org/
|
|
11
19
|
specs:
|
|
12
|
-
actionmailer (
|
|
13
|
-
actionpack (=
|
|
14
|
-
actionview (=
|
|
15
|
-
activejob (=
|
|
16
|
-
activesupport (=
|
|
17
|
-
mail (
|
|
18
|
-
rails-dom-testing (~> 2.
|
|
19
|
-
actionpack (
|
|
20
|
-
actionview (=
|
|
21
|
-
activesupport (=
|
|
22
|
-
|
|
20
|
+
actionmailer (8.1.3)
|
|
21
|
+
actionpack (= 8.1.3)
|
|
22
|
+
actionview (= 8.1.3)
|
|
23
|
+
activejob (= 8.1.3)
|
|
24
|
+
activesupport (= 8.1.3)
|
|
25
|
+
mail (>= 2.8.0)
|
|
26
|
+
rails-dom-testing (~> 2.2)
|
|
27
|
+
actionpack (8.1.3)
|
|
28
|
+
actionview (= 8.1.3)
|
|
29
|
+
activesupport (= 8.1.3)
|
|
30
|
+
nokogiri (>= 1.8.5)
|
|
31
|
+
rack (>= 2.2.4)
|
|
32
|
+
rack-session (>= 1.0.1)
|
|
23
33
|
rack-test (>= 0.6.3)
|
|
24
|
-
rails-dom-testing (~> 2.
|
|
25
|
-
rails-html-sanitizer (~> 1.
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
rails-dom-testing (~> 2.2)
|
|
35
|
+
rails-html-sanitizer (~> 1.6)
|
|
36
|
+
useragent (~> 0.16)
|
|
37
|
+
actionview (8.1.3)
|
|
38
|
+
activesupport (= 8.1.3)
|
|
28
39
|
builder (~> 3.1)
|
|
29
|
-
erubi (~> 1.
|
|
30
|
-
rails-dom-testing (~> 2.
|
|
31
|
-
rails-html-sanitizer (~> 1.
|
|
32
|
-
activejob (
|
|
33
|
-
activesupport (=
|
|
40
|
+
erubi (~> 1.11)
|
|
41
|
+
rails-dom-testing (~> 2.2)
|
|
42
|
+
rails-html-sanitizer (~> 1.6)
|
|
43
|
+
activejob (8.1.3)
|
|
44
|
+
activesupport (= 8.1.3)
|
|
34
45
|
globalid (>= 0.3.6)
|
|
35
|
-
activemodel (
|
|
36
|
-
activesupport (=
|
|
37
|
-
activerecord (
|
|
38
|
-
activemodel (=
|
|
39
|
-
activesupport (=
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
activemodel (8.1.3)
|
|
47
|
+
activesupport (= 8.1.3)
|
|
48
|
+
activerecord (8.1.3)
|
|
49
|
+
activemodel (= 8.1.3)
|
|
50
|
+
activesupport (= 8.1.3)
|
|
51
|
+
timeout (>= 0.4.0)
|
|
52
|
+
activesupport (8.1.3)
|
|
53
|
+
base64
|
|
54
|
+
bigdecimal
|
|
55
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
56
|
+
connection_pool (>= 2.2.5)
|
|
57
|
+
drb
|
|
42
58
|
i18n (>= 1.6, < 2)
|
|
59
|
+
json
|
|
60
|
+
logger (>= 1.4.2)
|
|
43
61
|
minitest (>= 5.1)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
crack (0.
|
|
62
|
+
securerandom (>= 0.3)
|
|
63
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
64
|
+
uri (>= 0.13.1)
|
|
65
|
+
addressable (2.9.0)
|
|
66
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
67
|
+
ast (2.4.3)
|
|
68
|
+
base64 (0.3.0)
|
|
69
|
+
bcrypt (3.1.22)
|
|
70
|
+
bigdecimal (4.1.2)
|
|
71
|
+
builder (3.3.0)
|
|
72
|
+
byebug (13.0.0)
|
|
73
|
+
reline (>= 0.6.0)
|
|
74
|
+
concurrent-ruby (1.3.6)
|
|
75
|
+
connection_pool (3.0.2)
|
|
76
|
+
crack (1.0.1)
|
|
77
|
+
bigdecimal
|
|
59
78
|
rexml
|
|
60
79
|
crass (1.0.6)
|
|
61
|
-
|
|
80
|
+
date (3.5.1)
|
|
81
|
+
devise (5.0.4)
|
|
62
82
|
bcrypt (~> 3.0)
|
|
63
83
|
orm_adapter (~> 0.1)
|
|
64
|
-
railties (>=
|
|
84
|
+
railties (>= 7.0)
|
|
65
85
|
responders
|
|
66
86
|
warden (~> 1.2.3)
|
|
67
|
-
diff-lcs (1.
|
|
68
|
-
docile (1.4.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
diff-lcs (1.6.2)
|
|
88
|
+
docile (1.4.1)
|
|
89
|
+
drb (2.2.3)
|
|
90
|
+
erb (6.0.4)
|
|
91
|
+
erubi (1.13.1)
|
|
92
|
+
globalid (1.3.0)
|
|
93
|
+
activesupport (>= 6.1)
|
|
94
|
+
hashdiff (1.2.1)
|
|
95
|
+
i18n (1.14.8)
|
|
74
96
|
concurrent-ruby (~> 1.0)
|
|
75
|
-
|
|
97
|
+
io-console (0.8.2)
|
|
98
|
+
irb (1.18.0)
|
|
99
|
+
pp (>= 0.6.0)
|
|
100
|
+
prism (>= 1.3.0)
|
|
101
|
+
rdoc (>= 4.0.0)
|
|
102
|
+
reline (>= 0.4.2)
|
|
103
|
+
json (2.19.7)
|
|
104
|
+
language_server-protocol (3.17.0.5)
|
|
105
|
+
lint_roller (1.1.0)
|
|
106
|
+
logger (1.7.0)
|
|
107
|
+
loofah (2.25.1)
|
|
76
108
|
crass (~> 1.0.2)
|
|
77
|
-
nokogiri (>= 1.
|
|
78
|
-
mail (2.
|
|
109
|
+
nokogiri (>= 1.12.0)
|
|
110
|
+
mail (2.9.0)
|
|
111
|
+
logger
|
|
79
112
|
mini_mime (>= 0.1.1)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
113
|
+
net-imap
|
|
114
|
+
net-pop
|
|
115
|
+
net-smtp
|
|
116
|
+
mini_mime (1.1.5)
|
|
117
|
+
minitest (6.0.6)
|
|
118
|
+
drb (~> 2.0)
|
|
119
|
+
prism (~> 1.5)
|
|
120
|
+
net-imap (0.6.4)
|
|
121
|
+
date
|
|
122
|
+
net-protocol
|
|
123
|
+
net-pop (0.1.2)
|
|
124
|
+
net-protocol
|
|
125
|
+
net-protocol (0.2.2)
|
|
126
|
+
timeout
|
|
127
|
+
net-smtp (0.5.1)
|
|
128
|
+
net-protocol
|
|
129
|
+
nokogiri (1.19.3-aarch64-linux-gnu)
|
|
130
|
+
racc (~> 1.4)
|
|
131
|
+
nokogiri (1.19.3-aarch64-linux-musl)
|
|
132
|
+
racc (~> 1.4)
|
|
133
|
+
nokogiri (1.19.3-arm-linux-gnu)
|
|
134
|
+
racc (~> 1.4)
|
|
135
|
+
nokogiri (1.19.3-arm-linux-musl)
|
|
136
|
+
racc (~> 1.4)
|
|
137
|
+
nokogiri (1.19.3-arm64-darwin)
|
|
138
|
+
racc (~> 1.4)
|
|
139
|
+
nokogiri (1.19.3-x86_64-darwin)
|
|
140
|
+
racc (~> 1.4)
|
|
141
|
+
nokogiri (1.19.3-x86_64-linux-gnu)
|
|
142
|
+
racc (~> 1.4)
|
|
143
|
+
nokogiri (1.19.3-x86_64-linux-musl)
|
|
84
144
|
racc (~> 1.4)
|
|
85
145
|
orm_adapter (0.5.0)
|
|
86
|
-
parallel (1.
|
|
87
|
-
parser (3.
|
|
146
|
+
parallel (1.28.0)
|
|
147
|
+
parser (3.3.11.1)
|
|
88
148
|
ast (~> 2.4.1)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
149
|
+
racc
|
|
150
|
+
pp (0.6.3)
|
|
151
|
+
prettyprint
|
|
152
|
+
prettyprint (0.2.0)
|
|
153
|
+
prism (1.9.0)
|
|
154
|
+
psych (5.3.1)
|
|
155
|
+
date
|
|
156
|
+
stringio
|
|
157
|
+
public_suffix (7.0.5)
|
|
158
|
+
racc (1.8.1)
|
|
159
|
+
rack (3.2.6)
|
|
160
|
+
rack-session (2.1.2)
|
|
161
|
+
base64 (>= 0.1.0)
|
|
162
|
+
rack (>= 3.0.0)
|
|
163
|
+
rack-test (2.2.0)
|
|
164
|
+
rack (>= 1.3)
|
|
165
|
+
rackup (2.3.1)
|
|
166
|
+
rack (>= 3)
|
|
167
|
+
rails-dom-testing (2.3.0)
|
|
168
|
+
activesupport (>= 5.0.0)
|
|
169
|
+
minitest
|
|
96
170
|
nokogiri (>= 1.6)
|
|
97
|
-
rails-html-sanitizer (1.
|
|
98
|
-
loofah (~> 2.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
171
|
+
rails-html-sanitizer (1.7.0)
|
|
172
|
+
loofah (~> 2.25)
|
|
173
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
174
|
+
railties (8.1.3)
|
|
175
|
+
actionpack (= 8.1.3)
|
|
176
|
+
activesupport (= 8.1.3)
|
|
177
|
+
irb (~> 1.13)
|
|
178
|
+
rackup (>= 1.0.0)
|
|
179
|
+
rake (>= 12.2)
|
|
180
|
+
thor (~> 1.0, >= 1.2.2)
|
|
181
|
+
tsort (>= 0.2)
|
|
182
|
+
zeitwerk (~> 2.6)
|
|
183
|
+
rainbow (3.1.1)
|
|
184
|
+
rake (13.4.2)
|
|
185
|
+
rdoc (7.2.0)
|
|
186
|
+
erb
|
|
187
|
+
psych (>= 4.0.0)
|
|
188
|
+
tsort
|
|
189
|
+
regexp_parser (2.12.0)
|
|
190
|
+
reline (0.6.3)
|
|
191
|
+
io-console (~> 0.5)
|
|
192
|
+
responders (3.2.0)
|
|
193
|
+
actionpack (>= 7.0)
|
|
194
|
+
railties (>= 7.0)
|
|
195
|
+
rexml (3.4.4)
|
|
196
|
+
rspec (3.13.2)
|
|
197
|
+
rspec-core (~> 3.13.0)
|
|
198
|
+
rspec-expectations (~> 3.13.0)
|
|
199
|
+
rspec-mocks (~> 3.13.0)
|
|
200
|
+
rspec-core (3.13.6)
|
|
201
|
+
rspec-support (~> 3.13.0)
|
|
202
|
+
rspec-expectations (3.13.5)
|
|
119
203
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
120
|
-
rspec-support (~> 3.
|
|
121
|
-
rspec-mocks (3.
|
|
204
|
+
rspec-support (~> 3.13.0)
|
|
205
|
+
rspec-mocks (3.13.8)
|
|
122
206
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
123
|
-
rspec-support (~> 3.
|
|
124
|
-
rspec-rails (
|
|
125
|
-
actionpack (>=
|
|
126
|
-
activesupport (>=
|
|
127
|
-
railties (>=
|
|
128
|
-
rspec-core (
|
|
129
|
-
rspec-expectations (
|
|
130
|
-
rspec-mocks (
|
|
131
|
-
rspec-support (
|
|
132
|
-
rspec-support (3.
|
|
133
|
-
rubocop (1.
|
|
207
|
+
rspec-support (~> 3.13.0)
|
|
208
|
+
rspec-rails (8.0.4)
|
|
209
|
+
actionpack (>= 7.2)
|
|
210
|
+
activesupport (>= 7.2)
|
|
211
|
+
railties (>= 7.2)
|
|
212
|
+
rspec-core (>= 3.13.0, < 5.0.0)
|
|
213
|
+
rspec-expectations (>= 3.13.0, < 5.0.0)
|
|
214
|
+
rspec-mocks (>= 3.13.0, < 5.0.0)
|
|
215
|
+
rspec-support (>= 3.13.0, < 5.0.0)
|
|
216
|
+
rspec-support (3.13.7)
|
|
217
|
+
rubocop (1.84.2)
|
|
218
|
+
json (~> 2.3)
|
|
219
|
+
language_server-protocol (~> 3.17.0.2)
|
|
220
|
+
lint_roller (~> 1.1.0)
|
|
134
221
|
parallel (~> 1.10)
|
|
135
|
-
parser (>= 3.
|
|
222
|
+
parser (>= 3.3.0.2)
|
|
136
223
|
rainbow (>= 2.2.2, < 4.0)
|
|
137
|
-
regexp_parser (>=
|
|
138
|
-
|
|
139
|
-
rubocop-ast (>= 1.8.0, < 2.0)
|
|
224
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
225
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
140
226
|
ruby-progressbar (~> 1.7)
|
|
141
|
-
unicode-display_width (>=
|
|
142
|
-
rubocop-ast (1.
|
|
143
|
-
parser (>= 3.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
227
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
228
|
+
rubocop-ast (1.49.1)
|
|
229
|
+
parser (>= 3.3.7.2)
|
|
230
|
+
prism (~> 1.7)
|
|
231
|
+
rubocop-performance (1.26.1)
|
|
232
|
+
lint_roller (~> 1.1)
|
|
233
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
234
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
235
|
+
ruby-progressbar (1.13.0)
|
|
236
|
+
securerandom (0.4.1)
|
|
237
|
+
simplecov (0.22.0)
|
|
149
238
|
docile (~> 1.1)
|
|
150
239
|
simplecov-html (~> 0.11)
|
|
151
240
|
simplecov_json_formatter (~> 0.1)
|
|
152
|
-
simplecov-html (0.
|
|
153
|
-
simplecov_json_formatter (0.1.
|
|
154
|
-
sqlite3 (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
241
|
+
simplecov-html (0.13.2)
|
|
242
|
+
simplecov_json_formatter (0.1.4)
|
|
243
|
+
sqlite3 (2.9.4-aarch64-linux-gnu)
|
|
244
|
+
sqlite3 (2.9.4-aarch64-linux-musl)
|
|
245
|
+
sqlite3 (2.9.4-arm-linux-gnu)
|
|
246
|
+
sqlite3 (2.9.4-arm-linux-musl)
|
|
247
|
+
sqlite3 (2.9.4-arm64-darwin)
|
|
248
|
+
sqlite3 (2.9.4-x86_64-darwin)
|
|
249
|
+
sqlite3 (2.9.4-x86_64-linux-gnu)
|
|
250
|
+
sqlite3 (2.9.4-x86_64-linux-musl)
|
|
251
|
+
standard (1.54.0)
|
|
252
|
+
language_server-protocol (~> 3.17.0.2)
|
|
253
|
+
lint_roller (~> 1.0)
|
|
254
|
+
rubocop (~> 1.84.0)
|
|
255
|
+
standard-custom (~> 1.0.0)
|
|
256
|
+
standard-performance (~> 1.8)
|
|
257
|
+
standard-custom (1.0.2)
|
|
258
|
+
lint_roller (~> 1.0)
|
|
259
|
+
rubocop (~> 1.50)
|
|
260
|
+
standard-performance (1.9.0)
|
|
261
|
+
lint_roller (~> 1.1)
|
|
262
|
+
rubocop-performance (~> 1.26.0)
|
|
263
|
+
stringio (3.2.0)
|
|
264
|
+
thor (1.5.0)
|
|
265
|
+
timeout (0.6.1)
|
|
266
|
+
tsort (0.2.0)
|
|
267
|
+
tzinfo (2.0.6)
|
|
160
268
|
concurrent-ruby (~> 1.0)
|
|
161
|
-
unicode-display_width (2.0
|
|
162
|
-
|
|
269
|
+
unicode-display_width (3.2.0)
|
|
270
|
+
unicode-emoji (~> 4.1)
|
|
271
|
+
unicode-emoji (4.2.0)
|
|
272
|
+
uri (1.1.1)
|
|
273
|
+
useragent (0.16.11)
|
|
274
|
+
vcr (6.4.0)
|
|
163
275
|
warden (1.2.9)
|
|
164
276
|
rack (>= 2.0.9)
|
|
165
|
-
webmock (3.
|
|
166
|
-
addressable (>= 2.
|
|
277
|
+
webmock (3.26.2)
|
|
278
|
+
addressable (>= 2.8.0)
|
|
167
279
|
crack (>= 0.3.2)
|
|
168
280
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
169
|
-
zeitwerk (2.
|
|
281
|
+
zeitwerk (2.8.2)
|
|
170
282
|
|
|
171
283
|
PLATFORMS
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
284
|
+
aarch64-linux-gnu
|
|
285
|
+
aarch64-linux-musl
|
|
286
|
+
arm-linux-gnu
|
|
287
|
+
arm-linux-musl
|
|
288
|
+
arm64-darwin
|
|
289
|
+
x86_64-darwin
|
|
290
|
+
x86_64-linux-gnu
|
|
291
|
+
x86_64-linux-musl
|
|
175
292
|
|
|
176
293
|
DEPENDENCIES
|
|
177
294
|
actionmailer
|
|
178
295
|
activerecord
|
|
179
|
-
appraisal (~> 2.3.0)
|
|
180
296
|
byebug
|
|
297
|
+
castle-rb!
|
|
181
298
|
castle_devise!
|
|
182
|
-
|
|
299
|
+
devise (~> 5.0)
|
|
300
|
+
railties (~> 8.1)
|
|
183
301
|
rake
|
|
184
302
|
rspec
|
|
185
303
|
rspec-rails
|
|
186
304
|
simplecov
|
|
187
|
-
sqlite3
|
|
305
|
+
sqlite3 (~> 2.1)
|
|
188
306
|
standard
|
|
189
307
|
vcr
|
|
190
308
|
webmock
|
|
191
309
|
|
|
192
310
|
BUNDLED WITH
|
|
193
|
-
2.2
|
|
311
|
+
2.7.2
|
data/README.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
[](https://badge.fury.io/rb/castle_devise)
|
|
2
2
|
|
|
3
|
-
**Disclaimer:** CastleDevise is currently in beta. There might be some upcoming breaking changes to the gem before we stabilize the API.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
3
|
# CastleDevise
|
|
8
4
|
|
|
9
5
|
CastleDevise is a [Devise](https://github.com/heartcombo/devise) plugin that integrates [Castle](https://castle.io).
|
|
@@ -211,3 +207,26 @@ CastleDevise.configure do |config|
|
|
|
211
207
|
end
|
|
212
208
|
end
|
|
213
209
|
```
|
|
210
|
+
|
|
211
|
+
## Development
|
|
212
|
+
|
|
213
|
+
### Setup
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
bundle install
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Running tests
|
|
220
|
+
|
|
221
|
+
Most of the specs should pass just by running the following command:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
bundle exec rake
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
We also have a few VCR tests that will periodically rebuild the cassettes just to make sure that the integration with Castle API is working.
|
|
228
|
+
For those, you need to run your specs with a proper Castle API Secret:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
CASTLE_API_SECRET=your_api_secret bundle exec rake
|
|
232
|
+
```
|
data/bin/console
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "bundler/setup"
|
|
5
|
-
require "
|
|
5
|
+
require "castle_devise"
|
|
6
6
|
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
data/castle_devise.gemspec
CHANGED
|
@@ -9,10 +9,10 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.summary = "Integrates Castle with Devise"
|
|
10
10
|
spec.description = "castle_devise provides out-of-the-box protection against bot registrations and account takeover attacks."
|
|
11
11
|
spec.homepage = "https://github.com/castle/castle_devise"
|
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
|
13
13
|
|
|
14
|
-
spec.authors = ["Kacper Madej", "Dawid Libiszewski", "Johan Brissmyr"]
|
|
15
|
-
spec.email = ["
|
|
14
|
+
spec.authors = ["Kacper Madej", "Dawid Libiszewski", "Bartosz Knapik", "Johan Brissmyr"]
|
|
15
|
+
spec.email = ["team@castle.io"]
|
|
16
16
|
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/castle/castle_devise"
|
|
@@ -27,9 +27,7 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
28
28
|
spec.require_paths = ["lib"]
|
|
29
29
|
|
|
30
|
-
spec.add_dependency "activesupport", ">=
|
|
31
|
-
spec.add_dependency "castle-rb", ">= 7.
|
|
32
|
-
spec.add_dependency "devise", ">= 4.3.0", "<
|
|
33
|
-
|
|
34
|
-
spec.add_development_dependency "appraisal", "~> 2.3.0"
|
|
30
|
+
spec.add_dependency "activesupport", ">= 6.0"
|
|
31
|
+
spec.add_dependency "castle-rb", ">= 7.2", "< 10.0"
|
|
32
|
+
spec.add_dependency "devise", ">= 4.3.0", "< 6.0"
|
|
35
33
|
end
|
data/gemfiles/rails_6.0.gemfile
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
1
|
source "https://rubygems.org"
|
|
4
2
|
|
|
5
3
|
gem "actionmailer"
|
|
6
4
|
gem "activerecord"
|
|
7
|
-
gem "
|
|
5
|
+
gem "byebug"
|
|
6
|
+
gem "railties", "~> 6.0"
|
|
8
7
|
gem "rake"
|
|
9
8
|
gem "rspec"
|
|
10
9
|
gem "rspec-rails"
|
|
11
10
|
gem "simplecov"
|
|
12
11
|
gem "standard"
|
|
13
|
-
gem "sqlite3"
|
|
12
|
+
gem "sqlite3", "~> 1.7"
|
|
14
13
|
gem "vcr"
|
|
15
14
|
gem "webmock"
|
|
15
|
+
gem "mutex_m"
|
|
16
|
+
gem "logger"
|
|
16
17
|
|
|
17
18
|
gemspec path: "../"
|
data/gemfiles/rails_6.1.gemfile
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
1
|
source "https://rubygems.org"
|
|
4
2
|
|
|
5
3
|
gem "actionmailer"
|
|
6
4
|
gem "activerecord"
|
|
7
|
-
gem "
|
|
5
|
+
gem "byebug"
|
|
6
|
+
gem "railties", "~> 6.1"
|
|
8
7
|
gem "rake"
|
|
9
8
|
gem "rspec"
|
|
10
9
|
gem "rspec-rails"
|
|
11
10
|
gem "simplecov"
|
|
12
11
|
gem "standard"
|
|
13
|
-
gem "sqlite3"
|
|
12
|
+
gem "sqlite3", "~> 1.7"
|
|
14
13
|
gem "vcr"
|
|
15
14
|
gem "webmock"
|
|
15
|
+
gem "mutex_m"
|
|
16
|
+
gem "logger"
|
|
16
17
|
|
|
17
18
|
gemspec path: "../"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem "actionmailer"
|
|
4
|
+
gem "activerecord"
|
|
5
|
+
gem "byebug"
|
|
6
|
+
gem "railties", "~> 7.0"
|
|
7
|
+
gem "rake"
|
|
8
|
+
gem "rspec"
|
|
9
|
+
gem "rspec-rails"
|
|
10
|
+
gem "simplecov"
|
|
11
|
+
gem "standard"
|
|
12
|
+
gem "sqlite3", "~> 1.7"
|
|
13
|
+
gem "vcr"
|
|
14
|
+
gem "webmock"
|
|
15
|
+
gem "mutex_m"
|
|
16
|
+
gem "logger"
|
|
17
|
+
|
|
18
|
+
gemspec path: "../"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem "actionmailer"
|
|
4
|
+
gem "activerecord"
|
|
5
|
+
gem "byebug"
|
|
6
|
+
gem "railties", "~> 7.1"
|
|
7
|
+
gem "rake"
|
|
8
|
+
gem "rspec"
|
|
9
|
+
gem "rspec-rails"
|
|
10
|
+
gem "simplecov"
|
|
11
|
+
gem "standard"
|
|
12
|
+
gem "sqlite3", "~> 1.7"
|
|
13
|
+
gem "vcr"
|
|
14
|
+
gem "webmock"
|
|
15
|
+
gem "mutex_m"
|
|
16
|
+
gem "logger"
|
|
17
|
+
|
|
18
|
+
gemspec path: "../"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem "actionmailer"
|
|
4
|
+
gem "activerecord"
|
|
5
|
+
gem "byebug"
|
|
6
|
+
gem "railties", "~> 7.2"
|
|
7
|
+
gem "rake"
|
|
8
|
+
gem "rspec"
|
|
9
|
+
gem "rspec-rails"
|
|
10
|
+
gem "simplecov"
|
|
11
|
+
gem "standard"
|
|
12
|
+
gem "sqlite3", "~> 1.7"
|
|
13
|
+
gem "vcr"
|
|
14
|
+
gem "webmock"
|
|
15
|
+
gem "mutex_m"
|
|
16
|
+
gem "logger"
|
|
17
|
+
|
|
18
|
+
gemspec path: "../"
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
# This file was generated by Appraisal
|
|
2
|
-
|
|
3
1
|
source "https://rubygems.org"
|
|
4
2
|
|
|
5
3
|
gem "actionmailer"
|
|
6
4
|
gem "activerecord"
|
|
7
|
-
gem "
|
|
5
|
+
gem "byebug"
|
|
6
|
+
gem "railties", "~> 8.0.0"
|
|
8
7
|
gem "rake"
|
|
9
8
|
gem "rspec"
|
|
10
9
|
gem "rspec-rails"
|
|
@@ -13,5 +12,7 @@ gem "standard"
|
|
|
13
12
|
gem "sqlite3"
|
|
14
13
|
gem "vcr"
|
|
15
14
|
gem "webmock"
|
|
15
|
+
gem "mutex_m"
|
|
16
|
+
gem "logger"
|
|
16
17
|
|
|
17
18
|
gemspec path: "../"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gem "actionmailer"
|
|
4
|
+
gem "activerecord"
|
|
5
|
+
gem "byebug"
|
|
6
|
+
gem "devise", "~> 5.0"
|
|
7
|
+
gem "railties", "~> 8.1.0"
|
|
8
|
+
gem "rake"
|
|
9
|
+
gem "rspec"
|
|
10
|
+
gem "rspec-rails"
|
|
11
|
+
gem "simplecov"
|
|
12
|
+
gem "standard"
|
|
13
|
+
gem "sqlite3"
|
|
14
|
+
gem "vcr"
|
|
15
|
+
gem "webmock"
|
|
16
|
+
|
|
17
|
+
gemspec path: "../"
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "active_support/configurable"
|
|
4
3
|
require "logger"
|
|
5
4
|
|
|
6
5
|
module CastleDevise
|
|
7
|
-
#
|
|
6
|
+
# Plain Ruby configuration object for CastleDevise.
|
|
7
|
+
#
|
|
8
|
+
# Previously this used +ActiveSupport::Configurable+, which is deprecated
|
|
9
|
+
# and slated for removal in Rails 8.2.
|
|
8
10
|
class Configuration
|
|
9
|
-
include ActiveSupport::Configurable
|
|
10
|
-
|
|
11
11
|
# @!attribute api_secret
|
|
12
12
|
# @return [String] Your API secret
|
|
13
|
-
|
|
13
|
+
attr_accessor :api_secret
|
|
14
14
|
|
|
15
15
|
# @!attribute app_id
|
|
16
16
|
# @return [String] Your Castle App ID
|
|
17
|
-
|
|
17
|
+
attr_accessor :app_id
|
|
18
18
|
|
|
19
19
|
# @!attribute monitoring_mode
|
|
20
20
|
# When CastleDevise is in monitoring mode, it sends requests to Castle
|
|
@@ -25,27 +25,41 @@ module CastleDevise
|
|
|
25
25
|
# from logging in/registering.
|
|
26
26
|
#
|
|
27
27
|
# @return [true, false] whether to act on deny requests or not
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# @!attribute logger
|
|
31
|
-
# @return [Logger] A Logger instance. You might want to use Rails.logger here.
|
|
32
|
-
config_accessor(:logger) { Logger.new("/dev/null") }
|
|
28
|
+
attr_accessor :monitoring_mode
|
|
33
29
|
|
|
34
30
|
# @!attribute before_request_hooks
|
|
35
31
|
# @return [Array<Proc>] Array of procs that will get called before a request to the Castle API
|
|
36
|
-
|
|
32
|
+
attr_accessor :before_request_hooks
|
|
37
33
|
|
|
38
34
|
# @!attribute after_request_hooks
|
|
39
35
|
# @return [Array<Proc>] Array of procs that will get called after a request to the Castle API
|
|
40
|
-
|
|
36
|
+
attr_accessor :after_request_hooks
|
|
37
|
+
|
|
38
|
+
attr_writer :logger, :castle_sdk_facade_class, :castle_client
|
|
39
|
+
|
|
40
|
+
def initialize
|
|
41
|
+
@monitoring_mode = false
|
|
42
|
+
@before_request_hooks = []
|
|
43
|
+
@after_request_hooks = []
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @!attribute logger
|
|
47
|
+
# @return [Logger] A Logger instance. You might want to use Rails.logger here.
|
|
48
|
+
def logger
|
|
49
|
+
@logger ||= Logger.new(File::NULL)
|
|
50
|
+
end
|
|
41
51
|
|
|
42
52
|
# @!attribute castle_sdk_facade_class
|
|
43
53
|
# @return [Class] Castle API implementation
|
|
44
|
-
|
|
54
|
+
def castle_sdk_facade_class
|
|
55
|
+
@castle_sdk_facade_class ||= ::CastleDevise::SdkFacade
|
|
56
|
+
end
|
|
45
57
|
|
|
46
58
|
# @!attribute castle_client
|
|
47
|
-
# @return [
|
|
48
|
-
|
|
59
|
+
# @return [Castle::Client] Castle SDK client
|
|
60
|
+
def castle_client
|
|
61
|
+
@castle_client ||= ::Castle::Client.new
|
|
62
|
+
end
|
|
49
63
|
|
|
50
64
|
# Adds a new before_request hook
|
|
51
65
|
# @param blk [Proc]
|
|
@@ -23,9 +23,11 @@ Warden::Manager.after_authentication do |resource, warden, opts|
|
|
|
23
23
|
context.logout!
|
|
24
24
|
end
|
|
25
25
|
rescue Castle::InvalidParametersError
|
|
26
|
-
#
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
# log API error and allow
|
|
27
|
+
CastleDevise.logger.warn(
|
|
28
|
+
"[CastleDevise] /v1/risk request contained invalid parameters."
|
|
29
|
+
)
|
|
30
|
+
rescue Castle::InvalidRequestTokenError
|
|
29
31
|
CastleDevise.logger.warn(
|
|
30
32
|
"[CastleDevise] /v1/risk request contained invalid parameters." \
|
|
31
33
|
" This might mean that either you didn't configure Castle's Javascript properly, or" \
|
|
@@ -42,6 +44,9 @@ end
|
|
|
42
44
|
|
|
43
45
|
Warden::Manager.before_failure do |env, opts|
|
|
44
46
|
next if opts[:castle_devise] == :skip
|
|
47
|
+
# recall is set by Devise on a failed login attempt. If it's not set, this hook might fire on any
|
|
48
|
+
# authentication failure attempt (eg. trying to access a resource while unauthenticated), not just login specifically
|
|
49
|
+
next unless opts.key?(:recall)
|
|
45
50
|
|
|
46
51
|
resource_class = Devise.mappings[opts[:scope]].to
|
|
47
52
|
|
|
@@ -58,6 +63,6 @@ Warden::Manager.before_failure do |env, opts|
|
|
|
58
63
|
context: context
|
|
59
64
|
)
|
|
60
65
|
rescue Castle::Error => e
|
|
61
|
-
CastleDevise.logger.
|
|
66
|
+
CastleDevise.logger.warn("[CastleDevise] filter($login, $failed): #{e}")
|
|
62
67
|
end
|
|
63
68
|
end
|
|
@@ -28,16 +28,19 @@ module CastleDevise
|
|
|
28
28
|
context: context
|
|
29
29
|
)
|
|
30
30
|
rescue Castle::InvalidParametersError
|
|
31
|
-
#
|
|
32
|
-
# compared to any other validation errors. However, we can't do this with the
|
|
33
|
-
# current Castle SDK as it doesn't give us any way to differentiate these two cases.
|
|
31
|
+
# log API error and allow
|
|
34
32
|
CastleDevise.logger.warn(
|
|
35
|
-
"[CastleDevise] /v1/risk request contained invalid parameters."
|
|
36
|
-
|
|
33
|
+
"[CastleDevise] /v1/risk request contained invalid parameters."
|
|
34
|
+
)
|
|
35
|
+
rescue Castle::InvalidRequestTokenError
|
|
36
|
+
CastleDevise.logger.warn(
|
|
37
|
+
"[CastleDevise] /v1/risk request contained invalid token." \
|
|
38
|
+
" This means that either you didn't configure Castle's Javascript properly," \
|
|
37
39
|
" or a request has been made without Javascript (eg. cURL/bot)." \
|
|
38
40
|
" Such a request is treated as if Castle responded with a 'deny' action in" \
|
|
39
41
|
" non-monitoring mode."
|
|
40
42
|
)
|
|
43
|
+
# TODO: Implement a deny mechanism for this action.
|
|
41
44
|
rescue Castle::Error => e
|
|
42
45
|
# log API errors and allow
|
|
43
46
|
CastleDevise.logger.error("[CastleDevise] risk($profile_update): #{e}")
|
|
@@ -81,12 +84,14 @@ module CastleDevise
|
|
|
81
84
|
# everything fine, continue
|
|
82
85
|
end
|
|
83
86
|
rescue Castle::InvalidParametersError
|
|
84
|
-
#
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
# log error and allow
|
|
88
|
+
CastleDevise.logger.warn(
|
|
89
|
+
"[CastleDevise] /v1/filter request contained invalid parameters."
|
|
90
|
+
)
|
|
91
|
+
rescue Castle::InvalidRequestTokenError
|
|
87
92
|
CastleDevise.logger.warn(
|
|
88
|
-
"[CastleDevise] /v1/filter request contained invalid
|
|
89
|
-
" This
|
|
93
|
+
"[CastleDevise] /v1/filter request contained invalid request token." \
|
|
94
|
+
" This means that either you didn't configure Castle's Javascript properly, or" \
|
|
90
95
|
" a request has been made without Javascript (eg. cURL/bot)." \
|
|
91
96
|
" Such a request is treated as if Castle responded with a 'deny' action in" \
|
|
92
97
|
" non-monitoring mode."
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: castle_devise
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kacper Madej
|
|
8
8
|
- Dawid Libiszewski
|
|
9
|
+
- Bartosz Knapik
|
|
9
10
|
- Johan Brissmyr
|
|
10
|
-
autorequire:
|
|
11
11
|
bindir: exe
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|
|
@@ -18,34 +18,34 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - ">="
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '
|
|
21
|
+
version: '6.0'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: '
|
|
28
|
+
version: '6.0'
|
|
29
29
|
- !ruby/object:Gem::Dependency
|
|
30
30
|
name: castle-rb
|
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
|
32
32
|
requirements:
|
|
33
33
|
- - ">="
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: '7.
|
|
35
|
+
version: '7.2'
|
|
36
36
|
- - "<"
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: '
|
|
38
|
+
version: '10.0'
|
|
39
39
|
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - ">="
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '7.
|
|
45
|
+
version: '7.2'
|
|
46
46
|
- - "<"
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '
|
|
48
|
+
version: '10.0'
|
|
49
49
|
- !ruby/object:Gem::Dependency
|
|
50
50
|
name: devise
|
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -55,7 +55,7 @@ dependencies:
|
|
|
55
55
|
version: 4.3.0
|
|
56
56
|
- - "<"
|
|
57
57
|
- !ruby/object:Gem::Version
|
|
58
|
-
version: '
|
|
58
|
+
version: '6.0'
|
|
59
59
|
type: :runtime
|
|
60
60
|
prerelease: false
|
|
61
61
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -65,25 +65,11 @@ dependencies:
|
|
|
65
65
|
version: 4.3.0
|
|
66
66
|
- - "<"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: appraisal
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: 2.3.0
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: 2.3.0
|
|
68
|
+
version: '6.0'
|
|
83
69
|
description: castle_devise provides out-of-the-box protection against bot registrations
|
|
84
70
|
and account takeover attacks.
|
|
85
71
|
email:
|
|
86
|
-
-
|
|
72
|
+
- team@castle.io
|
|
87
73
|
executables: []
|
|
88
74
|
extensions: []
|
|
89
75
|
extra_rdoc_files: []
|
|
@@ -91,8 +77,9 @@ files:
|
|
|
91
77
|
- ".github/workflows/lint.yml"
|
|
92
78
|
- ".github/workflows/specs.yml"
|
|
93
79
|
- ".gitignore"
|
|
80
|
+
- ".octocov.yml"
|
|
94
81
|
- ".rspec"
|
|
95
|
-
-
|
|
82
|
+
- ".standard.yml"
|
|
96
83
|
- CHANGELOG.md
|
|
97
84
|
- Gemfile
|
|
98
85
|
- Gemfile.lock
|
|
@@ -102,9 +89,13 @@ files:
|
|
|
102
89
|
- bin/console
|
|
103
90
|
- bin/setup
|
|
104
91
|
- castle_devise.gemspec
|
|
105
|
-
- gemfiles/rails_5.2.gemfile
|
|
106
92
|
- gemfiles/rails_6.0.gemfile
|
|
107
93
|
- gemfiles/rails_6.1.gemfile
|
|
94
|
+
- gemfiles/rails_7.0.gemfile
|
|
95
|
+
- gemfiles/rails_7.1.gemfile
|
|
96
|
+
- gemfiles/rails_7.2.gemfile
|
|
97
|
+
- gemfiles/rails_8.0.gemfile
|
|
98
|
+
- gemfiles/rails_8.1.gemfile
|
|
108
99
|
- lib/castle_devise.rb
|
|
109
100
|
- lib/castle_devise/configuration.rb
|
|
110
101
|
- lib/castle_devise/context.rb
|
|
@@ -125,7 +116,6 @@ metadata:
|
|
|
125
116
|
homepage_uri: https://github.com/castle/castle_devise
|
|
126
117
|
source_code_uri: https://github.com/castle/castle_devise
|
|
127
118
|
changelog_uri: https://github.com/castle/castle_devise/CHANGELOG.md
|
|
128
|
-
post_install_message:
|
|
129
119
|
rdoc_options: []
|
|
130
120
|
require_paths:
|
|
131
121
|
- lib
|
|
@@ -133,15 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
133
123
|
requirements:
|
|
134
124
|
- - ">="
|
|
135
125
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: 2.
|
|
126
|
+
version: 3.2.0
|
|
137
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
128
|
requirements:
|
|
139
129
|
- - ">="
|
|
140
130
|
- !ruby/object:Gem::Version
|
|
141
131
|
version: '0'
|
|
142
132
|
requirements: []
|
|
143
|
-
rubygems_version:
|
|
144
|
-
signing_key:
|
|
133
|
+
rubygems_version: 4.0.8
|
|
145
134
|
specification_version: 4
|
|
146
135
|
summary: Integrates Castle with Devise
|
|
147
136
|
test_files: []
|