sorcery-hh 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 +10 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/lib/sorcery/hh.rb +2 -0
- data/lib/sorcery/hh/version.rb +5 -0
- data/lib/sorcery/providers/hh.rb +51 -0
- data/sorcery-hh.gemspec +34 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 859c1ce3c3df3c1c7bc00a7a0ba8c932852f7b0b
|
4
|
+
data.tar.gz: 6d1dee273488e130668fb36d457077c844a2c6bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e5a566e6dd203c7ac6a5a0a393a60799b75afc36cf0a3c7ad551e6a6a75ef5a57828156605313cde647b029752feedda6a4621566d79fd5413f4ece442fe3cf
|
7
|
+
data.tar.gz: 461426316c02f805a44d31ba63189ea205f4ba0b33b2bccb33d82181643040172b659a7c5e642799bbba6d258d1c579ddf7a9d2b05fd7f79f502fb186b527216
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Teachbase
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Sorcery::Hh
|
2
|
+
|
3
|
+
[HeadHunter](https://hh.ru) as auth provider in Sorcery
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'sorcery-hh'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install sorcery-hh
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Just add this gem and you can use HeadHunter as auth provider
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
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).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/teachbase/sorcery-hh.
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/lib/sorcery/hh.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'sorcery/providers/base'
|
2
|
+
|
3
|
+
module Sorcery
|
4
|
+
module Providers
|
5
|
+
# This class adds support for OAuth with hh.ru.
|
6
|
+
#
|
7
|
+
# config.hh.key = <key>
|
8
|
+
# config.hh.secret = <secret>
|
9
|
+
# ...
|
10
|
+
#
|
11
|
+
class Hh < Base
|
12
|
+
include Protocols::Oauth2
|
13
|
+
|
14
|
+
attr_accessor :auth_path, :token_path, :user_info_url, :scope, :response_type
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
|
19
|
+
@scope = nil
|
20
|
+
@site = 'https://hh.ru/'
|
21
|
+
@user_info_url = 'http://api.hh.ru/me'
|
22
|
+
@auth_path = '/oauth/authorize'
|
23
|
+
@token_path = '/oauth/token'
|
24
|
+
@grant_type = 'authorization_code'
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_user_hash(access_token)
|
28
|
+
user_hash = auth_hash(access_token)
|
29
|
+
|
30
|
+
headers = { authorization: "Bearer #{access_token.token}" }
|
31
|
+
response = access_token.get(user_info_url, headers: headers)
|
32
|
+
|
33
|
+
user_hash[:uid] = user_hash[:user_info]["id"] if user_hash[:user_info] = JSON.parse(response.body)
|
34
|
+
|
35
|
+
user_hash
|
36
|
+
end
|
37
|
+
|
38
|
+
def login_url(params, session)
|
39
|
+
authorize_url({ authorize_url: auth_path })
|
40
|
+
end
|
41
|
+
|
42
|
+
def process_callback(params, session)
|
43
|
+
args = {}.tap do |a|
|
44
|
+
a[:code] = params[:code] if params[:code]
|
45
|
+
end
|
46
|
+
|
47
|
+
get_access_token(args, token_url: token_path, token_method: :post)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/sorcery-hh.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "sorcery/hh/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sorcery-hh"
|
8
|
+
spec.version = Sorcery::Hh::VERSION
|
9
|
+
spec.authors = ["earendil95"]
|
10
|
+
spec.email = ["ermak95@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Sorcery provider for HeadHunter}
|
13
|
+
spec.homepage = "https://github.com/teachbase/sorcery-hh"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency 'sorcery', "~> 0.9"
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sorcery-hh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- earendil95
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sorcery
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
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.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
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
|
+
description:
|
56
|
+
email:
|
57
|
+
- ermak95@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/sorcery/hh.rb
|
68
|
+
- lib/sorcery/hh/version.rb
|
69
|
+
- lib/sorcery/providers/hh.rb
|
70
|
+
- sorcery-hh.gemspec
|
71
|
+
homepage: https://github.com/teachbase/sorcery-hh
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata:
|
75
|
+
allowed_push_host: https://rubygems.org
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.5.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Sorcery provider for HeadHunter
|
96
|
+
test_files: []
|