verikloak-audience 0.2.0 → 0.2.2
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 +10 -0
- data/lib/verikloak/audience/middleware.rb +13 -1
- data/lib/verikloak/audience/railtie.rb +31 -0
- data/lib/verikloak/audience/version.rb +1 -1
- metadata +4 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1b51d9c244185b84fce77ec939a727cbdd9ac2a93541444c42e0b823ca86f4a3
         | 
| 4 | 
            +
              data.tar.gz: 5c9c5257ab6da299c39ba3d6e0f58f62c6e70ec2e140519abdc2f583e75b0ba3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9b18e302be97ac271c2ebf7cb9891cce250ce01cc2cf91be963e7cf3ef19b3f05a97424073ea3f78db8a7581027ddac322e3004e224c356a27697224cfc866aa
         | 
| 7 | 
            +
              data.tar.gz: 128053a70894be6a243b286aa16299d89c5a05ebc41e6ec13399925732e5cf3b624c06691b9433052c4bb7c12b2da033c3e9f6de5c99815cb74ebff986952adf
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
| 7 7 |  | 
| 8 8 | 
             
            ---
         | 
| 9 9 |  | 
| 10 | 
            +
            ## [0.2.2] - 2025-09-22
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ### Fixed
         | 
| 13 | 
            +
            - Skip middleware configuration validation when Rails generator commands execute so `rails g verikloak:install` can boot without preconfigured audiences.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ## [0.2.1] - 2025-09-22
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            ### Fixed
         | 
| 18 | 
            +
            - Skip configuration validation while Rails generators run so `rails g verikloak:install` can execute before `required_aud` is configured.
         | 
| 19 | 
            +
             | 
| 10 20 | 
             
            ## [0.2.0] - 2025-09-21
         | 
| 11 21 |  | 
| 12 22 | 
             
            ### Added
         | 
| @@ -24,7 +24,7 @@ module Verikloak | |
| 24 24 | 
             
                    @app = app
         | 
| 25 25 | 
             
                    @config = Verikloak::Audience.config.dup
         | 
| 26 26 | 
             
                    apply_overrides!(opts)
         | 
| 27 | 
            -
                    @config.validate!
         | 
| 27 | 
            +
                    @config.validate! unless skip_validation?
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 |  | 
| 30 30 | 
             
                  # Evaluate the request against the audience profile.
         | 
| @@ -70,6 +70,18 @@ module Verikloak | |
| 70 70 | 
             
                    end
         | 
| 71 71 | 
             
                  end
         | 
| 72 72 |  | 
| 73 | 
            +
                  # Determine whether configuration validation should run. This allows
         | 
| 74 | 
            +
                  # Rails generators to boot without a fully-populated configuration since
         | 
| 75 | 
            +
                  # the install task is responsible for creating it.
         | 
| 76 | 
            +
                  #
         | 
| 77 | 
            +
                  # @return [Boolean]
         | 
| 78 | 
            +
                  def skip_validation?
         | 
| 79 | 
            +
                    return false unless defined?(::Verikloak::Audience::Railtie)
         | 
| 80 | 
            +
                    return false unless ::Verikloak::Audience::Railtie.respond_to?(:skip_configuration_validation?)
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                    ::Verikloak::Audience::Railtie.skip_configuration_validation?
         | 
| 83 | 
            +
                  end
         | 
| 84 | 
            +
             | 
| 73 85 | 
             
                  # Emit a warning for failed audience checks using request-scoped loggers
         | 
| 74 86 | 
             
                  # when available.
         | 
| 75 87 | 
             
                  #
         | 
| @@ -35,6 +35,8 @@ module Verikloak | |
| 35 35 |  | 
| 36 36 | 
             
                  initializer 'verikloak_audience.configuration' do
         | 
| 37 37 | 
             
                    config.after_initialize do
         | 
| 38 | 
            +
                      next if Verikloak::Audience::Railtie.skip_configuration_validation?
         | 
| 39 | 
            +
             | 
| 38 40 | 
             
                      Verikloak::Audience.config.validate!
         | 
| 39 41 | 
             
                    end
         | 
| 40 42 | 
             
                  end
         | 
| @@ -50,6 +52,35 @@ module Verikloak | |
| 50 52 |  | 
| 51 53 | 
             
                    app.middleware.insert_after ::Verikloak::Middleware, ::Verikloak::Audience::Middleware
         | 
| 52 54 | 
             
                  end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  COMMANDS_SKIPPING_VALIDATION = %w[generate g destroy d].freeze
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  # Detect whether Rails is currently executing a generator-style command.
         | 
| 59 | 
            +
                  # Generators boot the application before configuration exists, so we
         | 
| 60 | 
            +
                  # temporarily skip validation to let the install task complete.
         | 
| 61 | 
            +
                  #
         | 
| 62 | 
            +
                  # @return [Boolean]
         | 
| 63 | 
            +
                  def self.skip_configuration_validation?
         | 
| 64 | 
            +
                    return false unless defined?(Rails::Generators)
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                    command = first_rails_command
         | 
| 67 | 
            +
                    COMMANDS_SKIPPING_VALIDATION.include?(command)
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  # Capture the first non-option argument passed to the Rails CLI,
         | 
| 71 | 
            +
                  # ignoring wrapper tokens such as "rails".
         | 
| 72 | 
            +
                  #
         | 
| 73 | 
            +
                  # @return [String, nil]
         | 
| 74 | 
            +
                  def self.first_rails_command
         | 
| 75 | 
            +
                    ARGV.each do |arg|
         | 
| 76 | 
            +
                      next if arg.start_with?('-')
         | 
| 77 | 
            +
                      next if arg == 'rails'
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                      return arg
         | 
| 80 | 
            +
                    end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                    nil
         | 
| 83 | 
            +
                  end
         | 
| 53 84 | 
             
                end
         | 
| 54 85 | 
             
              end
         | 
| 55 86 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: verikloak-audience
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - taiyaky
         | 
| @@ -35,7 +35,7 @@ dependencies: | |
| 35 35 | 
             
                requirements:
         | 
| 36 36 | 
             
                - - ">="
         | 
| 37 37 | 
             
                  - !ruby/object:Gem::Version
         | 
| 38 | 
            -
                    version: 0. | 
| 38 | 
            +
                    version: 0.2.0
         | 
| 39 39 | 
             
                - - "<"
         | 
| 40 40 | 
             
                  - !ruby/object:Gem::Version
         | 
| 41 41 | 
             
                    version: 1.0.0
         | 
| @@ -45,7 +45,7 @@ dependencies: | |
| 45 45 | 
             
                requirements:
         | 
| 46 46 | 
             
                - - ">="
         | 
| 47 47 | 
             
                  - !ruby/object:Gem::Version
         | 
| 48 | 
            -
                    version: 0. | 
| 48 | 
            +
                    version: 0.2.0
         | 
| 49 49 | 
             
                - - "<"
         | 
| 50 50 | 
             
                  - !ruby/object:Gem::Version
         | 
| 51 51 | 
             
                    version: 1.0.0
         | 
| @@ -74,7 +74,7 @@ metadata: | |
| 74 74 | 
             
              source_code_uri: https://github.com/taiyaky/verikloak-audience
         | 
| 75 75 | 
             
              changelog_uri: https://github.com/taiyaky/verikloak-audience/blob/main/CHANGELOG.md
         | 
| 76 76 | 
             
              bug_tracker_uri: https://github.com/taiyaky/verikloak-audience/issues
         | 
| 77 | 
            -
              documentation_uri: https://rubydoc.info/gems/verikloak-audience/0.2. | 
| 77 | 
            +
              documentation_uri: https://rubydoc.info/gems/verikloak-audience/0.2.2
         | 
| 78 78 | 
             
              rubygems_mfa_required: 'true'
         | 
| 79 79 | 
             
            rdoc_options: []
         | 
| 80 80 | 
             
            require_paths:
         |