omniauth-adp-oauth2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 13b52eae3117f543c5def0a7eabb8c22b8ea2ec2
4
+ data.tar.gz: ebb044384966c7d6048eccd91aa923a5be686220
5
+ SHA512:
6
+ metadata.gz: d4c454b1318b5a04575bdefe473307494e8e7c9d323ea7fff9c5517fcd6e036dc87a6bb264278bd84280866c551ecfd5eb364f243208184bbd3338b00ebce7f2
7
+ data.tar.gz: 1a28198f88c10741073015f93b72c301657df091a11906b4fb873c1e6eda97bb615ea96fc678f4e752afb0c28c8ca53e4d92d20ea0826365e8ee995de7e4c64d
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .ruby-gemset
7
+ .ruby-version
8
+ .rvmrc
9
+ Gemfile.lock
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
21
+ .powenv
22
+ .idea/
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ before_install:
2
+ - gem update --system 2.1.11
3
+ language: ruby
4
+ rvm:
5
+ - "2.0.0"
6
+ - "2.1.0"
7
+ - "2.2.0"
8
+ - "2.3.0"
9
+ - "rbx"
10
+ - "jruby"
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: "rbx"
14
+ - rvm: "jruby"
data/CHANGELOG.md ADDED
@@ -0,0 +1,162 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ ## 0.4.1 - 2016-03-14
5
+
6
+ ### Added
7
+ - Nothing.
8
+
9
+ ### Deprecated
10
+ - Nothing.
11
+
12
+ ### Removed
13
+ - Nothing.
14
+
15
+ ### Fixed
16
+ - Fixed JWT iat leeway by requiring ruby-jwt 1.5.2
17
+
18
+ ## 0.4.0 - 2016-03-11
19
+
20
+ ### Added
21
+ - Addedd ability to specify multiple hosted domains.
22
+ - Added a default leeway of 1 minute to JWT token validation.
23
+ - Now requires ruby-jwt 1.5.x.
24
+
25
+ ### Deprecated
26
+ - Nothing.
27
+
28
+ ### Removed
29
+ - Removed support for ruby 1.9.3 as ruby-jwt 1.5.x does not support it.
30
+
31
+ ### Fixed
32
+ - Nothing.
33
+
34
+ ## 0.3.1 - 2016-01-28
35
+
36
+ ### Added
37
+ - Verify Hosted Domain if hd is set in options.
38
+
39
+ ### Deprecated
40
+ - Nothing.
41
+
42
+ ### Removed
43
+ - Dependency on addressable.
44
+
45
+ ### Fixed
46
+ - Nothing.
47
+
48
+ ## 0.3.0 - 2016-01-09
49
+
50
+ ### Added
51
+ - Updated verify_token to use the v3 tokeninfo endpoint.
52
+
53
+ ### Deprecated
54
+ - Nothing.
55
+
56
+ ### Removed
57
+ - Nothing.
58
+
59
+ ### Fixed
60
+ - Compatibility with omniauth-oauth2 1.4.0
61
+
62
+ ## 0.2.10 - 2015-11-05
63
+
64
+ ### Added
65
+ - Nothing.
66
+
67
+ ### Deprecated
68
+ - Nothing.
69
+
70
+ ### Removed
71
+ - Removed some checks on the id_token. Now only parses the id_token in the JWT processing.
72
+
73
+ ### Fixed
74
+ - Nothing.
75
+
76
+ ## 0.2.9 - 2015-10-29
77
+
78
+ ### Added
79
+ - Nothing.
80
+
81
+ ### Deprecated
82
+ - Nothing.
83
+
84
+ ### Removed
85
+ - Nothing.
86
+
87
+ ### Fixed
88
+ - Issue with omniauth-oauth2 where redirect_uri was handled improperly. We now lock the dependency to ~> 1.3.1
89
+
90
+ ## 0.2.8 - 2015-10-01
91
+
92
+ ### Added
93
+ - Added skip_jwt option to bypass JWT decoding in case you get decoding errors.
94
+
95
+ ### Deprecated
96
+ - Nothing.
97
+
98
+ ### Removed
99
+ - Nothing.
100
+
101
+ ### Fixed
102
+ - Resolved JWT::InvalidIatError. https://github.com/zquestz/omniauth-google-oauth2/issues/195
103
+
104
+ ## 0.2.7 - 2015-09-25
105
+
106
+ ### Added
107
+ - Now strips out the 'sz' parameter from profile image urls.
108
+ - Now uses 'addressable' gem for URI actions.
109
+ - Added image data to extras hash.
110
+ - Override validation on JWT token for open_id token.
111
+ - Handle authorization codes coming from an installed applications.
112
+
113
+ ### Deprecated
114
+ - Nothing.
115
+
116
+ ### Removed
117
+ - Nothing.
118
+
119
+ ### Fixed
120
+ - Fixes double slashes in google image urls.
121
+
122
+ ## 0.2.6 - 2014-10-26
123
+
124
+ ### Added
125
+ - Nothing.
126
+
127
+ ### Deprecated
128
+ - Nothing.
129
+
130
+ ### Removed
131
+ - Nothing.
132
+
133
+ ### Fixed
134
+ - Hybrid authorization issues due to bad method alias.
135
+
136
+ ## 0.2.5 - 2014-07-09
137
+
138
+ ### Added
139
+ - Support for versions of omniauth past 1.0.x.
140
+
141
+ ### Deprecated
142
+ - Nothing.
143
+
144
+ ### Removed
145
+ - Nothing.
146
+
147
+ ### Fixed
148
+ - Nothing.
149
+
150
+ ## 0.2.4 - 2014-04-25
151
+
152
+ ### Added
153
+ - Now requiring the "Contacts API" and "Google+ API" to be enabled in your Google API console.
154
+
155
+ ### Deprecated
156
+ - The old Google OAuth API support was removed without deprecation.
157
+
158
+ ### Removed
159
+ - Support for the old Google OAuth API. `OAuth2::Error` will be thrown and state that access is not configured when you attempt to authenticate using the old API. See Added section for this release.
160
+
161
+ ### Fixed
162
+ - Nothing.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,119 @@
1
+ [![Gem Version](https://badge.fury.io/rb/omniauth-google-oauth2.svg)](https://badge.fury.io/rb/omniauth-google-oauth2)
2
+ [![Build Status](https://travis-ci.org/zquestz/omniauth-google-oauth2.png)](https://travis-ci.org/zquestz/omniauth-google-oauth2)
3
+
4
+ # OmniAuth ADP OAuth2 Strategy
5
+
6
+ Strategy to authenticate with ADP via OpenID CConnect in OmniAuth.
7
+
8
+ ## Installation
9
+
10
+ Add to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem 'omniauth-adp-oauth2', github: 'dahal/omniauth-adp-oauth2'
14
+ ```
15
+
16
+ Then `bundle install`.
17
+
18
+
19
+ ## Usage
20
+
21
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :adp_oauth2, ENV["ADP_CONSUMER_CLIENT_ID"], ENV["ADP_CONSUMER_CLIENT_SECRET"]
26
+ end
27
+ ```
28
+
29
+ ### Devise
30
+
31
+ First define your application id and secret in `config/initializers/devise.rb`.
32
+
33
+ ```ruby
34
+ config.omniauth :adp_oauth2, "ADP_CONSUMER_CLIENT_ID", "ADP_CONSUMER_CLIENT_SECRET", { }
35
+ ```
36
+
37
+ Then add the following to 'config/routes.rb' so the callback routes are defined.
38
+
39
+ ```ruby
40
+ devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
41
+ ```
42
+
43
+ Make sure your model is omniauthable. Generally this is "/app/models/user.rb"
44
+
45
+ ```ruby
46
+ devise :omniauthable, :omniauth_providers => [:adp_oauth2]
47
+ ```
48
+
49
+ Then make sure your callbacks controller is setup.
50
+
51
+ ```ruby
52
+ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
53
+ def adp_oauth2
54
+ # You need to implement the method below in your model (e.g. app/models/user.rb)
55
+ @user = User.from_omniauth(request.env["omniauth.auth"])
56
+
57
+ if @user.persisted?
58
+ flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "ADP"
59
+ sign_in_and_redirect @user, :event => :authentication
60
+ else
61
+ session["devise.adp_data"] = request.env["omniauth.auth"]
62
+ redirect_to new_user_registration_url
63
+ end
64
+ end
65
+ end
66
+ ```
67
+
68
+ and bind to or create the user
69
+
70
+ ```ruby
71
+ def self.from_omniauth(access_token)
72
+ data = access_token.info
73
+ user = User.where(:email => data["email"]).first
74
+
75
+ # Uncomment the section below if you want users to be created if they don't exist
76
+ # unless user
77
+ # user = User.create(name: data["name"],
78
+ # email: data["email"],
79
+ # password: Devise.friendly_token[0,20]
80
+ # )
81
+ # end
82
+ user
83
+ end
84
+ ```
85
+
86
+ For your views you can login using:
87
+
88
+ ```erb
89
+ <%= link_to "Sign in with ADP", user_adp_oauth2_omniauth_authorize_path %>
90
+
91
+ <%# Devise prior 4.1.0: %>
92
+ <%= link_to "Sign in with ADP", user_omniauth_authorize_path(:adp_oauth2) %>
93
+ ```
94
+
95
+ An overview is available at https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
96
+
97
+
98
+
99
+ ## Auth Hash
100
+
101
+ Here's an example of an authentication hash available in the callback by accessing `request.env["omniauth.auth"]`:
102
+
103
+ ```ruby
104
+
105
+ ```
106
+
107
+ ## Credits
108
+
109
+ * [omniauth-google-oauth2](https://github.com/zquestz/omniauth-google-oauth2)
110
+
111
+ ## License
112
+
113
+ Copyright (c) 2016 by Puru Dahal
114
+
115
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
118
+
119
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env rake
2
+ require File.join('bundler', 'gem_tasks')
3
+ # require File.join('rspec', 'core', 'rake_task')
4
+ # RSpec::Core::RakeTask.new(:spec)
5
+ # task default: :spec
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module AdpOauth2
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'strategies', 'adp_oauth2')
@@ -0,0 +1,47 @@
1
+ require 'multi_json'
2
+ require 'jwt'
3
+ require 'omniauth/strategies/oauth2'
4
+ require 'uri'
5
+
6
+ module OmniAuth
7
+ module Strategies
8
+ class AdpOauth2 < OmniAuth::Strategies::OAuth2
9
+ DEFAULT_SCOPE = %w(
10
+ api
11
+ openid
12
+ profile
13
+ hr.workerInformationManagement.workerManagement.workerViewing.worker.read
14
+ hr.workerInformationManagement.workerManagement.associateManagement.associate.read
15
+ hr.workerInformationManagement.workerManagement.employeeManagement.employee.read
16
+ )
17
+
18
+ option :name, 'adp_oauth2'
19
+ option :skip_jwt, false
20
+ option :jwt_leeway, 60
21
+ option :authorize_options, %i(response_type client_id redirect_uri scope state)
22
+
23
+ option :client_options, {
24
+ :site => 'https://accounts.adp.com',
25
+ :authorize_url => '/auth/oauth/v2/authorize',
26
+ :token_url => '/auth/oauth/v2/token'
27
+ }
28
+
29
+ def authorize_params
30
+ super.tap do |params|
31
+ options[:authorize_options].each do |k|
32
+ params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
33
+ end
34
+
35
+ params[:scope] = DEFAULT_SCOPE.join(' ')
36
+ session['omniauth.state'] = params[:state] if params['state']
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def callback_url
43
+ options[:redirect_uri] || (full_host + script_name + callback_path)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'adp_oauth2')
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path(File.join('..', 'lib', 'omniauth', 'adp_oauth2', 'version'), __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'omniauth-adp-oauth2'
6
+ gem.version = OmniAuth::AdpOauth2::VERSION
7
+ gem.license = 'MIT'
8
+ gem.summary = %q{A ADP OpenID/OAuth2 strategy for OmniAuth 1.x}
9
+ gem.description = %q{A ADP OpenID/OAuth2 strategy for OmniAuth 1.x}
10
+ gem.authors = ['Puru Dahal']
11
+ gem.email = ['puru@dahal.me']
12
+ gem.homepage = 'https://github.com/dahal/omniauth-adp-oauth2'
13
+
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.require_paths = ['lib']
16
+
17
+ gem.required_ruby_version = '>= 2.0'
18
+
19
+ gem.add_runtime_dependency 'omniauth', '>= 1.1.1'
20
+ gem.add_runtime_dependency 'omniauth-oauth2', '>= 1.3.1'
21
+ gem.add_runtime_dependency 'jwt', '~> 1.5.2'
22
+ gem.add_runtime_dependency 'multi_json', '~> 1.3'
23
+
24
+ # gem.add_development_dependency 'rspec', '>= 2.14.0'
25
+ gem.add_development_dependency 'rake'
26
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-adp-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Puru Dahal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: jwt
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.5.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: multi_json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A ADP OpenID/OAuth2 strategy for OmniAuth 1.x
84
+ email:
85
+ - puru@dahal.me
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - CHANGELOG.md
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - lib/omniauth-adp-oauth2.rb
97
+ - lib/omniauth/adp_oauth2.rb
98
+ - lib/omniauth/adp_oauth2/version.rb
99
+ - lib/omniauth/strategies/adp_oauth2.rb
100
+ - omniauth-adp-oauth2.gemspec
101
+ homepage: https://github.com/dahal/omniauth-adp-oauth2
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '2.0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.4.5.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: A ADP OpenID/OAuth2 strategy for OmniAuth 1.x
125
+ test_files: []