omniauth_cobot 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +22 -0
- data/MIT_LICENSE.txt +19 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/lib/omniauth/cobot/version.rb +5 -0
- data/lib/omniauth/strategies/cobot.rb +33 -0
- data/lib/omniauth_cobot.rb +2 -0
- data/omniauth_cobot.gemspec +23 -0
- metadata +86 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/*
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth_cobot (0.0.1)
|
5
|
+
omniauth
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
hashie (1.2.0)
|
11
|
+
omniauth (1.1.1)
|
12
|
+
hashie (~> 1.2)
|
13
|
+
rack
|
14
|
+
rack (1.4.1)
|
15
|
+
rake (0.9.2.2)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
omniauth_cobot!
|
22
|
+
rake
|
data/MIT_LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
### About
|
2
|
+
|
3
|
+
This gem provides an [OmniAuth](https://github.com/intridea/omniauth) strategy for authenticating with [Cobot](http://cobot.me).
|
4
|
+
|
5
|
+
### Rails
|
6
|
+
|
7
|
+
Add the following as an initializer:
|
8
|
+
|
9
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
10
|
+
provider :cobot, '<client_id>', '<client_secret>', scope: 'read write'
|
11
|
+
end
|
12
|
+
|
13
|
+
This gives you access to a variable `request.env['omniauth.auth']` in your authentication callback that looks like this:
|
14
|
+
|
15
|
+
* `uid` - the id of the user
|
16
|
+
* `info` - `{'email' => '<user email>', 'picture' => '<url>'}`
|
17
|
+
* `extra` - `{:raw_info => { "id": "<user id>", "email": "<email>", "picture": "<picture url>", "mac_addresses": ["<mac address>"...], "memberships": [{ "space_link": "<https://www.cobot.me/api/spaces/some-space>", "link": "<https://some-space.cobot.me/api/memberships/some-membership>" } ], "admin_of": [ { "space_link": "<https://www.cobot.me/api/spaces/some-space>", "name": "<admin name>" } ] }`
|
18
|
+
|
19
|
+
|
20
|
+
"user_info"=>{"name"=>"janesmith",
|
21
|
+
"email"=>"janesmith@example.com"},
|
22
|
+
"extra"=>{
|
23
|
+
"user_hash"=>{
|
24
|
+
"login"=>"janesmith",
|
25
|
+
"email"=>"janesmith@example.com",
|
26
|
+
"id"=>"user-janesmith",
|
27
|
+
"memberships"=>[{
|
28
|
+
"link"=>"https://co-up.cobot.me/api/memberships/738...b53",
|
29
|
+
"space_link"=>"https://www.cobot.me/api/spaces/co-up"}],
|
30
|
+
"admin_of"=>[
|
31
|
+
{"space_link"=>"https://www.cobot.me/api/spaces/my_subdomain"},
|
32
|
+
{"space_link"=>"https://www.cobot.me/api/spaces/test2"}]
|
33
|
+
}
|
34
|
+
}
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Cobot < OmniAuth::Strategies::OAuth2
|
6
|
+
option :client_options, {
|
7
|
+
:site => 'https://www.cobot.me',
|
8
|
+
:authorize_url => 'https://www.cobot.me/oauth2/authorize',
|
9
|
+
:token_url => 'https://www.cobot.me/oauth2/access_token'
|
10
|
+
}
|
11
|
+
|
12
|
+
uid { raw_info['id'] }
|
13
|
+
|
14
|
+
info do
|
15
|
+
{
|
16
|
+
'email' => raw_info['email'],
|
17
|
+
'picture' => raw_info['picture']
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
extra do
|
22
|
+
{:raw_info => raw_info}
|
23
|
+
end
|
24
|
+
|
25
|
+
def raw_info
|
26
|
+
access_token.options[:mode] = :query
|
27
|
+
@raw_info ||= access_token.get('/api/user').parsed
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
OmniAuth.config.add_camelization 'cobot', 'Cobot'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth/cobot/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth_cobot"
|
7
|
+
s.summary = "OmniAuth strategy for Cobot"
|
8
|
+
s.email = "alex@cobot.me"
|
9
|
+
s.homepage = "http://github.com/cobot/omniauth_cobot"
|
10
|
+
s.description = "OmniAuth strategy for Cobot"
|
11
|
+
s.authors = ["Alexander Lang"]
|
12
|
+
s.version = OmniAuth::Cobot::VERSION
|
13
|
+
s.platform = Gem::Platform::RUBY
|
14
|
+
|
15
|
+
s.add_dependency 'omniauth-oauth2'
|
16
|
+
|
17
|
+
s.add_development_dependency 'rake'
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
# s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
# s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth_cobot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alexander Lang
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: OmniAuth strategy for Cobot
|
47
|
+
email: alex@cobot.me
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- .gitignore
|
53
|
+
- Gemfile
|
54
|
+
- Gemfile.lock
|
55
|
+
- MIT_LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/omniauth/cobot/version.rb
|
59
|
+
- lib/omniauth/strategies/cobot.rb
|
60
|
+
- lib/omniauth_cobot.rb
|
61
|
+
- omniauth_cobot.gemspec
|
62
|
+
homepage: http://github.com/cobot/omniauth_cobot
|
63
|
+
licenses: []
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.24
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: OmniAuth strategy for Cobot
|
86
|
+
test_files: []
|