omniauth-pacreception 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d82ca600c81b66497dc30d84e6f1ddf5dc86c48955a634507a9ea8a14c6910b8
4
+ data.tar.gz: ce437941985722bf4d0e6962dcef3aa27a0610b10f2a99c67d55a0945a5d409a
5
+ SHA512:
6
+ metadata.gz: 5ba0c56f32403d89bf5bd000b30ce998fb39267e771d94220d1f08a3927ff507de3ea7e50946058fc2823d0e78ce460c3e0273b68690360827d71b2aad871a27
7
+ data.tar.gz: c2f12b2be899b4d35b521034d77acf168f8887f71153e0cd8ffa3be5e0873f72c54aafda630d17c7c226a3cb3bec23ae92366a440618cb1d4b2de1a31d5b571e
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 1.17.1
@@ -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 TODO: Write your email address. 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
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in omniauth-pacreception.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-pacreception (0.2.3)
5
+ omniauth-oauth2 (~> 1.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ faraday (0.15.4)
11
+ multipart-post (>= 1.2, < 3)
12
+ hashie (3.6.0)
13
+ jwt (2.1.0)
14
+ minitest (5.11.3)
15
+ multi_json (1.13.1)
16
+ multi_xml (0.6.0)
17
+ multipart-post (2.0.0)
18
+ oauth2 (1.4.1)
19
+ faraday (>= 0.8, < 0.16.0)
20
+ jwt (>= 1.0, < 3.0)
21
+ multi_json (~> 1.3)
22
+ multi_xml (~> 0.5)
23
+ rack (>= 1.2, < 3)
24
+ omniauth (1.9.0)
25
+ hashie (>= 3.4.6, < 3.7.0)
26
+ rack (>= 1.6.2, < 3)
27
+ omniauth-oauth2 (1.6.0)
28
+ oauth2 (~> 1.1)
29
+ omniauth (~> 1.9)
30
+ rack (2.0.6)
31
+ rake (10.5.0)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 1.17)
38
+ minitest (~> 5.0)
39
+ omniauth-pacreception!
40
+ rake (~> 10.0)
41
+
42
+ BUNDLED WITH
43
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
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,115 @@
1
+ # Omniauth PacReception
2
+
3
+ ## PacReception OAuth2 Strategy for OmniAuth
4
+
5
+ This is official OmniAuth strategy for authenticating to pacreception.com. To use it, you'll need to register your consumer application on pacreception.com to get pair of OAuth2 Application ID and Secret. It supports the OAuth 2.0 server-side and client-side flows for 3rd party OAuth consumer applications
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-pacreception'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-pacreception
22
+
23
+ ## Usage
24
+
25
+ OmniAuth::Strategies::Pacreception is simply a Rack middleware.
26
+
27
+ First, register your application at 'www.pacreception.com/oauth/applications' with valid callback url to get app_id and secret (pacreception.com uses callback url to redirect to your app). Create environement variables 'PACRECEPTION_KEY', 'PACRECEPTION_SECRET' to store your app_id, secret respectively. Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb.
28
+
29
+
30
+ ```ruby
31
+ Rails.application.config.middleware.use OmniAuth::Builder do
32
+ provider :pacreception, ENV['PACRECEPTION_KEY'], ENV['PACRECEPTION_SECRET']
33
+ end
34
+ ```
35
+
36
+ ## Configuration
37
+
38
+ You can configure several options, which you can pass in to the `provider` method via a `Hash`. also refer 'Examples' section accordingly.
39
+
40
+ Option name | Default | Explanation
41
+ --- | --- | ---
42
+ `scope` | `public` | lets you set scope to provide granular access to different types of data. If not provided, scope defaults to 'public' for users. you can use any one of "write", "public" and "admin" values for scope.
43
+ `auth_type` | nil | Optionally specifies the requested authentication feature. Valid value is 'reauthenticate' (asks the user to re-authenticate unconditionally). If not specified, default value is nil. (reuses the existing session of last authenticated user if any).
44
+ `callback_path` | '/auth/:provider/callback' | Specify a custom callback URL used during the server-side flow. Note this must be same as specified at the time of your applicaiton registration at www.pacreception.com/oauth/applications. Execution flow returns back to this point at consumer application after authencitcation flow finishes at server-side. If not specified, default is '/auth/:provider/callback'. Make an entry for this end point in config/routes.rb of your consumer application. Strategy automatically replaces ':provider' by provider name as specified in config/initializers/omniauth.rb.
45
+
46
+ ### Examples
47
+
48
+ #### scope
49
+
50
+ ```ruby
51
+ Rails.application.config.middleware.use OmniAuth::Builder do
52
+ provider :pacreception, ENV['PACRECEPTION_KEY'], ENV['PACRECEPTION_SECRET'], { scope: 'admin' }
53
+ end
54
+ ```
55
+ If not specified, default scope is 'public'
56
+
57
+ #### auth_type
58
+
59
+ ```ruby
60
+ Rails.application.config.middleware.use OmniAuth::Builder do
61
+ provider :pacreception, ENV['PACRECEPTION_KEY'], ENV['PACRECEPTION_SECRET'],
62
+ { scope: 'admin', authorize_params: { auth_type: 'reauthenticate' }}
63
+ end
64
+ ```
65
+ If not specified, default is nil.
66
+
67
+ #### callback_path
68
+
69
+ ```ruby
70
+ Rails.application.config.middleware.use OmniAuth::Builder do
71
+ provider :pacreception, ENV['PACRECEPTION_KEY'], ENV['PACRECEPTION_SECRET'],
72
+ { scope: 'admin', authorize_params: { auth_type: 'reauthenticate' },
73
+ callback_path: '/your/custom/callback/path'}
74
+ end
75
+ ```
76
+ If not specified, default callback_path is '/auth/:provider/callback'.Here, finally it would be '/auth/pacreception/callback' as per explained in configuration table.
77
+
78
+ ## Auth Hash
79
+
80
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
81
+
82
+ ```ruby
83
+ {
84
+ provider: 'pacreception',
85
+ uid: 1212123,
86
+ info: {
87
+ email: 'dark.knight@gotham.com',
88
+ name: 'Bruce Wayne'
89
+ },
90
+ credentials: {
91
+ token: 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store
92
+ expires_at: 1321747205, # when the access token expires (it always will)
93
+ expires: true # this will always be true
94
+ },
95
+ extra: {
96
+ raw_info: {
97
+ user: {
98
+ id: 1212123,
99
+ email: 'dark.knight@gotham.com',
100
+ first_name: 'Bruce',
101
+ last_name: 'Wayne'
102
+ }
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+
109
+ ## Contributing
110
+
111
+ 1. Fork it ( https://github.com/[my-github-username]/omniauth-pacreception/fork )
112
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
113
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
114
+ 4. Push to the branch (`git push origin my-new-feature`)
115
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'omniauth/pacreception'
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Pacreception
3
+ VERSION = "0.2.3"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require "omniauth/pacreception/version"
2
+ require "omniauth/strategies/pacreception"
3
+
4
+ module Omniauth
5
+ module Pacreception
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,60 @@
1
+ require 'omniauth/strategies/oauth2'
2
+ require 'uri'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Pacreception < OmniAuth::Strategies::OAuth2
7
+ # class NoAuthorizationCodeError < StandardError; en
8
+ DEFAULT_SCOPE = 'public'
9
+
10
+ option :name, :pacreception
11
+
12
+ option :client_options, {
13
+ site: "https://www.pacreception.com"
14
+ }
15
+
16
+ option :authorize_options, [:scope, :auth_type]
17
+
18
+ uid { raw_info['user']['id'] }
19
+
20
+ info do
21
+ prune!({
22
+ 'email' => raw_info['user']['email'],
23
+ 'name' => "#{raw_info['user']['first_name']} #{raw_info['user']['last_name']}"
24
+ })
25
+ end
26
+
27
+ extra do
28
+ hash = {}
29
+ hash['raw_info'] = raw_info unless skip_info?
30
+ prune! hash
31
+ end
32
+
33
+ def raw_info
34
+ @raw_info ||= access_token.get('/api/v1/me').parsed
35
+ end
36
+
37
+ def authorize_params
38
+ super.tap do |params|
39
+ %w[scope auth_type].each do |v|
40
+ if request.params[v]
41
+ params[v.to_sym] = request.params[v]
42
+ end
43
+ end
44
+ params[:scope] ||= DEFAULT_SCOPE
45
+ end
46
+ end
47
+
48
+ def callback_url
49
+ options[:callback_url] || super
50
+ end
51
+
52
+ def prune!(hash)
53
+ hash.delete_if do |_, value|
54
+ prune!(value) if value.is_a?(Hash)
55
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/pacreception'
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "omniauth/pacreception/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-pacreception"
8
+ spec.version = Omniauth::Pacreception::VERSION
9
+ spec.authors = ["Akash Srivastava"]
10
+ spec.email = ["akash.srivastava@elitmus.com"]
11
+
12
+ spec.summary = %q{PAC Reception OAuth2 Strategy for OmniAuth}
13
+ spec.description = %q{PAC Reception OAuth2 Strategy for OmniAuth}
14
+ spec.homepage = "https://github.com/akkee/omniauth-pacreception"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = spec.homepage
24
+ spec.metadata["changelog_uri"] = "https://github.com/akkee/omniauth-pacreception"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.5'
40
+
41
+ spec.add_development_dependency "bundler", "~> 1.17"
42
+ spec.add_development_dependency "rake", "~> 10.0"
43
+ spec.add_development_dependency "minitest", "~> 5.0"
44
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-pacreception
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ platform: ruby
6
+ authors:
7
+ - Akash Srivastava
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.17'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.17'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ description: PAC Reception OAuth2 Strategy for OmniAuth
70
+ email:
71
+ - akash.srivastava@elitmus.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/omniauth-pacreception.rb
87
+ - lib/omniauth/pacreception.rb
88
+ - lib/omniauth/pacreception/version.rb
89
+ - lib/omniauth/strategies/pacreception.rb
90
+ - omniauth-pacreception.gemspec
91
+ homepage: https://github.com/akkee/omniauth-pacreception
92
+ licenses:
93
+ - MIT
94
+ metadata:
95
+ allowed_push_host: https://rubygems.org
96
+ homepage_uri: https://github.com/akkee/omniauth-pacreception
97
+ source_code_uri: https://github.com/akkee/omniauth-pacreception
98
+ changelog_uri: https://github.com/akkee/omniauth-pacreception
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubygems_version: 3.0.0
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: PAC Reception OAuth2 Strategy for OmniAuth
118
+ test_files: []