omniauth-aitu-passport 0.1.19 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -6
- data/Gemfile.lock +1 -1
- data/README.md +16 -4
- data/lib/omniauth/aitu_passport/version.rb +1 -1
- data/lib/omniauth/strategies/aitu_passport.rb +21 -2
- metadata +2 -4
- data/bin/console +0 -15
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e92c64e77c4f3de63c2aff68dcbadfe6dda5156dc980ceffab4237a7724b59da
|
4
|
+
data.tar.gz: c6ad628463a5f8b94fd9d5aed018a8a0a7e2ffdcbf1e7a65be7ed7e8ae47c684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 476c648beb600866d42140573a23df270c6487b4088b86456f963a90b1b5443e923e3a5169c81d96d2deb9589e000df85be6123ed7bfd3f96a2e0b0c1373f3ac
|
7
|
+
data.tar.gz: 0e4a5f660903eab42f3392705737b1478c4e9a88572f8e3cc80e3635e9daacf48ce25b7d5d5150a1f483fd0e4eaa880e1a3e37ef79b3366b06a11e544dd14571
|
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,34 @@
|
|
1
|
-
# v 0.1.
|
1
|
+
# v 0.1.21
|
2
|
+
Added:
|
3
|
+
- session_id added to auth link according to
|
4
|
+
https://docs.passport.aitu.io/#tag/Poluchenie-identifikatora-oauth-sessii
|
5
|
+
- PASSPORT_STAGING env option
|
2
6
|
|
3
|
-
|
4
|
-
-
|
7
|
+
Removed:
|
8
|
+
- setup binaries
|
5
9
|
|
6
|
-
|
7
|
-
|
10
|
+
# v 0.1.9
|
11
|
+
Fixed:
|
12
|
+
- possible NoMethod error in guard clause
|
13
|
+
|
14
|
+
Added:
|
15
|
+
- Base test cases
|
16
|
+
- Rubocop inspections
|
8
17
|
|
9
18
|
# v 0.1.8
|
10
19
|
|
11
20
|
Added:
|
12
21
|
- redirect_uri accepted once in :options
|
13
22
|
|
23
|
+
Removed:
|
24
|
+
- None
|
25
|
+
|
26
|
+
|
27
|
+
# v 0.1.6
|
28
|
+
|
29
|
+
Added:
|
30
|
+
- Scope filtered to avoid malformed_scope errors
|
31
|
+
|
14
32
|
Removed:
|
15
|
-
- None
|
33
|
+
- None
|
34
|
+
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -43,12 +43,15 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
43
43
|
provider :aitu_passport,
|
44
44
|
ENV['PASSPORT_KEY'],
|
45
45
|
ENV['PASSPORT_SECRET'],
|
46
|
-
{
|
46
|
+
{
|
47
47
|
scope: 'phone first_name middle_name last_name gender openid',
|
48
48
|
response_type: 'code',
|
49
49
|
client_id: ENV['PASSPORT_KEY'],
|
50
50
|
provider_ignores_state: Rails.env == 'production' ? false : true,
|
51
|
-
redirect_uri: ENV['PASSPORT_REDIRECT_URI']
|
51
|
+
redirect_uri: ENV['PASSPORT_REDIRECT_URI'],
|
52
|
+
token_params: {
|
53
|
+
redirect_uri: ENV['PASSPORT_REDIRECT_URI']
|
54
|
+
}
|
52
55
|
}
|
53
56
|
end
|
54
57
|
|
@@ -57,6 +60,17 @@ OmniAuth.config.logger = Rails.logger
|
|
57
60
|
```
|
58
61
|
using the keys you receive and URI you provided when registered the app
|
59
62
|
|
63
|
+
Please note :redirect_uri param under :token_params is mandatory option.
|
64
|
+
|
65
|
+
Also, you can use
|
66
|
+
|
67
|
+
```yaml
|
68
|
+
ENV['PASSPORT_STAGING']: true
|
69
|
+
```
|
70
|
+
|
71
|
+
option in your environment to send auth requests to staging AituPassport server,
|
72
|
+
e.g. https://passport.stage.supreme-team.tech
|
73
|
+
|
60
74
|
4. Use it in your sessions controller on your own, assuming the following envs to store the data you need
|
61
75
|
|
62
76
|
```ruby
|
@@ -70,8 +84,6 @@ using the keys you receive and URI you provided when registered the app
|
|
70
84
|
|
71
85
|
## Development
|
72
86
|
|
73
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
74
|
-
|
75
87
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
76
88
|
|
77
89
|
## Contributing
|
@@ -12,12 +12,13 @@ module OmniAuth
|
|
12
12
|
|
13
13
|
option :client_options, {
|
14
14
|
site: 'https://passport.aitu.io',
|
15
|
-
token_url: '/
|
15
|
+
token_url: '/api/v1/oauth/token',
|
16
16
|
authorize_url: '/oauth2/auth',
|
17
|
+
session_url: '/api/v1/oauth/session',
|
17
18
|
auth_scheme: :basic_auth
|
18
19
|
}
|
19
20
|
|
20
|
-
option :pkce,
|
21
|
+
option :pkce, true
|
21
22
|
|
22
23
|
AVAILABLE_SCOPE_OPTIONS = %w[
|
23
24
|
openid
|
@@ -67,6 +68,8 @@ module OmniAuth
|
|
67
68
|
super.tap do
|
68
69
|
# Raising up an error if redirect_uri is missing
|
69
70
|
raise ArgumentError, 'Wrong options: redirect_uri option is missing.' unless options[:redirect_uri]
|
71
|
+
|
72
|
+
options[:client_options][:site] = 'https://passport.stage.supreme-team.tech' if ENV['PASSPORT_STAGING']
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
@@ -75,6 +78,7 @@ module OmniAuth
|
|
75
78
|
super.tap do |params|
|
76
79
|
params[:scope] = filter_scope(params)
|
77
80
|
params[:redirect_uri] = options[:redirect_uri]
|
81
|
+
params[:session_id] = get_session_id
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
@@ -84,6 +88,21 @@ module OmniAuth
|
|
84
88
|
|
85
89
|
private
|
86
90
|
|
91
|
+
def get_session_id
|
92
|
+
params = ::OAuth2::Authenticator.new(client.id, client.secret, client.options[:auth_scheme]).apply({})
|
93
|
+
res = client.request(:post, session_url, params)
|
94
|
+
case res.status
|
95
|
+
when 200
|
96
|
+
JSON.parse(res.body).dig('sessionId')
|
97
|
+
else
|
98
|
+
raise NoSessionError, 'No session ID received, sorry.'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def session_url
|
103
|
+
options[:client_options][:site] + options[:client_options][:session_url]
|
104
|
+
end
|
105
|
+
|
87
106
|
def filter_scope(params)
|
88
107
|
return DEFAULT_SCOPE unless params[:scope]
|
89
108
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-aitu-passport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Shevchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -112,8 +112,6 @@ files:
|
|
112
112
|
- LICENSE.txt
|
113
113
|
- README.md
|
114
114
|
- Rakefile
|
115
|
-
- bin/console
|
116
|
-
- bin/setup
|
117
115
|
- lib/omniauth-aitu-passport.rb
|
118
116
|
- lib/omniauth/aitu_passport.rb
|
119
117
|
- lib/omniauth/aitu_passport/version.rb
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'omniauth/aitu/passport'
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require 'irb'
|
15
|
-
IRB.start(__FILE__)
|