access_token_agent 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -11
- data/.travis.yml +6 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +34 -9
- data/access_token_agent.gemspec +4 -5
- data/lib/access_token_agent/connector.rb +6 -1
- data/lib/access_token_agent/version.rb +1 -1
- metadata +30 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 515e66f424f27274679e49bfcbbf7a3aaed85054
|
4
|
+
data.tar.gz: 50c9d660e90a2eb12f24a494a9a5006ee8b76261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1c6a0ba6263f9378ea6b4481748a30f6166cf475872205766a8f63c7fb7b3470d8c240c0caa51850fac61e3929ad5546717aa5f36a522e6c3c44f009300e56c
|
7
|
+
data.tar.gz: 310906cd857492000660581b8fe314a417ef7a7fd4cee338da50263f2d62dfb503a1adcf57d02d231b7cdcd54973a69cce9635d3599b14294e24b47160beba4d
|
data/.rubocop.yml
CHANGED
@@ -1,28 +1,34 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.1
|
3
2
|
Exclude:
|
3
|
+
- 'bin/**/*'
|
4
4
|
- 'db/schema.rb'
|
5
5
|
- 'doc/**/*'
|
6
|
-
- '
|
7
|
-
- '
|
6
|
+
- 'docker_app/**/*'
|
7
|
+
- 'Guardfile'
|
8
|
+
- 'tmp/**/*'
|
9
|
+
- 'vendor/**/*'
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
+
# We need to configure exemptions for blocks that we generally accept to be
|
12
|
+
# long, since they are less comparable to methods and more comparable to
|
13
|
+
# modules/classes.
|
14
|
+
Metrics/BlockLength:
|
15
|
+
ExcludedMethods:
|
16
|
+
- context
|
17
|
+
- describe
|
18
|
+
- namespace
|
19
|
+
Exclude:
|
20
|
+
- 'config/environments/*.rb' # instead of excluding all :configure methods
|
21
|
+
- 'config/routes.rb'
|
11
22
|
|
12
23
|
Style/Documentation:
|
13
24
|
Enabled: false
|
14
25
|
|
15
|
-
# Encoding comments are not neccessary in all 2.x versions of ruby, since
|
16
|
-
# UTF-8 has become the default encoding.
|
17
|
-
Style/Encoding:
|
18
|
-
EnforcedStyle: never
|
19
|
-
Enabled: true
|
20
|
-
|
21
26
|
# This cop tries to make you use module_funtion instead of extend self
|
22
27
|
# This is bad because both have their own use-case and should not be used
|
23
28
|
# and sometimes cannot be used to do the same thing
|
24
29
|
Style/ModuleFunction:
|
25
30
|
Enabled: false
|
31
|
+
|
26
32
|
# While it is very often useful to separate numbers after every three digits
|
27
33
|
# for readability, this mostly doesn't make sense if the number doesn't
|
28
34
|
# represent an amount but rather an identifier. Thus the use of underscores
|
data/.travis.yml
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
script:
|
3
|
-
- bundle exec rspec
|
3
|
+
- bundle exec rspec && codeclimate-test-reporter
|
4
4
|
- bundle exec rubocop
|
5
|
+
|
6
|
+
addons:
|
7
|
+
code_climate:
|
8
|
+
repo_token:
|
9
|
+
secure: "tsEpSMfYQHfnm5l9zkdksmTcdV/hjq28HsKh7+tXefWbNbMksrzWlonuZsoQSeLx8OdG5dcGREY3JVbWUl8CxILZ/j8rse0CBpW1S/sy7sz7KQEaBgTq+BxJiFyjPibul91X7TcMHVLpo2c2bIM353HJW4Sf0gT5rhbykek2YHXsvHXlDv4dkE/PL0yZylgDi8zC6dXl9IrjsqgPcTwtCAOM2o1+NhNBiyBWJqQyfhv2N72dml3mk8rQ9WszyRhHmIUhHehdgYcbOrydlEclOHwuszIQd0z2wpJ9HMlvQFtmH/muW4XTf/VNu3XaZr1OYwzBZBeC9Ngfoqn/7Bs0p815NrRcKc9oq+hIyjyd6Mj7Asqcs1+JxakzcVdW6Enf3ZL7F7fsmmB4mQkATEcpBv8G4aN3lFkBmIZdx16oyMQWrLPPzsFXgSdARdUczdtgfnAFT3IB311CnT6zxPCL8FBI/KiHK9FXc6FBGv030doIhr3pDUjMkx35VYN5cvixf+oHMYg4/XuoO+HGwdViA/P8gAUGs5bQL5kY6jcYSTsa8KlzKfgUcK1buWblHfTSEKdMOnKRSBvfS9S3VcPt5ZpZ62Cfbqfjn4lPa5UxcOyb3abk3s2ikKbftGUQk8k4qlhednki3yV71xKhpQsiO/ufNCnp6jXAV2p/KoM2QjA="
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/access_token_agent.svg)](https://badge.fury.io/rb/access_token_agent)
|
1
2
|
[![Build Status](https://travis-ci.org/kaeuferportal/access_token_agent.svg?branch=master)](https://travis-ci.org/kaeuferportal/access_token_agent)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/kaeuferportal/access_token_agent/badges/gpa.svg)](https://codeclimate.com/github/kaeuferportal/access_token_agent)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/kaeuferportal/access_token_agent/badges/coverage.svg)](https://codeclimate.com/github/kaeuferportal/access_token_agent/coverage)
|
2
5
|
|
3
6
|
# AccessTokenAgent
|
4
7
|
|
@@ -29,30 +32,43 @@ Needs the following parameters to instantiate:
|
|
29
32
|
* `host` - the server address where the auth provider is running.
|
30
33
|
* `client_id` - the client_id of the application using this gem.
|
31
34
|
* `client_secret` - the client_secret of the application using this gem.
|
32
|
-
* `access_token_path` - Allows to customize the HTTP path where the
|
33
|
-
access token needs to be requested.
|
34
|
-
**Default:** `/oauth/token`
|
35
35
|
|
36
36
|
Optional parameters:
|
37
37
|
|
38
38
|
* `fake_auth` - if true, do not connect to the auth service and return
|
39
39
|
a faked access token.
|
40
|
+
* `access_token_path` - Allows to customize the HTTP path where the
|
41
|
+
access token needs to be requested.
|
42
|
+
**Default:** `/oauth/token`
|
40
43
|
|
41
44
|
### Example
|
42
45
|
|
43
46
|
```ruby
|
44
|
-
AccessTokenAgent::Connector.new(host: 'https://auth.kaeuferportal.de',
|
45
|
-
|
46
|
-
|
47
|
+
@connector = AccessTokenAgent::Connector.new(host: 'https://auth.kaeuferportal.de',
|
48
|
+
client_id: 'my_client',
|
49
|
+
client_secret: 'very_secure_and_secret')
|
50
|
+
```
|
51
|
+
|
52
|
+
## Sharing a connector
|
53
|
+
|
54
|
+
When connecting to multiple endpoints you will commonly come across the need
|
55
|
+
to share a single instance of a connector in multiple places, because your
|
56
|
+
application will use the same configuration everywhere.
|
57
|
+
|
58
|
+
You can use the convenience accessor `instance` for that:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
AccessTokenAgent::Connector.instance = AccessTokenAgent::Connector.new(...)
|
47
62
|
```
|
48
63
|
|
49
64
|
## Usage
|
50
65
|
|
51
66
|
Setup an AcccessTokenAgent::Connector instance (see Configuration) and call
|
52
|
-
authenticate on it to receive your access_token.
|
67
|
+
`authenticate` on it to receive your access_token.
|
53
68
|
|
54
|
-
```
|
55
|
-
|
69
|
+
```ruby
|
70
|
+
AccessTokenAgent::Connector.instance.authenticate
|
71
|
+
=> "XYZ"
|
56
72
|
```
|
57
73
|
|
58
74
|
When no valid AccessToken is present a call to authenticate returns one of the
|
@@ -65,3 +81,12 @@ following:
|
|
65
81
|
As long as a valid AccessToken is present a call to authenticate simply returns
|
66
82
|
that AccessToken. An AccessToken is valid for a limited time. The exact value is
|
67
83
|
determined by the auth response which contains an `expires_at` parameter.
|
84
|
+
|
85
|
+
### As HTTP Header
|
86
|
+
|
87
|
+
Since the most common use case is to include the access token as [RFC 6750](https://tools.ietf.org/html/rfc6750) bearer token, there is a method that returns the `Authorization: Bearer XYZ` header as hash:
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
AccessTokenAgent::Connector.instance.http_auth_header
|
91
|
+
=> { "Authorization" => "Bearer XYZ" }
|
92
|
+
```
|
data/access_token_agent.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
lib = File.expand_path('../lib', __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
require 'access_token_agent/version'
|
@@ -19,10 +17,11 @@ Gem::Specification.new do |s|
|
|
19
17
|
.reject { |f| f.match(%r{^spec/}) }
|
20
18
|
|
21
19
|
s.add_development_dependency 'bundler', '~> 1.11'
|
22
|
-
s.add_development_dependency '
|
20
|
+
s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
|
23
21
|
s.add_development_dependency 'pry', '~> 0.10'
|
24
|
-
s.add_development_dependency '
|
22
|
+
s.add_development_dependency 'rspec', '~> 3.4'
|
23
|
+
s.add_development_dependency 'rubocop', '0.51'
|
24
|
+
s.add_development_dependency 'simplecov', '~> 0.11'
|
25
25
|
s.add_development_dependency 'vcr', '~> 3.0'
|
26
26
|
s.add_development_dependency 'webmock', '~> 1.24'
|
27
|
-
s.add_development_dependency 'simplecov', '~> 0.11'
|
28
27
|
end
|
@@ -4,6 +4,10 @@ module AccessTokenAgent
|
|
4
4
|
class Connector
|
5
5
|
FAKE_TOKEN = 'FakeAuthToken'.freeze
|
6
6
|
|
7
|
+
class << self
|
8
|
+
attr_accessor :instance
|
9
|
+
end
|
10
|
+
|
7
11
|
def initialize(host:,
|
8
12
|
client_id:,
|
9
13
|
client_secret:,
|
@@ -28,7 +32,8 @@ module AccessTokenAgent
|
|
28
32
|
end
|
29
33
|
|
30
34
|
def authenticate
|
31
|
-
warn
|
35
|
+
warn "[DEPRECATION] `#{self.class}.authenticate` is deprecated. " \
|
36
|
+
'Use `token` instead.'
|
32
37
|
token
|
33
38
|
end
|
34
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: access_token_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beko Käuferportal GmbH
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: codeclimate-test-reporter
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,61 +53,75 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.4'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.51'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.51'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '0.11'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '0.11'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: vcr
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '3.0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '3.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: webmock
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
117
|
+
version: '1.24'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
124
|
+
version: '1.24'
|
111
125
|
description: Retrieves an access token from an OAuth2 providerusing the supplied credentials.
|
112
126
|
email: oss@kaeuferportal.de
|
113
127
|
executables: []
|