verikloak-rails 0.3.0 → 0.3.1
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 +19 -0
- data/README.md +10 -0
- data/lib/generators/verikloak/install/templates/initializer.rb.erb +20 -5
- data/lib/verikloak/rails/railtie.rb +8 -2
- data/lib/verikloak/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7bac28bdf7982aa61a3512e8af5f213c550dd68556af1e96e0654a8033d8d0d
|
|
4
|
+
data.tar.gz: 926fe82895004cb6ee2dcc4c55fe3138dc879e08ef59bf94a31a6b634c379348
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc7cf3ca6c356a17d28744402b22b0e2118ab8ec0c33a2e230b34613db8b935ccae635fe11094916ae2a58bb255523162eccd1c93bb57f39498f977343a30348
|
|
7
|
+
data.tar.gz: ea2d296e2845db7d01b128ee573865279e89544b1068c0fd05d302e1f6618c62d6bf051c91fbf6eb05f629aa9ab224a86353c623f76114a962bedf321bb58e66
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [0.3.1] - 2026-01-01
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **API mode support**: `auto_include_controller` now automatically includes
|
|
14
|
+
`Verikloak::Rails::Controller` in both `ActionController::Base` and `ActionController::API`
|
|
15
|
+
- Rails API-only applications (`rails new myapp --api`) now work out of the box
|
|
16
|
+
- Skip logic prevents duplicate inclusion when controller already includes the concern
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- **Generator template improved**: `initializer.rb.erb` now includes:
|
|
20
|
+
- Descriptive comments for each configuration option
|
|
21
|
+
- ENV variable support for `auto_include_controller` (`VERIKLOAK_AUTO_INCLUDE`)
|
|
22
|
+
- ENV variable prefix changed from `VERIKLOAK_AUDIENCE` to `KEYCLOAK_AUDIENCE` for consistency
|
|
23
|
+
|
|
24
|
+
### Documentation
|
|
25
|
+
- README updated with API mode usage example
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
10
29
|
## [0.3.0] - 2026-01-01
|
|
11
30
|
|
|
12
31
|
### Changed
|
data/README.md
CHANGED
|
@@ -108,6 +108,16 @@ class ApplicationController < ActionController::Base
|
|
|
108
108
|
end
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
+
### API Mode Support
|
|
112
|
+
Both `ActionController::Base` and `ActionController::API` are supported. The controller concern is automatically included in both when `auto_include_controller` is enabled (default).
|
|
113
|
+
|
|
114
|
+
```ruby
|
|
115
|
+
# Works automatically with Rails API mode (rails new myapp --api)
|
|
116
|
+
class ApplicationController < ActionController::API
|
|
117
|
+
# Verikloak::Rails::Controller is auto-included
|
|
118
|
+
end
|
|
119
|
+
```
|
|
120
|
+
|
|
111
121
|
## Middleware
|
|
112
122
|
### Inserted Middleware
|
|
113
123
|
| Component | Inserted relative to | Purpose |
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
Rails.application.configure do
|
|
4
|
+
# Discovery URL (required)
|
|
4
5
|
config.verikloak.discovery_url = ENV.fetch('KEYCLOAK_DISCOVERY_URL', nil)
|
|
5
|
-
config.verikloak.audience = ENV.fetch('VERIKLOAK_AUDIENCE', 'rails-api')
|
|
6
|
-
config.verikloak.issuer = ENV.fetch('VERIKLOAK_ISSUER', nil)
|
|
7
|
-
config.verikloak.leeway = Integer(ENV.fetch('VERIKLOAK_LEEWAY', '60'))
|
|
8
|
-
config.verikloak.skip_paths = %w[/up /health /rails/health]
|
|
9
6
|
|
|
7
|
+
# Audience validation (optional but recommended)
|
|
8
|
+
config.verikloak.audience = ENV.fetch('KEYCLOAK_AUDIENCE', 'rails-api')
|
|
9
|
+
|
|
10
|
+
# Issuer validation (optional, derived from discovery_url if not set)
|
|
11
|
+
config.verikloak.issuer = ENV.fetch('KEYCLOAK_ISSUER', nil)
|
|
12
|
+
|
|
13
|
+
# JWT clock skew tolerance in seconds
|
|
14
|
+
config.verikloak.leeway = Integer(ENV.fetch('VERIKLOAK_LEEWAY', '60'))
|
|
15
|
+
|
|
16
|
+
# Paths to skip authentication (health checks, etc.)
|
|
17
|
+
config.verikloak.skip_paths = %w[/up /health /rails/health]
|
|
18
|
+
|
|
19
|
+
# Request ID and subject in logs
|
|
10
20
|
config.verikloak.logger_tags = %i[request_id sub]
|
|
11
|
-
|
|
21
|
+
|
|
22
|
+
# Auto-include controller concern
|
|
23
|
+
# Set to false if you manually include Verikloak::Rails::Controller
|
|
24
|
+
config.verikloak.auto_include_controller = ENV.fetch('VERIKLOAK_AUTO_INCLUDE', 'true') == 'true'
|
|
25
|
+
|
|
26
|
+
# Render detailed 500 errors (development only recommended)
|
|
12
27
|
config.verikloak.render_500_json = ENV.fetch('VERIKLOAK_RENDER_500', 'false') == 'true'
|
|
13
28
|
|
|
14
29
|
# Optional Pundit rescue (403 JSON). Leave commented so `verikloak-pundit`
|
|
@@ -31,10 +31,16 @@ module Verikloak
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Optionally include the controller concern when ActionController loads.
|
|
34
|
+
# Supports both ActionController::Base and ActionController::API (API mode).
|
|
35
|
+
# Skips inclusion if the controller already includes the concern.
|
|
34
36
|
# @return [void]
|
|
35
37
|
initializer 'verikloak.controller' do |_app|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
%i[action_controller_base action_controller_api].each do |hook|
|
|
39
|
+
ActiveSupport.on_load(hook) do
|
|
40
|
+
next if include?(Verikloak::Rails::Controller) # Already included, skip
|
|
41
|
+
|
|
42
|
+
include Verikloak::Rails::Controller if Verikloak::Rails.config.auto_include_controller
|
|
43
|
+
end
|
|
38
44
|
end
|
|
39
45
|
end
|
|
40
46
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: verikloak-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- taiyaky
|
|
@@ -94,7 +94,7 @@ metadata:
|
|
|
94
94
|
source_code_uri: https://github.com/taiyaky/verikloak-rails
|
|
95
95
|
changelog_uri: https://github.com/taiyaky/verikloak-rails/blob/main/CHANGELOG.md
|
|
96
96
|
bug_tracker_uri: https://github.com/taiyaky/verikloak-rails/issues
|
|
97
|
-
documentation_uri: https://rubydoc.info/gems/verikloak-rails/0.3.
|
|
97
|
+
documentation_uri: https://rubydoc.info/gems/verikloak-rails/0.3.1
|
|
98
98
|
rubygems_mfa_required: 'true'
|
|
99
99
|
rdoc_options: []
|
|
100
100
|
require_paths:
|