zaikio-jwt_auth 2.4.0 → 2.5.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/lib/zaikio/jwt_auth/directory_cache.rb +1 -1
 - data/lib/zaikio/jwt_auth/version.rb +1 -1
 - data/lib/zaikio/jwt_auth.rb +16 -14
 - 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: 2973a0c217c47da109e5a5023a7a430a153c8b61dae1a0ab21d24511420c209a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: adbf5e6c3beb55f437ba68f04966186b0b6c886d4cb78b0db3ce294dc8d99710
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7a30f36608a792d86bd839402b17b3ad6b0ae4aa2554f53f23bf80c70526763a756a2cc727c8b5043687535353886f63e80759a84999d2e1b399cb6646a8da52
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f40fa02553e687c3d2d653e35c0c4a6d43e2bcc14e2f46328127ae78960e9d8a95303cb735aa65f43797d6a29613d1d3fa3891cb88c31027377ff49ea2fbf4ce
         
     | 
| 
         @@ -5,7 +5,7 @@ require "logger" 
     | 
|
| 
       5 
5 
     | 
    
         
             
            module Zaikio
         
     | 
| 
       6 
6 
     | 
    
         
             
              module JWTAuth
         
     | 
| 
       7 
7 
     | 
    
         
             
                class DirectoryCache
         
     | 
| 
       8 
     | 
    
         
            -
                  class UpdateJob < ::ActiveJob::Base
         
     | 
| 
      
 8 
     | 
    
         
            +
                  class UpdateJob < ::ActiveJob::Base # rubocop:disable Rails/ApplicationJob
         
     | 
| 
       9 
9 
     | 
    
         
             
                    def perform(directory_path)
         
     | 
| 
       10 
10 
     | 
    
         
             
                      DirectoryCache.fetch(directory_path)
         
     | 
| 
       11 
11 
     | 
    
         
             
                      true # This job will always re-queue until it succeeds.
         
     | 
    
        data/lib/zaikio/jwt_auth.rb
    CHANGED
    
    | 
         @@ -119,7 +119,7 @@ module Zaikio 
     | 
|
| 
       119 
119 
     | 
    
         
             
                  end
         
     | 
| 
       120 
120 
     | 
    
         | 
| 
       121 
121 
     | 
    
         
             
                  def update_revoked_access_tokens_by_webhook
         
     | 
| 
       122 
     | 
    
         
            -
                    return unless params[:name] 
     | 
| 
      
 122 
     | 
    
         
            +
                    return unless %w[directory.revoked_access_token zaikio.revoked_access_token].include?(params[:name])
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
       124 
124 
     | 
    
         
             
                    DirectoryCache.update("api/v1/revoked_access_tokens.json", expires_after: 60.minutes) do |data|
         
     | 
| 
       125 
125 
     | 
    
         
             
                      data["revoked_token_ids"] << params[:payload][:access_token_id]
         
     | 
| 
         @@ -131,8 +131,8 @@ module Zaikio 
     | 
|
| 
       131 
131 
     | 
    
         | 
| 
       132 
132 
     | 
    
         
             
                  private
         
     | 
| 
       133 
133 
     | 
    
         | 
| 
       134 
     | 
    
         
            -
                  def  
     | 
| 
       135 
     | 
    
         
            -
                    scope_configurations. 
     | 
| 
      
 134 
     | 
    
         
            +
                  def find_scope_configurations(scope_configurations)
         
     | 
| 
      
 135 
     | 
    
         
            +
                    scope_configurations.select do |scope_configuration|
         
     | 
| 
       136 
136 
     | 
    
         
             
                      action_matches = action_matches_config?(scope_configuration)
         
     | 
| 
       137 
137 
     | 
    
         | 
| 
       138 
138 
     | 
    
         
             
                      if action_matches && scope_configuration[:if] && !instance_exec(&scope_configuration[:if])
         
     | 
| 
         @@ -169,21 +169,23 @@ module Zaikio 
     | 
|
| 
       169 
169 
     | 
    
         
             
                  end
         
     | 
| 
       170 
170 
     | 
    
         | 
| 
       171 
171 
     | 
    
         
             
                  def show_error_if_authorize_by_jwt_scopes_fails(token_data)
         
     | 
| 
       172 
     | 
    
         
            -
                     
     | 
| 
      
 172 
     | 
    
         
            +
                    configurations = find_scope_configurations(self.class.authorize_by_jwt_scopes)
         
     | 
| 
       173 
173 
     | 
    
         | 
| 
       174 
     | 
    
         
            -
                    return if  
     | 
| 
       175 
     | 
    
         
            -
                      configuration,
         
     | 
| 
       176 
     | 
    
         
            -
                      action_name
         
     | 
| 
       177 
     | 
    
         
            -
                    )
         
     | 
| 
      
 174 
     | 
    
         
            +
                    return if configurations.empty?
         
     | 
| 
       178 
175 
     | 
    
         | 
| 
       179 
     | 
    
         
            -
                     
     | 
| 
      
 176 
     | 
    
         
            +
                    configuration = configurations.find do |scope_configuration|
         
     | 
| 
      
 177 
     | 
    
         
            +
                      token_data.scope_by_configurations?(
         
     | 
| 
      
 178 
     | 
    
         
            +
                        scope_configuration,
         
     | 
| 
      
 179 
     | 
    
         
            +
                        action_name
         
     | 
| 
      
 180 
     | 
    
         
            +
                      )
         
     | 
| 
      
 181 
     | 
    
         
            +
                    end
         
     | 
| 
       180 
182 
     | 
    
         | 
| 
       181 
     | 
    
         
            -
                    if configuration
         
     | 
| 
       182 
     | 
    
         
            -
                      required_scopes = required_scopes(token_data, configuration)
         
     | 
| 
      
 183 
     | 
    
         
            +
                    return if configuration
         
     | 
| 
       183 
184 
     | 
    
         | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
                     
     | 
| 
      
 185 
     | 
    
         
            +
                    required_scopes = required_scopes(token_data, configuration || configurations.first)
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                    details = "This endpoint requires one of the following scopes: #{required_scopes.join(', ')} but your " \
         
     | 
| 
      
 188 
     | 
    
         
            +
                    "access token only includes the following scopes: #{token_data.scope.join(', ')} - #{DOCS_LINK}"
         
     | 
| 
       187 
189 
     | 
    
         | 
| 
       188 
190 
     | 
    
         
             
                    render_error(["unpermitted_scope", details])
         
     | 
| 
       189 
191 
     | 
    
         
             
                  end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: zaikio-jwt_auth
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.5.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - crispymtn
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2023- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2023-05-11 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: activejob
         
     |