doorkeeper_hub 0.1.3 → 0.1.4
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/Rakefile +8 -2
 - data/lib/doorkeeper_hub/helpers.rb +0 -1
 - data/lib/doorkeeper_hub/saml.rb +20 -10
 - data/lib/doorkeeper_hub/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 57317b863c1df69f8ef98933a88adeefe67d16a9045b34a651f50040e7d0660a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 608d6f40b3f891882847825f615a537a32218be747eb4e754809b6d860349518
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9610fe1a924385f480ffde41a24ad5428b32ad838b9666398d11bc3073d06518d689a8e3f7b6e246b1330c68f475560d4ce3d97aeb13d601d1606ef7237173fc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: dd9825328ded32b28d500813a530f6845f9a45710bb71dd955996f91c3aed67b05e3bb043a8650a009c8352a49ef4db0439db9ae1bda8c093d67bb0cc96021d1
         
     | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/doorkeeper_hub/saml.rb
    CHANGED
    
    | 
         @@ -4,26 +4,36 @@ module DoorkeeperHub 
     | 
|
| 
       4 
4 
     | 
    
         
             
              module Saml
         
     | 
| 
       5 
5 
     | 
    
         
             
                extend ActiveSupport::Concern
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                 
     | 
| 
       8 
     | 
    
         
            -
                   
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                def instance_method
         
     | 
| 
       12 
     | 
    
         
            -
                  puts "instance method here"
         
     | 
| 
      
 7 
     | 
    
         
            +
                included do
         
     | 
| 
      
 8 
     | 
    
         
            +
                  devise :omniauthable, omniauth_providers: %i[saml]
         
     | 
| 
       13 
9 
     | 
    
         
             
                end
         
     | 
| 
       14 
10 
     | 
    
         | 
| 
       15 
11 
     | 
    
         
             
                class_methods do
         
     | 
| 
       16 
12 
     | 
    
         
             
                  def from_omniauth(auth)
         
     | 
| 
       17 
     | 
    
         
            -
                     
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                    return if companies.empty?
         
     | 
| 
      
 13 
     | 
    
         
            +
                    return if scope_results(auth).empty?
         
     | 
| 
       20 
14 
     | 
    
         | 
| 
       21 
15 
     | 
    
         
             
                    user = where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
         
     | 
| 
       22 
16 
     | 
    
         
             
                      user.email = auth.info.email
         
     | 
| 
       23 
17 
     | 
    
         
             
                    end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    scope_results(auth).each do |result|
         
     | 
| 
      
 20 
     | 
    
         
            +
                      user.users_companies.find_or_create_by(company: result)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       25 
23 
     | 
    
         
             
                    user
         
     | 
| 
       26 
24 
     | 
    
         
             
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  def scope_results(auth)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    @scope_results ||= DoorkeeperHub
         
     | 
| 
      
 28 
     | 
    
         
            +
                                         .config.scope_model
         
     | 
| 
      
 29 
     | 
    
         
            +
                                         .where(scope_query(auth))
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def scope_query(auth)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    {
         
     | 
| 
      
 34 
     | 
    
         
            +
                      DoorkeeperHub.token_name => auth.extra.raw_info[DoorkeeperHub.token_name]
         
     | 
| 
      
 35 
     | 
    
         
            +
                    }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
       27 
37 
     | 
    
         
             
                end
         
     | 
| 
       28 
38 
     | 
    
         
             
              end
         
     | 
| 
       29 
39 
     | 
    
         
             
            end
         
     |