faraday_middleware-oauth2_refresh 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE.txt +1 -1
- data/README.md +36 -21
- data/VERSION.txt +1 -1
- data/lib/faraday_middleware/oauth2_refresh.rb +8 -8
- data/test/test_setup.rb +3 -3
- metadata +26 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 89c2ef31c3b4cfe25a1fef7f71bf848d323ec97dfcde4aaaa155edf6e307a0e0
|
4
|
+
data.tar.gz: ee66a0f0bd8be99d4906a17236536993fe47bf1260a37edafe5af21507055ba6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d69cb38e0512c829aa4b84755509bd167ba87c7bb26c5c387593eaf43dcde58a7fea3cfeaeb61ca057de1d8ab2ea8418c48b60755c9e13bbaa129eb3845d11a8
|
7
|
+
data.tar.gz: 176dfc1b5a78575f5dc9d3f3549849e24ae18c4b963352eebff5664b215ec51241cb88d7916e16b33824ece6da024cff262d9aab86a554f27cc8e51c1846569e
|
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at johncwang@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,25 @@
|
|
1
1
|
# FaradayMiddleware::OAuth2Refresh
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
[![
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
<div align="center">
|
4
|
+
|
5
|
+
[![Gem Version][gem-version-svg]][gem-version-url]
|
6
|
+
[![Build Status][build-status-svg]][build-status-url]
|
7
|
+
[![Coverage Status][coverage-status-svg]][coverage-status-url]
|
8
|
+
|
9
|
+
</div>
|
10
|
+
<div align="center">
|
11
|
+
|
12
|
+
[![Code Climate][codeclimate-status-svg]][codeclimate-status-url]
|
13
|
+
[![Scrutinizer Code Quality][scrutinizer-status-svg]][scrutinizer-status-url]
|
14
|
+
|
15
|
+
</div>
|
16
|
+
<div align="center">
|
17
|
+
|
18
|
+
[![Downloads][downloads-svg]][downloads-url]
|
19
|
+
[![Docs][docs-rubydoc-svg]][docs-rubydoc-url]
|
20
|
+
[![License][license-svg]][license-url]
|
21
|
+
|
22
|
+
</div>
|
12
23
|
|
13
24
|
Faraday middleware to manage OAuth token authorization with token refresh.
|
14
25
|
|
@@ -71,25 +82,29 @@ Please report these on [Github](https://github.com/grokify/faraday_middleware-oa
|
|
71
82
|
|
72
83
|
## License
|
73
84
|
|
74
|
-
FaradayMiddleware::OAuth2Refresh is available under an MIT-style license. See {file:LICENSE.
|
85
|
+
FaradayMiddleware::OAuth2Refresh is available under an MIT-style license. See {file:LICENSE.md} for details.
|
75
86
|
|
76
|
-
FaradayMiddleware::OAuth2Refresh © 2015-
|
87
|
+
FaradayMiddleware::OAuth2Refresh © 2015-2021 by John Wang
|
77
88
|
|
78
89
|
[gem-version-svg]: https://badge.fury.io/rb/faraday_middleware-oauth2_refresh.svg
|
79
|
-
[gem-version-
|
90
|
+
[gem-version-url]: http://badge.fury.io/rb/faraday_middleware-oauth2_refresh
|
80
91
|
[downloads-svg]: http://ruby-gem-downloads-badge.herokuapp.com/faraday_middleware-oauth2_refresh
|
81
|
-
[downloads-
|
82
|
-
[build-status-svg]: https://
|
83
|
-
[build-status-
|
92
|
+
[downloads-url]: https://rubygems.org/gems/faraday_middleware-oauth2_refresh
|
93
|
+
[build-status-svg]: https://github.com/grokify/faraday_middleware-oauth2_refresh/workflows/Ruby%20CI/badge.svg?branch=master
|
94
|
+
[build-status-url]: https://github.com/grokify/faraday_middleware-oauth2_refresh/actions
|
84
95
|
[coverage-status-svg]: https://coveralls.io/repos/grokify/faraday_middleware-oauth2_refresh/badge.svg?branch=master
|
85
|
-
[coverage-status-
|
96
|
+
[coverage-status-url]: https://coveralls.io/r/grokify/faraday_middleware-oauth2_refresh?branch=master
|
86
97
|
[dependency-status-svg]: https://gemnasium.com/grokify/faraday_middleware-oauth2_refresh.svg
|
87
|
-
[dependency-status-
|
98
|
+
[dependency-status-url]: https://gemnasium.com/grokify/faraday_middleware-oauth2_refresh
|
99
|
+
[codacy-svg]: https://api.codacy.com/project/badge/Grade/88aedf52809d460891546fc7e11bd2c6
|
100
|
+
[codacy-url]: https://app.codacy.com/manual/grokify/faraday_middleware-oauth2_refresh/dashboard
|
88
101
|
[codeclimate-status-svg]: https://codeclimate.com/github/grokify/faraday_middleware-oauth2_refresh/badges/gpa.svg
|
89
|
-
[codeclimate-status-
|
102
|
+
[codeclimate-status-url]: https://codeclimate.com/github/grokify/faraday_middleware-oauth2_refresh
|
90
103
|
[scrutinizer-status-svg]: https://scrutinizer-ci.com/g/grokify/faraday_middleware-oauth2_refresh/badges/quality-score.png?b=master
|
91
|
-
[scrutinizer-status-
|
104
|
+
[scrutinizer-status-url]: https://scrutinizer-ci.com/g/grokify/faraday_middleware-oauth2_refresh/?branch=master
|
105
|
+
[references-svg]: https://www.versioneye.com/ruby/faraday_middleware-oauth2_refresh/reference_badge.svg
|
106
|
+
[references-url]: https://www.versioneye.com/ruby/faraday_middleware-oauth2_refresh/
|
92
107
|
[docs-rubydoc-svg]: https://img.shields.io/badge/docs-rubydoc-blue.svg
|
93
|
-
[docs-rubydoc-
|
108
|
+
[docs-rubydoc-url]: http://www.rubydoc.info/gems/faraday_middleware-oauth2_refresh/
|
94
109
|
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
|
95
|
-
[license-
|
110
|
+
[license-url]: https://github.com/grokify/faraday_middleware-oauth2_refresh/blob/master/LICENSE.txt
|
data/VERSION.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -12,27 +12,27 @@ module FaradayMiddleware
|
|
12
12
|
|
13
13
|
def call(env)
|
14
14
|
if @oauth2_token.expired?
|
15
|
-
|
15
|
+
@oauth2_token = @oauth2_token.refresh!({ headers: { 'Authorization' => 'Basic ' + get_api_key() } })
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
env[:request_headers][AUTH_HEADER] = %(Bearer #{@oauth2_token.token
|
18
|
+
unless @oauth2_token.token.to_s.empty?
|
19
|
+
env[:request_headers][AUTH_HEADER] = %(Bearer #{@oauth2_token.token})
|
20
20
|
end
|
21
21
|
|
22
22
|
@app.call env
|
23
23
|
end
|
24
24
|
|
25
|
-
def get_api_key
|
26
|
-
api_key = Base64
|
25
|
+
def get_api_key
|
26
|
+
api_key = Base64.encode64("#{@oauth2_token.client.id}:#{@oauth2_token.client.secret}").gsub(/[\s]/,'')
|
27
27
|
return api_key
|
28
28
|
end
|
29
29
|
|
30
|
-
def initialize(app=nil, token=nil
|
31
|
-
super
|
30
|
+
def initialize(app = nil, token = nil)
|
31
|
+
super app
|
32
32
|
@oauth2_token = token
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
Faraday::Request.register_middleware :
|
38
|
+
Faraday::Request.register_middleware oauth2_refresh: FaradayMiddleware::OAuth2Refresh
|
data/test/test_setup.rb
CHANGED
@@ -7,9 +7,9 @@ require 'faraday_middleware'
|
|
7
7
|
require 'faraday_middleware-oauth2_refresh'
|
8
8
|
|
9
9
|
class OAuth2Test < Test::Unit::TestCase
|
10
|
-
def
|
10
|
+
def test_setup
|
11
11
|
|
12
|
-
|
12
|
+
Faraday.new 'http://example.com/api' do |conn|
|
13
13
|
conn.request :oauth2_refresh
|
14
14
|
end
|
15
15
|
|
@@ -18,4 +18,4 @@ class OAuth2Test < Test::Unit::TestCase
|
|
18
18
|
assert_equal 'FaradayMiddleware::OAuth2Refresh', ref.class.name
|
19
19
|
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,67 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday_middleware-oauth2_refresh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.9'
|
20
|
-
- - "
|
20
|
+
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '0.9'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0.9'
|
30
|
-
- - "
|
30
|
+
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0.9'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: faraday_middleware
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
|
-
- - "
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
|
-
- - "
|
50
|
+
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: coveralls
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - "
|
57
|
+
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
type: :development
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - "
|
64
|
+
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '0'
|
67
67
|
- !ruby/object:Gem::Dependency
|
@@ -70,42 +70,42 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
73
|
+
version: 12.3.3
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 12.3.3
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: simplecov
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - "
|
85
|
+
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- - "
|
92
|
+
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: test-unit
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - "
|
99
|
+
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
101
|
+
version: '3'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- - "
|
106
|
+
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: '
|
108
|
+
version: '3'
|
109
109
|
description: This Faraday middleware gem adds OAuth2 token handling with token refresh
|
110
110
|
email: johncwang@gmail.com
|
111
111
|
executables: []
|
@@ -113,6 +113,7 @@ extensions: []
|
|
113
113
|
extra_rdoc_files: []
|
114
114
|
files:
|
115
115
|
- CHANGELOG.md
|
116
|
+
- CODE_OF_CONDUCT.md
|
116
117
|
- LICENSE.txt
|
117
118
|
- README.md
|
118
119
|
- Rakefile
|
@@ -120,11 +121,11 @@ files:
|
|
120
121
|
- lib/faraday_middleware-oauth2_refresh.rb
|
121
122
|
- lib/faraday_middleware/oauth2_refresh.rb
|
122
123
|
- test/test_setup.rb
|
123
|
-
homepage: https://github.com/grokify/
|
124
|
+
homepage: https://github.com/grokify/faraday_middleware-oauth2_refresh
|
124
125
|
licenses:
|
125
126
|
- MIT
|
126
127
|
metadata: {}
|
127
|
-
post_install_message:
|
128
|
+
post_install_message:
|
128
129
|
rdoc_options: []
|
129
130
|
require_paths:
|
130
131
|
- lib
|
@@ -139,9 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
- !ruby/object:Gem::Version
|
140
141
|
version: '0'
|
141
142
|
requirements: []
|
142
|
-
|
143
|
-
|
144
|
-
signing_key:
|
143
|
+
rubygems_version: 3.0.4
|
144
|
+
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Faraday OAuth2 request middleware with token refresh
|
147
147
|
test_files: []
|