omniauth-namba 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Gemfile +14 -0
- data/Guardfile +5 -0
- data/LICENSE +22 -0
- data/README.md +54 -0
- data/Rakefile +7 -0
- data/lib/omniauth-namba.rb +8 -0
- data/lib/omniauth-namba/version.rb +5 -0
- data/lib/omniauth/strategies/namba.rb +50 -0
- data/omniauth-namba.gemspec +25 -0
- data/spec/omniauth/strategies/namba_spec.rb +27 -0
- data/spec/spec_helper.rb +14 -0
- metadata +119 -0
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in omniauth-linkedin.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'omniauth-oauth', :git => 'https://github.com/intridea/omniauth-oauth.git'
|
7
|
+
|
8
|
+
group :development, :test do
|
9
|
+
gem 'guard'
|
10
|
+
gem 'guard-rspec'
|
11
|
+
gem 'guard-bundler'
|
12
|
+
gem 'libnotify'
|
13
|
+
gem 'multi_json'
|
14
|
+
end
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Sergey Kishenin
|
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,54 @@
|
|
1
|
+
## omniauth-namba Ruby gem
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/ZeroOneStudio/omniauth-namba.png)](http://travis-ci.org/ZeroOneStudio/omniauth-namba)
|
4
|
+
|
5
|
+
This gem contains the Namba.kg strategy for OmniAuth. Namba.kg uses the OAuth 1.0a flow.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
Add the strategy to your `Gemfile`:
|
9
|
+
|
10
|
+
gem "omniauth-namba"
|
11
|
+
|
12
|
+
For a Rails application you'd now create an initializer `config/initializers/omniauth.rb`:
|
13
|
+
|
14
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
15
|
+
provider :namba, 'key', 'secret'
|
16
|
+
end
|
17
|
+
|
18
|
+
Or for a Rack application:
|
19
|
+
|
20
|
+
use OmniAuth::Builder do
|
21
|
+
provider :namba, "key", "secret"
|
22
|
+
end
|
23
|
+
|
24
|
+
If you use omniauth with Devise just add configuration to `devise.rb` initializer:
|
25
|
+
|
26
|
+
Devise.setup do |config|
|
27
|
+
config.omniauth :namba, "key", "secret"
|
28
|
+
end
|
29
|
+
|
30
|
+
## Auth hash
|
31
|
+
|
32
|
+
{
|
33
|
+
:status => "I'm Chuck and I love Namba",
|
34
|
+
:login => "chuck_norris",
|
35
|
+
:firstname => "Chuck",
|
36
|
+
:lastname => "Norris",
|
37
|
+
:birthdate => "yyy-mm-dd 00:00:00",
|
38
|
+
:sex => "0",
|
39
|
+
:avatar => "0000000,0000000,0000000"
|
40
|
+
}
|
41
|
+
|
42
|
+
Detailed description of each fields goes [here][].
|
43
|
+
|
44
|
+
[here]: http://dev.namba.kg/api_description.php
|
45
|
+
|
46
|
+
## Acknowledgements
|
47
|
+
|
48
|
+
Many thanks to [@puzanov][] for active promotion.
|
49
|
+
|
50
|
+
[@puzanov]: https://github.com/puzanov
|
51
|
+
|
52
|
+
## Licence
|
53
|
+
MIT License. Copyright (c) 2012 ZERO.ONE
|
54
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'omniauth-oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Namba < OmniAuth::Strategies::OAuth
|
8
|
+
|
9
|
+
option :name, "namba"
|
10
|
+
option :client_options, {
|
11
|
+
:site => "http://api.namba.kg",
|
12
|
+
:request_token_path => "/oauth/request_token.php",
|
13
|
+
:authorize_url => "http://login.namba.kg/login2.php",
|
14
|
+
:access_token_path => "/oauth/access_token.php"
|
15
|
+
}
|
16
|
+
|
17
|
+
option :fields, ["status", "login", "firstname", "lastname", "birthdate", "sex", "avatar"]
|
18
|
+
|
19
|
+
uid { raw_info['login'] }
|
20
|
+
|
21
|
+
info do
|
22
|
+
{
|
23
|
+
:status => raw_info['status'],
|
24
|
+
:login => raw_info['login'],
|
25
|
+
:firstname => raw_info['firstname'],
|
26
|
+
:lastname => raw_info['lastname'],
|
27
|
+
:birthdate => raw_info['birthdate'],
|
28
|
+
:sex => raw_info['sex'],
|
29
|
+
:avatar => raw_info['avatar']
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
extra do
|
34
|
+
{
|
35
|
+
'raw_info' => raw_info
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def raw_info
|
40
|
+
@raw_info ||= MultiJson.load(access_token.get('http://api.namba.kg/getUserInfo2.php').body)
|
41
|
+
rescue ::Errno::ETIMEDOUT
|
42
|
+
raise ::Timeout::Error
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
OmniAuth.config.add_camelization 'namba', 'Namba'
|
50
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-namba/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Sergey Kishenin", "Michael Romanenko"]
|
7
|
+
gem.email = ["sergey.kishenin@gmail.com", "michael@romanenko.kg"]
|
8
|
+
gem.description = %q{Authenticate to Namba using OAuth.}
|
9
|
+
gem.summary = %q{Authenticate to Namba using OAuth.}
|
10
|
+
gem.homepage = "https://github.com/ZeroOneStudio/omniauth-namba"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "omniauth-namba"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = Omniauth::Namba::VERSION
|
18
|
+
|
19
|
+
gem.add_runtime_dependency 'omniauth-oauth', '~> 1.0.0'
|
20
|
+
|
21
|
+
gem.add_development_dependency 'rspec', '~> 2.7.0'
|
22
|
+
gem.add_development_dependency 'rake'
|
23
|
+
gem.add_development_dependency 'webmock'
|
24
|
+
gem.add_development_dependency 'rack-test'
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "OmniAuth Namba" do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::Namba.new(nil, @options || {})
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should add a camelization for itself' do
|
9
|
+
OmniAuth::Utils.camelize('namba').should == 'Namba'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should has correct Namba site' do
|
13
|
+
subject.options.client_options.site.should eq('http://api.namba.kg')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should has correct request token path' do
|
17
|
+
subject.options.client_options.request_token_path.should eq('/oauth/request_token.php')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should has correct access token path' do
|
21
|
+
subject.options.client_options.access_token_path.should eq('/oauth/access_token.php')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should has correct authorize url' do
|
25
|
+
subject.options.client_options.authorize_url.should eq('http://login.namba.kg/login2.php')
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'rack/test'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
require 'omniauth'
|
8
|
+
require 'omniauth-namba'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include WebMock::API
|
12
|
+
config.include Rack::Test::Methods
|
13
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-namba
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sergey Kishenin
|
9
|
+
- Michael Romanenko
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-08-23 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: omniauth-oauth
|
17
|
+
requirement: &81111320 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *81111320
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
requirement: &81110710 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.7.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *81110710
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rake
|
39
|
+
requirement: &81109950 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *81109950
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: webmock
|
50
|
+
requirement: &81109620 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *81109620
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rack-test
|
61
|
+
requirement: &81125340 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *81125340
|
70
|
+
description: Authenticate to Namba using OAuth.
|
71
|
+
email:
|
72
|
+
- sergey.kishenin@gmail.com
|
73
|
+
- michael@romanenko.kg
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- .rspec
|
80
|
+
- .travis.yml
|
81
|
+
- Gemfile
|
82
|
+
- Guardfile
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- lib/omniauth-namba.rb
|
87
|
+
- lib/omniauth-namba/version.rb
|
88
|
+
- lib/omniauth/strategies/namba.rb
|
89
|
+
- omniauth-namba.gemspec
|
90
|
+
- spec/omniauth/strategies/namba_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
homepage: https://github.com/ZeroOneStudio/omniauth-namba
|
93
|
+
licenses: []
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 1.8.10
|
113
|
+
signing_key:
|
114
|
+
specification_version: 3
|
115
|
+
summary: Authenticate to Namba using OAuth.
|
116
|
+
test_files:
|
117
|
+
- spec/omniauth/strategies/namba_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
has_rdoc:
|