omniauth-tanmer 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e53731b2c179028d8129aa617e8a605f503eebfd
4
- data.tar.gz: 8518e217257f134d55c75a5e7d742b71ff46937f
2
+ SHA256:
3
+ metadata.gz: 5eec50c04561623e9deaff3fc084e3d74a6f1a336e21a3004c31dae8f41eacd1
4
+ data.tar.gz: fc9fef3b22bde673c33bdf38a599e01627b804a929c7cdd53deab54b9c59f893
5
5
  SHA512:
6
- metadata.gz: b02809a68b4bf6015f92ef948ae2eb7e4e5fd47d9d6a77a0dc2070e19562fc5d25e1f5edd3046770634012451469d1a7c8d8505258606efc18f450354b981248
7
- data.tar.gz: a7da19d88724751dc5cd578945e1b291f8b3f7f6a380b1943f0126557ab42f259b982b035eeea2f4ed91a5d3f02711559eebaf55a2f804049a51013386f9cf60
6
+ metadata.gz: 8a1c815693bf9c267ca3712d785e240d23448fe5497f840767cf93a8f85d4f7ee18f7a4698a7a0d96fc66c02b51b6729c413e44ab1a4b24c1155dbaf6524afb7
7
+ data.tar.gz: 2915df57eb55205e2e9f8bdbe4dc0c3cb82dc7a55323783b3784f412ec964c4313411d73b0b27162d1358f3ad9dc83f102088343ae9e92d46978cc82ee1906cc
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ gem 'rspec', '~> 3.1'
7
7
  gem 'rspec-its', '~> 1.0'
8
8
  gem 'rack-test'
9
9
  gem 'simplecov'
10
- gem 'webmock'
10
+ gem 'webmock'
11
+ gem 'pry'
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: { site: ENV['OAUTH_TANMER_SITE'] }
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:
@@ -1,3 +1,4 @@
1
1
  require "omniauth-tanmer/version"
2
2
  require "omniauth-tanmer/permission"
3
+ require "omniauth-tanmer/user"
3
4
  require 'omniauth/strategies/tanmer'
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Tanmer
3
- VERSION = '1.1.1'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  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.1.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-03-31 00:00:00.000000000 Z
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.14
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