omniauth-headhunter 1.0.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 +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +7 -0
- data/lib/omniauth-headhunter.rb +8 -0
- data/lib/omniauth-headhunter/version.rb +5 -0
- data/lib/omniauth/headhunter.rb +1 -0
- data/lib/omniauth/strategies/headhunter.rb +44 -0
- data/omniauth-headhunter.gemspec +26 -0
- data/spec/omniauth/strategies/headhunter_spec.rb +37 -0
- data/spec/spec_helper.rb +13 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 691d376b837daf5104df1a86b052bb450f9a62c7
|
4
|
+
data.tar.gz: 2e9f9c9e2bb2811003d6c985260cbfe804816983
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d9a9819bec8dd0f7c214810f7e7dc0a263d2eedac04bc0625bf7c47e2a4443f91f4c1427030edc14eed86ff089fcb3ff86ccb8937c6d847ee7e811199e39781b
|
7
|
+
data.tar.gz: 186c5930d25d76c5c1fd006867529e765d3d031e2c0667527dff02dc70ce05cf319ae3ae676ba16b7b6ad1ed6faa689cb3c9d8764c44976e2d731f2eb10a91df
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2017 metastasis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#OmniAuth 1.2 HeadHunter (OAuth 2) strategy
|
2
|
+
|
3
|
+
This gem is designed to work with OmniAuth 1.2 library against hh.ru
|
4
|
+
|
5
|
+
## How to include in your Gemfile
|
6
|
+
|
7
|
+
```
|
8
|
+
gem 'omniauth-headhunter'
|
9
|
+
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install omniauth-headhunter
|
19
|
+
|
20
|
+
## Basic Usage
|
21
|
+
|
22
|
+
use OmniAuth::Builder do
|
23
|
+
provider :headhunter, ENV['HEADHUNTER_KEY'], ENV['HEADHUNTER_SECRET']
|
24
|
+
end
|
25
|
+
|
26
|
+
##Author
|
27
|
+
|
28
|
+
Metastasis <metastasis@protonmail.ch>
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "omniauth/strategies/headhunter.rb"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "omniauth-oauth2"
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class HeadHunter < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
USERINFO_ENDPOINT = "https://api.hh.ru/me"
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
:site => "https://hh.ru",
|
11
|
+
:token_url => "/oauth/token",
|
12
|
+
:authorize_url => "/oauth/authorize"
|
13
|
+
}
|
14
|
+
|
15
|
+
option :redirect_url
|
16
|
+
|
17
|
+
|
18
|
+
uid { raw_info["id"].to_s }
|
19
|
+
|
20
|
+
info do
|
21
|
+
{
|
22
|
+
name: raw_info["first_name"],
|
23
|
+
email: raw_info["email"]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
extra do
|
28
|
+
{ raw_info: raw_info }
|
29
|
+
end
|
30
|
+
|
31
|
+
def raw_info
|
32
|
+
@raw_info ||= access_token.get(USERINFO_ENDPOINT).parsed
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def callback_url
|
38
|
+
options.redirect_url || (full_host + script_name + callback_path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
OmniAuth.config.add_camelization "headhunter", "HeadHunter"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth-headhunter/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "omniauth-headhunter"
|
7
|
+
gem.version = OmniAuth::HeadHunter::VERSION
|
8
|
+
gem.authors = ["Metastasis"]
|
9
|
+
gem.email = ["metastasis@protonmail.ch"]
|
10
|
+
gem.description = %q{OmniAuth (OAuth 2) strategy for hh.ru}
|
11
|
+
gem.summary = %q{OmniAuth HeadHunter (OAuth 2) strategy for hh.ru}
|
12
|
+
gem.homepage = "https://github.com/metastasis/omniauth-headhunter"
|
13
|
+
gem.license = "MIT"
|
14
|
+
|
15
|
+
gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
|
16
|
+
gem.add_development_dependency 'rack-test'
|
17
|
+
gem.add_development_dependency 'rspec'
|
18
|
+
gem.add_development_dependency 'rspec-its'
|
19
|
+
# gem.add_dependency 'multi_json'
|
20
|
+
# gem.add_development_dependency 'webmock'
|
21
|
+
|
22
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
gem.files = `git ls-files`.split("\n")
|
24
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
gem.require_paths = ["lib"]
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::HeadHunter do
|
4
|
+
|
5
|
+
before do
|
6
|
+
OmniAuth.config.test_mode = true
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
OmniAuth.config.test_mode = false
|
11
|
+
end
|
12
|
+
|
13
|
+
subject do
|
14
|
+
OmniAuth::Strategies::HeadHunter.new(nil, @options || {})
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#client' do
|
18
|
+
it 'has correct site URL' do
|
19
|
+
expect(subject.client.site).to eq('https://hh.ru')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has correct authorize URL' do
|
23
|
+
expect(subject.client.authorize_url).to eq('https://hh.ru/oauth/authorize')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has correct token URL' do
|
27
|
+
expect(subject.client.token_url).to eq('https://hh.ru/oauth/token')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#callback_path' do
|
32
|
+
it "has the correct callback path" do
|
33
|
+
expect(subject.callback_path).to eq('/auth/headhunter/callback')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'rspec'
|
6
|
+
require 'rack/test'
|
7
|
+
require 'omniauth'
|
8
|
+
require 'omniauth-headhunter'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include Rack::Test::Methods
|
12
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-headhunter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Metastasis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-08 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.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack-test
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
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
|
+
description: OmniAuth (OAuth 2) strategy for hh.ru
|
70
|
+
email:
|
71
|
+
- metastasis@protonmail.ch
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/omniauth-headhunter.rb
|
83
|
+
- lib/omniauth-headhunter/version.rb
|
84
|
+
- lib/omniauth/headhunter.rb
|
85
|
+
- lib/omniauth/strategies/headhunter.rb
|
86
|
+
- omniauth-headhunter.gemspec
|
87
|
+
- spec/omniauth/strategies/headhunter_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: https://github.com/metastasis/omniauth-headhunter
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.5.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: OmniAuth HeadHunter (OAuth 2) strategy for hh.ru
|
113
|
+
test_files: []
|