bamboo-id 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +62 -0
- data/Rakefile +6 -0
- data/bamboo_id.gemspec +30 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/bamboo_id.rb +1 -0
- data/lib/bamboo_id/api_key_fetcher.rb +45 -0
- data/lib/bamboo_id/configuration.rb +25 -0
- data/lib/bamboo_id/requests/access_token_request.rb +31 -0
- data/lib/bamboo_id/requests/api_key_request.rb +35 -0
- data/lib/bamboo_id/requests/base_access_token_request.rb +31 -0
- data/lib/bamboo_id/requests/basic_request_handling.rb +26 -0
- data/lib/bamboo_id/state_code.rb +15 -0
- data/lib/bamboo_id/urls/api_key_url.rb +25 -0
- data/lib/bamboo_id/urls/auth_url.rb +51 -0
- data/lib/bamboo_id/urls/bamboo_url.rb +20 -0
- data/lib/bamboo_id/urls/base_auth_url.rb +41 -0
- data/lib/bamboo_id/urls/base_oauth_token_url.rb +35 -0
- data/lib/bamboo_id/urls/oauth_token_url.rb +34 -0
- data/lib/bamboo_id/version.rb +3 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b4e7c1e3eda03ee309dd4302dfee5a67beedf598
|
4
|
+
data.tar.gz: 4c6089b7a0cfa21b6f9a4a84a6c2a9741b6bc43c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f51afe7ae438c5b85baf85e05d2d072bdb9d4cebc853d6573b9440cf531f7be461e11cd656798d36ab3bee88b788267cd8fa81107b6077890b8ed073172c216
|
7
|
+
data.tar.gz: d410e30713314f49ca531965ed792450a1886b9c8957761966ef9e7a746c11245444393619f1363cb4397e8a34c435599aeab5285e6c7f99e254446504116108
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
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 joncodes+github@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/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Jon Evans
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# BambooId
|
2
|
+
|
3
|
+
Makes connecting to BambooHR with OpenID easier.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'bamboo-id'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install bamboo-id
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Configuration
|
24
|
+
|
25
|
+
`Bamboo::Configuration.redirect_url` must be set.
|
26
|
+
|
27
|
+
The following environment variables are also required:
|
28
|
+
- `BAMBOO_APPLICATION_KEY`
|
29
|
+
- `BAMBOO_CLIENT_ID`
|
30
|
+
- `BAMBOO_CLIENT_SECRET`
|
31
|
+
|
32
|
+
### Authorizing
|
33
|
+
|
34
|
+
To get the initial authorization URL, use `BambooId::Urls::AuthUrl.new(subdomain).to_s`
|
35
|
+
|
36
|
+
In the callback controller, you can use `BambooId::ApiKeyFetcher` to get an API key
|
37
|
+
using the code passed to you like so:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
::BambooId::ApiKeyFetcher.new(
|
41
|
+
code: params[:code],
|
42
|
+
integration: current_company.user_management_integration
|
43
|
+
).fetch
|
44
|
+
```
|
45
|
+
|
46
|
+
This will either return an api key or `false` with an `error` attribute set.
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
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.
|
51
|
+
|
52
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bonusly/bamboo-id. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
57
|
+
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
62
|
+
|
data/Rakefile
ADDED
data/bamboo_id.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bamboo_id/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bamboo-id"
|
8
|
+
spec.version = BambooId::VERSION
|
9
|
+
spec.authors = ["Jon Evans"]
|
10
|
+
spec.email = ["joncodes@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Wrapper classes around the OpenID connect process.}
|
13
|
+
spec.description = %q{Easily connect your Ruby application to BambooHR through OpenID.}
|
14
|
+
spec.homepage = "https://www.github.com/bonusly/bamboo-id"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "webmock"
|
28
|
+
|
29
|
+
spec.add_dependency 'httparty'
|
30
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bamboo_id"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/bamboo_id.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'bamboo_id', '**', '*.rb')].each { |file| require file }
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module BambooId
|
2
|
+
class ApiKeyFetcher
|
3
|
+
attr_reader :error
|
4
|
+
|
5
|
+
def initialize(code:, subdomain:)
|
6
|
+
self.code = code
|
7
|
+
self.subdomain = subdomain
|
8
|
+
self.error = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch
|
12
|
+
unless access_token_request.successful?
|
13
|
+
self.error = "Could not get access token: #{access_token_request.error}"
|
14
|
+
return false
|
15
|
+
end
|
16
|
+
|
17
|
+
unless api_key_request.successful?
|
18
|
+
self.error = "Could not get API key."
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
|
22
|
+
api_key_request.key
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_accessor :code, :subdomain
|
29
|
+
attr_writer :error
|
30
|
+
|
31
|
+
def access_token_request
|
32
|
+
@access_token_request ||= Requests::AccessTokenRequest.new(
|
33
|
+
temporary_code: code,
|
34
|
+
subdomain: subdomain
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def api_key_request
|
39
|
+
@api_key_request ||= Requests::ApiKeyRequest.new(
|
40
|
+
id_token: access_token_request.id_token,
|
41
|
+
subdomain: subdomain
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module BambooId
|
2
|
+
class Configuration
|
3
|
+
@@redirect_url = nil
|
4
|
+
|
5
|
+
def self.redirect_url
|
6
|
+
@@redirect_url || raise('No redirect_url set')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.redirect_url=(url)
|
10
|
+
@@redirect_url = url
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.application_key
|
14
|
+
ENV['BAMBOO_APPLICATION_KEY']
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.client_id
|
18
|
+
ENV['BAMBOO_CLIENT_ID']
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.client_secret
|
22
|
+
ENV['BAMBOO_CLIENT_SECRET']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'base_access_token_request.rb'
|
2
|
+
|
3
|
+
module BambooId
|
4
|
+
module Requests
|
5
|
+
class AccessTokenRequest
|
6
|
+
include BaseAccessTokenRequest
|
7
|
+
|
8
|
+
def initialize(temporary_code:, subdomain:, grant_type: 'authorization_code')
|
9
|
+
self.temporary_code = temporary_code
|
10
|
+
self.subdomain = subdomain
|
11
|
+
self.grant_type = grant_type
|
12
|
+
end
|
13
|
+
|
14
|
+
def id_token
|
15
|
+
response.id_token
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_accessor :subdomain
|
21
|
+
|
22
|
+
def url
|
23
|
+
@url ||= Urls::OauthTokenUrl.new(
|
24
|
+
temporary_code: temporary_code,
|
25
|
+
subdomain: subdomain,
|
26
|
+
grant_type: grant_type
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module BambooId
|
2
|
+
module Requests
|
3
|
+
class ApiKeyRequest
|
4
|
+
include BasicRequestHandling
|
5
|
+
|
6
|
+
def initialize(subdomain:, id_token:)
|
7
|
+
self.subdomain = subdomain
|
8
|
+
self.id_token = id_token
|
9
|
+
end
|
10
|
+
|
11
|
+
def successful?
|
12
|
+
response.success
|
13
|
+
end
|
14
|
+
|
15
|
+
def key
|
16
|
+
response.key
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_accessor :subdomain, :id_token
|
22
|
+
|
23
|
+
def url
|
24
|
+
Urls::ApiKeyUrl.new(subdomain: subdomain, id_token: id_token)
|
25
|
+
end
|
26
|
+
|
27
|
+
def headers
|
28
|
+
{
|
29
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
30
|
+
'Accept' => 'application/json'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'basic_request_handling.rb'
|
2
|
+
|
3
|
+
module BambooId
|
4
|
+
module Requests
|
5
|
+
module BaseAccessTokenRequest
|
6
|
+
def self.included(base)
|
7
|
+
base.send(:include, BasicRequestHandling)
|
8
|
+
end
|
9
|
+
|
10
|
+
def access_token
|
11
|
+
response.access_token
|
12
|
+
end
|
13
|
+
|
14
|
+
def refresh_token
|
15
|
+
response.refresh_token
|
16
|
+
end
|
17
|
+
|
18
|
+
def successful?
|
19
|
+
error.nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
def error
|
23
|
+
response.error
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_accessor :temporary_code, :grant_type
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module BambooId
|
4
|
+
module Requests
|
5
|
+
module BasicRequestHandling
|
6
|
+
def self.included(base)
|
7
|
+
base.send :include, HTTParty
|
8
|
+
base.send :format, :json
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def response
|
14
|
+
@response ||= OpenStruct.new(self.class.post(url.to_s, body: url.params, headers: headers))
|
15
|
+
end
|
16
|
+
|
17
|
+
def headers
|
18
|
+
{}
|
19
|
+
end
|
20
|
+
|
21
|
+
def url
|
22
|
+
raise NotImplementedError, 'Please implement #url'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module BambooId
|
2
|
+
module Urls
|
3
|
+
class ApiKeyUrl
|
4
|
+
def initialize(subdomain:, id_token:)
|
5
|
+
self.subdomain = subdomain
|
6
|
+
self.id_token = id_token
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
"https://api.bamboohr.com/api/gateway.php/#{subdomain}/v1/oidcLogin"
|
11
|
+
end
|
12
|
+
|
13
|
+
def params
|
14
|
+
{
|
15
|
+
id_token: id_token,
|
16
|
+
applicationKey: Configuration.application_key
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_accessor :subdomain, :id_token
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative 'bamboo_url.rb'
|
2
|
+
require_relative 'base_auth_url.rb'
|
3
|
+
|
4
|
+
# URL for getting initial authorization from Bamboo.
|
5
|
+
#
|
6
|
+
# If user authorizes access to their Bamboo account, we get back
|
7
|
+
# an authorization code code which is then fed to OauthTokenUrl for getting
|
8
|
+
# the OAuth access token.
|
9
|
+
#
|
10
|
+
module BambooId
|
11
|
+
module Urls
|
12
|
+
class AuthUrl
|
13
|
+
include BambooUrl
|
14
|
+
include BaseAuthUrl
|
15
|
+
|
16
|
+
def initialize(subdomain)
|
17
|
+
self.subdomain = subdomain
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_accessor :subdomain
|
23
|
+
|
24
|
+
def additional_params
|
25
|
+
{
|
26
|
+
request: 'authorize'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def base_url
|
31
|
+
"https://#{subdomain}.bamboohr.com/authorize.php"
|
32
|
+
end
|
33
|
+
|
34
|
+
def param_strings
|
35
|
+
params.map { |key, value| "#{key}=#{value}" }
|
36
|
+
end
|
37
|
+
|
38
|
+
def scope
|
39
|
+
'openid email'
|
40
|
+
end
|
41
|
+
|
42
|
+
def redirect_uri
|
43
|
+
CGI.escape(Configuration.redirect_url)
|
44
|
+
end
|
45
|
+
|
46
|
+
def state_code
|
47
|
+
StateCode.new(subdomain).to_s
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# First step of OAuth 2 is getting an authorization code via an authorization grant.
|
2
|
+
# Then we use the code in a second request to get the access token.
|
3
|
+
#
|
4
|
+
# https://tools.ietf.org/html/rfc6749#section-1.3
|
5
|
+
|
6
|
+
module BambooId
|
7
|
+
module Urls
|
8
|
+
module BaseAuthUrl
|
9
|
+
def to_s
|
10
|
+
[
|
11
|
+
base_url,
|
12
|
+
param_strings.join('&')
|
13
|
+
].join('?')
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def param_strings
|
19
|
+
params.map { |key, value| "#{key}=#{value}" }
|
20
|
+
end
|
21
|
+
|
22
|
+
def params
|
23
|
+
base_params.merge(additional_params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def base_params
|
27
|
+
{
|
28
|
+
client_id: client_id,
|
29
|
+
scope: scope,
|
30
|
+
response_type: 'code',
|
31
|
+
state: state_code,
|
32
|
+
redirect_uri: redirect_uri
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def additional_params
|
37
|
+
{}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module BambooId
|
2
|
+
module Urls
|
3
|
+
module BaseOauthTokenUrl
|
4
|
+
def to_s
|
5
|
+
base_url
|
6
|
+
end
|
7
|
+
|
8
|
+
def params
|
9
|
+
{
|
10
|
+
client_id: client_id,
|
11
|
+
client_secret: client_secret,
|
12
|
+
grant_type: grant_type,
|
13
|
+
redirect_uri: redirect_uri,
|
14
|
+
scope: scope
|
15
|
+
}.tap do |parameters|
|
16
|
+
parameters[refresh? ? :refresh_token : :code] = temporary_code
|
17
|
+
end.select do |_key, value|
|
18
|
+
value != nil && value != ''
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_accessor :temporary_code, :grant_type
|
25
|
+
|
26
|
+
def scope
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def refresh?
|
31
|
+
grant_type == 'refresh_token'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module BambooId
|
2
|
+
module Urls
|
3
|
+
class OauthTokenUrl
|
4
|
+
include BambooUrl
|
5
|
+
include BaseOauthTokenUrl
|
6
|
+
|
7
|
+
def initialize(temporary_code:, subdomain:, grant_type: 'authorization_code')
|
8
|
+
self.temporary_code = temporary_code
|
9
|
+
self.subdomain = subdomain
|
10
|
+
self.grant_type = grant_type
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_accessor :subdomain
|
16
|
+
|
17
|
+
def base_url
|
18
|
+
"https://#{subdomain}.bamboohr.com/token.php?request=token"
|
19
|
+
end
|
20
|
+
|
21
|
+
def client_secret
|
22
|
+
Configuration.client_secret
|
23
|
+
end
|
24
|
+
|
25
|
+
def redirect_uri
|
26
|
+
Configuration.redirect_url
|
27
|
+
end
|
28
|
+
|
29
|
+
def scope
|
30
|
+
'openid email'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bamboo-id
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jon Evans
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httparty
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Easily connect your Ruby application to BambooHR through OpenID.
|
84
|
+
email:
|
85
|
+
- joncodes@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bamboo_id.gemspec
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/bamboo_id.rb
|
102
|
+
- lib/bamboo_id/api_key_fetcher.rb
|
103
|
+
- lib/bamboo_id/configuration.rb
|
104
|
+
- lib/bamboo_id/requests/access_token_request.rb
|
105
|
+
- lib/bamboo_id/requests/api_key_request.rb
|
106
|
+
- lib/bamboo_id/requests/base_access_token_request.rb
|
107
|
+
- lib/bamboo_id/requests/basic_request_handling.rb
|
108
|
+
- lib/bamboo_id/state_code.rb
|
109
|
+
- lib/bamboo_id/urls/api_key_url.rb
|
110
|
+
- lib/bamboo_id/urls/auth_url.rb
|
111
|
+
- lib/bamboo_id/urls/bamboo_url.rb
|
112
|
+
- lib/bamboo_id/urls/base_auth_url.rb
|
113
|
+
- lib/bamboo_id/urls/base_oauth_token_url.rb
|
114
|
+
- lib/bamboo_id/urls/oauth_token_url.rb
|
115
|
+
- lib/bamboo_id/version.rb
|
116
|
+
homepage: https://www.github.com/bonusly/bamboo-id
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.6.11
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Wrapper classes around the OpenID connect process.
|
140
|
+
test_files: []
|