omniauth-edwith-oauth2 0.1.1

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: 39e0e4dd8c9e3f797a4418e7ee76829dfd16b540508ff318633b9b5d8d9b1d0d
4
+ data.tar.gz: 54497bba3d352c529a95d97a32e281543e3b09d267e910f0132974f3d4d2cde1
5
+ SHA512:
6
+ metadata.gz: 8cb9b69a0b9febe8a14dfb5ca669c5339203b8c35da2e7b068925fce5094c469071a4c34bf941274a3fa289d60a6a512af523d7cbb6de00f2d99cf0ca4731bf1
7
+ data.tar.gz: 10671f27094f712f390935a002b589d448db40a7576736496aeff12f84554276e09d2637c3bcbf00460ddc9f16ac8c97c5e009d341defc455e6d9ede077e7a34
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.2
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-edwith-oauth2.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Omniauth::Edwith::Oauth2
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/edwith/oauth2`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-edwith-oauth2'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-edwith-oauth2
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-edwith-oauth2.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/edwith/oauth2"
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,2 @@
1
+ require "omniauth-edwith-oauth2/version"
2
+ require "omniauth/strategies/edwith_oauth2"
@@ -0,0 +1,6 @@
1
+ module Omniauth
2
+ module EdwithOauth2
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
6
+
@@ -0,0 +1,74 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class EdwithOauth2 < OmniAuth::Strategies::OAuth2
6
+ option :name, 'edwith_oauth2'
7
+
8
+ option :client_options, {
9
+ site: '',
10
+ user_info_url: '',
11
+ authorize_url: '',
12
+ token_url: ''
13
+ }
14
+
15
+ option :user_response_structure, {
16
+ root_path: ['data'],
17
+ id_path: 'id',
18
+ attributes: {
19
+ name: 'nickName',
20
+ email: 'email',
21
+ nickname: 'nickName'
22
+ }
23
+ }
24
+
25
+ option :auth_token_params, {
26
+ mode: :query
27
+ }
28
+
29
+ option :redirect_url
30
+
31
+ uid do
32
+ fetch_user_info(user_paths[:id_path]).to_s
33
+ end
34
+
35
+ info do
36
+ user_paths[:attributes].inject({}) do |user_hash, (field, path)|
37
+ value = fetch_user_info(path)
38
+ user_hash[field] = value if value
39
+ user_hash
40
+ end
41
+ end
42
+
43
+ extra do
44
+ { raw_info: raw_info }
45
+ end
46
+
47
+ def raw_info
48
+ @raw_info ||= access_token.get(options.client_options[:user_info_url]).parsed
49
+ end
50
+
51
+ def authorize_params
52
+ params = super
53
+ Hash[params.map { |k, v| [k, v.respond_to?(:call) ? v.call(request) : v] }]
54
+ end
55
+
56
+ private
57
+
58
+ def user_paths
59
+ options.user_response_structure
60
+ end
61
+
62
+ def fetch_user_info(path)
63
+ return nil unless path
64
+ full_path = path.is_a?(Array) ? path : Array(user_paths[:root_path]) + [path]
65
+ full_path.inject(raw_info) { |info, key| info[key] rescue nil }
66
+ end
67
+
68
+ def callback_url
69
+ options.redirect_url || (full_host + script_name + callback_path)
70
+ end
71
+ end
72
+ end
73
+ end
74
+
@@ -0,0 +1,25 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "omniauth-edwith-oauth2/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-edwith-oauth2"
8
+ spec.version = Omniauth::EdwithOauth2::VERSION
9
+ spec.authors = ["Minhyeok Ju"]
10
+ spec.email = ["mh4877@naver.com"]
11
+
12
+ spec.summary = %q{Configurable Omniauth Strategy for edwith providers.}
13
+ spec.description = spec.summary
14
+
15
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
16
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ end
18
+ spec.bindir = "bin"
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.17"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-edwith-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Minhyeok Ju
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-20 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.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
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
+ description: Configurable Omniauth Strategy for edwith providers.
56
+ email:
57
+ - mh4877@naver.com
58
+ executables:
59
+ - console
60
+ - setup
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
+ - Gemfile
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/omniauth-edwith-oauth2.rb
73
+ - lib/omniauth-edwith-oauth2/version.rb
74
+ - lib/omniauth/strategies/edwith_oauth2.rb
75
+ - omniauth-edwith-oauth2.gemspec
76
+ homepage:
77
+ licenses: []
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.0.3
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Configurable Omniauth Strategy for edwith providers.
98
+ test_files: []