omniauth-tanmer 1.1.1 → 1.2.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 +5 -5
 - data/Gemfile +2 -1
 - data/README.md +6 -1
 - data/lib/omniauth-tanmer.rb +1 -0
 - data/lib/omniauth-tanmer/user.rb +36 -0
 - data/lib/omniauth-tanmer/version.rb +1 -1
 - metadata +4 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5eec50c04561623e9deaff3fc084e3d74a6f1a336e21a3004c31dae8f41eacd1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: fc9fef3b22bde673c33bdf38a599e01627b804a929c7cdd53deab54b9c59f893
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8a1c815693bf9c267ca3712d785e240d23448fe5497f840767cf93a8f85d4f7ee18f7a4698a7a0d96fc66c02b51b6729c413e44ab1a4b24c1155dbaf6524afb7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2915df57eb55205e2e9f8bdbe4dc0c3cb82dc7a55323783b3784f412ec964c4313411d73b0b27162d1358f3ad9dc83f102088343ae9e92d46978cc82ee1906cc
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -25,9 +25,14 @@ Put below code to `config/application.rb`: 
     | 
|
| 
       25 
25 
     | 
    
         
             
                config.middleware.use OmniAuth::Builder do
         
     | 
| 
       26 
26 
     | 
    
         
             
                    provider :tanmer, ENV['OAUTH_TANMER_KEY'], ENV['OAUTH_TANMER_SECRET'],
         
     | 
| 
       27 
27 
     | 
    
         
             
                    scope: 'public',
         
     | 
| 
       28 
     | 
    
         
            -
                    client_options: {  
     | 
| 
      
 28 
     | 
    
         
            +
                    client_options: { 
         
     | 
| 
      
 29 
     | 
    
         
            +
                        site: ENV['OAUTH_TANMER_SITE'],
         
     | 
| 
      
 30 
     | 
    
         
            +
                        authorize_url: ENV['OAUTH_TANMER_AUTH_URL'] || '/oauth/authorize'
         
     | 
| 
      
 31 
     | 
    
         
            +
                    }
         
     | 
| 
       29 
32 
     | 
    
         
             
                end
         
     | 
| 
       30 
33 
     | 
    
         | 
| 
      
 34 
     | 
    
         
            +
            Like docker-compose/kubernetes infrastructure, we set `ENV['OAUTH_TANMER_SITE']='http://sso`, then user frontend will redirect to `http://sso/oauth/authorize`, To fix this, we can define `ENV['OAUTH_TANMER_AUTH_URL']='http://sso.my-site.com/oauth/authorize'`
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       31 
36 
     | 
    
         
             
            ## Features
         
     | 
| 
       32 
37 
     | 
    
         | 
| 
       33 
38 
     | 
    
         
             
            Sync permissions:
         
     | 
    
        data/lib/omniauth-tanmer.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "faraday"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "jwt"
         
     | 
| 
      
 3 
     | 
    
         
            +
            module Omniauth
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Tanmer
         
     | 
| 
      
 5 
     | 
    
         
            +
                class User
         
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :app_id, :app_secret, :conn
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  def initialize(oauth_host, app_id, app_secret)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @app_id = app_id
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @app_secret = app_secret
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @conn = Faraday.new(oauth_host)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def create(name: nil, username: nil, email: nil, mobile_phone: nil, image: nil, password: nil)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    params = {
         
     | 
| 
      
 16 
     | 
    
         
            +
                      app_id: app_id,
         
     | 
| 
      
 17 
     | 
    
         
            +
                      sn: generate_sn(SecureRandom.uuid),
         
     | 
| 
      
 18 
     | 
    
         
            +
                      name: name,
         
     | 
| 
      
 19 
     | 
    
         
            +
                      username: username,
         
     | 
| 
      
 20 
     | 
    
         
            +
                      email: email,
         
     | 
| 
      
 21 
     | 
    
         
            +
                      mobile_phone: mobile_phone,
         
     | 
| 
      
 22 
     | 
    
         
            +
                      image: image,
         
     | 
| 
      
 23 
     | 
    
         
            +
                      password: password
         
     | 
| 
      
 24 
     | 
    
         
            +
                    }
         
     | 
| 
      
 25 
     | 
    
         
            +
                    resp = conn.post('/api/v1/users.json', params)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    JSON.parse(resp.body)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  private
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def generate_sn(data=nil)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    JWT.encode({ data: data, exp: Time.now.to_i + 300 }, app_secret, 'HS256')
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: omniauth-tanmer
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - xiaohui
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-05-29 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: omniauth
         
     | 
| 
         @@ -81,6 +81,7 @@ files: 
     | 
|
| 
       81 
81 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       82 
82 
     | 
    
         
             
            - lib/omniauth-tanmer.rb
         
     | 
| 
       83 
83 
     | 
    
         
             
            - lib/omniauth-tanmer/permission.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - lib/omniauth-tanmer/user.rb
         
     | 
| 
       84 
85 
     | 
    
         
             
            - lib/omniauth-tanmer/version.rb
         
     | 
| 
       85 
86 
     | 
    
         
             
            - lib/omniauth/strategies/tanmer.rb
         
     | 
| 
       86 
87 
     | 
    
         
             
            - omniauth-tanmer.gemspec
         
     | 
| 
         @@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       105 
106 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       106 
107 
     | 
    
         
             
            requirements: []
         
     | 
| 
       107 
108 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       108 
     | 
    
         
            -
            rubygems_version: 2.6 
     | 
| 
      
 109 
     | 
    
         
            +
            rubygems_version: 2.7.6
         
     | 
| 
       109 
110 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       110 
111 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       111 
112 
     | 
    
         
             
            summary: This is the strategy for authenticating to your Tanmer service
         
     |