omniauth-loctouch 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/README.md +31 -0
- data/Rakefile +21 -0
- data/lib/omniauth-loctouch.rb +2 -0
- data/lib/omniauth-loctouch/version.rb +5 -0
- data/lib/omniauth/strategies/loctouch.rb +42 -0
- data/omniauth-loctouch.gemspec +26 -0
- data/spec/omniauth/strategies/loctouch_spec.rb +39 -0
- data/spec/spec_helper.rb +8 -0
- metadata +103 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Omniauth Loctouch [![Build Status](https://secure.travis-ci.org/kyanny/omniauth-loctouch.png)](http://travis-ci.org/kyanny/omniauth-loctouch)
|
2
|
+
|
3
|
+
Strategy to auth with Loctouch via OAuth2.0 in OmniAuth.
|
4
|
+
|
5
|
+
Get your API key at https://tou.ch/developer/apps/
|
6
|
+
|
7
|
+
Be sure when you register callback url will be "http://sample.com/auth/loctouch/callback"
|
8
|
+
|
9
|
+
## Basic Usage
|
10
|
+
|
11
|
+
use OmniAuth::Builder do
|
12
|
+
provider "loctouch", ENV['LOCTOUCH_CLIENT_ID'], ENV['LOCTOUCH_CLIENT_SECRET']
|
13
|
+
end
|
14
|
+
|
15
|
+
## Ruby
|
16
|
+
|
17
|
+
Tested with the following Ruby versions:
|
18
|
+
|
19
|
+
- MRI 1.8.7
|
20
|
+
- MRI 1.9.2
|
21
|
+
- MRI 1.9.3
|
22
|
+
|
23
|
+
## See Also
|
24
|
+
|
25
|
+
sample rails application is available:
|
26
|
+
|
27
|
+
https://github.com/kyanny/hello-omniauth-loctouch
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
MIT License http://kyanny.mit-license.org/
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
desc 'Default: run specs.'
|
5
|
+
task :default => :spec
|
6
|
+
|
7
|
+
desc 'Run specs'
|
8
|
+
RSpec::Core::RakeTask.new
|
9
|
+
|
10
|
+
desc 'Run specs'
|
11
|
+
task :default => :spec
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'omniauth-oauth2'
|
3
|
+
require 'multi_json'
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Loctouch < OmniAuth::Strategies::OAuth2
|
8
|
+
option :client_options, {
|
9
|
+
:site => 'https://api.loctouch.com',
|
10
|
+
:authorize_url => 'https://tou.ch/oauth2/authenticate',
|
11
|
+
:token_url => 'https://tou.ch/oauth2/token'
|
12
|
+
}
|
13
|
+
|
14
|
+
def request_phase
|
15
|
+
options[:response_type] ||= 'code'
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
uid { raw_info["id"] }
|
20
|
+
|
21
|
+
info do
|
22
|
+
{
|
23
|
+
'nickname' => raw_info["display_name"],
|
24
|
+
'image' => raw_info["icon"],
|
25
|
+
'urls' => { 'Loctouch' => raw_info["link"] }
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
extra do
|
30
|
+
{ :raw_info => raw_info }
|
31
|
+
end
|
32
|
+
|
33
|
+
def raw_info
|
34
|
+
access_token.options[:mode] = :query
|
35
|
+
access_token.options[:param_name] = 'oauth_token'
|
36
|
+
@raw_info ||= MultiJson.decode(access_token.get("/v1/users/@self", { 'oauth_token' => access_token.token }).body)["user"]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
OmniAuth.config.add_camelization 'loctouch', 'Loctouch'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-loctouch/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-loctouch"
|
7
|
+
s.version = OmniAuth::Loctouch::VERSION
|
8
|
+
s.authors = ["Kensuke Nagae"]
|
9
|
+
s.email = ["kyanny@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/banyan/omniauth-loctouch"
|
11
|
+
s.summary = %q{OmniAuth strategy for Loctouch}
|
12
|
+
s.description = s.summary
|
13
|
+
|
14
|
+
s.rubyforge_project = "omniauth-loctouch"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency "omniauth-oauth2", '~> 1.0'
|
22
|
+
s.add_runtime_dependency "multi_json", '~> 1.0.4'
|
23
|
+
|
24
|
+
s.add_development_dependency "rspec", '~> 2.7'
|
25
|
+
s.add_development_dependency "rake"
|
26
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Loctouch do
|
4
|
+
before do
|
5
|
+
@consumer_key = 'key'
|
6
|
+
@consumer_secret = 'secret'
|
7
|
+
end
|
8
|
+
|
9
|
+
subject do
|
10
|
+
args = [@client_id, @client_secret, @options].compact
|
11
|
+
OmniAuth::Strategies::Loctouch.new(nil, *args).tap do |strategy|
|
12
|
+
strategy.stub(:request) { @request }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#consumer' do
|
17
|
+
it 'has correct Loctouch site' do
|
18
|
+
subject.client.site.should eq('https://api.loctouch.com')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has correct access token url' do
|
22
|
+
subject.client.token_url.should eq('https://tou.ch/oauth2/token')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'has correct authorize url' do
|
26
|
+
subject.client.authorize_url.should eq('https://tou.ch/oauth2/authenticate')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#uid' do
|
31
|
+
before :each do
|
32
|
+
subject.stub(:raw_info) { { 'id' => '123' } }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns the id from raw_info' do
|
36
|
+
subject.uid.should eq('123')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-loctouch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kensuke Nagae
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: &189632200 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *189632200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: multi_json
|
27
|
+
requirement: &189631700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.4
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *189631700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &189631240 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.7'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *189631240
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &189630860 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *189630860
|
58
|
+
description: OmniAuth strategy for Loctouch
|
59
|
+
email:
|
60
|
+
- kyanny@gmail.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- .rspec
|
67
|
+
- .travis.yml
|
68
|
+
- Gemfile
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- lib/omniauth-loctouch.rb
|
72
|
+
- lib/omniauth-loctouch/version.rb
|
73
|
+
- lib/omniauth/strategies/loctouch.rb
|
74
|
+
- omniauth-loctouch.gemspec
|
75
|
+
- spec/omniauth/strategies/loctouch_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
homepage: https://github.com/banyan/omniauth-loctouch
|
78
|
+
licenses: []
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project: omniauth-loctouch
|
97
|
+
rubygems_version: 1.8.11
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: OmniAuth strategy for Loctouch
|
101
|
+
test_files:
|
102
|
+
- spec/omniauth/strategies/loctouch_spec.rb
|
103
|
+
- spec/spec_helper.rb
|