omniauth-crozdesk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +9 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +83 -0
- data/lib/omniauth-crozdesk.rb +1 -0
- data/lib/omniauth/crozdesk.rb +2 -0
- data/lib/omniauth/crozdesk/version.rb +5 -0
- data/lib/omniauth/strategies/crozdesk.rb +31 -0
- data/omniauth-crozdesk.gemspec +23 -0
- data/spec/omniauth/strategies/crozdesk_spec.rb +19 -0
- data/spec/spec_helper.rb +18 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bc5167cf3dbdad03bae26d10ca6b2613abf11046
|
4
|
+
data.tar.gz: c7c5e0c6d2daaa908e9273bf6e830a24ce62caba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72fd042aaa6546e2cb407319971c2da925c8562e8dfcbe481a760b1e994ba0b856c20b36a01b6a25a1f8f16a5511135be5182a0247945691f089318203d20eb2
|
7
|
+
data.tar.gz: 63b6fe2a464e75ad93dac1584747dc46a13aa8c9a831c17c53706cce4fd7a0532fe3b3e05c74f0edb71938b1407f4d244ce3973017b7444efc4900c92dec2565
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Crozdesk Ltd
|
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.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# OmniAuth Crozdesk
|
2
|
+
|
3
|
+
Adds an OmniAuth strategy for <a href="https://crozdesk.com">Crozdesk</a>.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's `Gemfile`:
|
8
|
+
```ruby
|
9
|
+
gem 'omniauth-crozdesk'
|
10
|
+
```
|
11
|
+
|
12
|
+
Then run `bundle install`.
|
13
|
+
|
14
|
+
Alternatively you can install it using `gem install omniauth-crozdesk`
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
This gem provides the `OmniAuth::Strategies::Crozdesk` rack middleware that integrates with OmniAuth, for more details read the docs at https://github.com/intridea/omniauth.
|
19
|
+
|
20
|
+
Here's a quick example of how to active the strategy in a rails app, add the following lines to `config/initializers/omniauth.rb`:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
24
|
+
provider :crozdesk, ENV['CROZDESK_KEY'], ENV['CROZDESK_SECRET']
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
For a full example, check out the sample apps below:
|
29
|
+
[Sinatra](https://github.com/crozdesk/sinatra-oauth2-example)
|
30
|
+
[Rails](https://github.com/crozdesk/rails-oauth2-example)
|
31
|
+
|
32
|
+
## Auth Hash
|
33
|
+
|
34
|
+
The following is an example "auth hash" returned via `request.env['omniauth.auth']`:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
{
|
38
|
+
provider: 'crozdesk',
|
39
|
+
uid: '1234567',
|
40
|
+
info: {
|
41
|
+
first_name: 'John',
|
42
|
+
last_name: 'Doe',
|
43
|
+
name: 'John Doe',
|
44
|
+
email: 'john@doe.com'
|
45
|
+
},
|
46
|
+
credentials: {
|
47
|
+
... # OAuth2 token value and expiry status
|
48
|
+
},
|
49
|
+
extra: {
|
50
|
+
raw_info: {
|
51
|
+
id: '1234567',
|
52
|
+
first_name: 'John',
|
53
|
+
last_name: 'Doe',
|
54
|
+
name: 'John Doe',
|
55
|
+
email: 'john@doe.com'
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
```
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The MIT License (MIT)
|
64
|
+
|
65
|
+
Copyright (c) 2015 Crozdesk Ltd
|
66
|
+
|
67
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
68
|
+
of this software and associated documentation files (the "Software"), to deal
|
69
|
+
in the Software without restriction, including without limitation the rights
|
70
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
71
|
+
copies of the Software, and to permit persons to whom the Software is
|
72
|
+
furnished to do so, subject to the following conditions:
|
73
|
+
|
74
|
+
The above copyright notice and this permission notice shall be included in all
|
75
|
+
copies or substantial portions of the Software.
|
76
|
+
|
77
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
78
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
79
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
80
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
81
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
82
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
83
|
+
SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/crozdesk'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Crozdesk < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, :crozdesk
|
7
|
+
|
8
|
+
option :client_options, {
|
9
|
+
site: "https://crozdesk.com",
|
10
|
+
authorize_path: "/oauth/authorize"
|
11
|
+
}
|
12
|
+
|
13
|
+
uid do
|
14
|
+
raw_info["id"]
|
15
|
+
end
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
name: raw_info["name"],
|
20
|
+
email: raw_info["email"],
|
21
|
+
first_name: raw_info["first_name"],
|
22
|
+
last_name: raw_info["last_name"],
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def raw_info
|
27
|
+
@raw_info ||= access_token.get('/api/v1/users/me').parsed['user'] || {}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth/crozdesk/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'omniauth-crozdesk'
|
7
|
+
s.version = OmniAuth::Crozdesk::VERSION
|
8
|
+
s.authors = ['Alexandru Stoian']
|
9
|
+
s.email = ['alex@crozdesk.com']
|
10
|
+
s.summary = 'Crozdesk OAuth2 Strategy for OmniAuth'
|
11
|
+
s.homepage = 'https://github.com/crozdesk/omniauth-crozdesk'
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
|
20
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
21
|
+
s.add_development_dependency 'webmock', '~> 1.21'
|
22
|
+
s.add_development_dependency 'rack-test', '~> 0.6'
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Crozdesk do
|
4
|
+
subject { described_class.new({}) }
|
5
|
+
|
6
|
+
context "client connection" do
|
7
|
+
it "should have the correct name" do
|
8
|
+
expect(subject.options.name).to eq(:crozdesk)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should use the correct site" do
|
12
|
+
expect(subject.options.client_options.site).to eq("https://crozdesk.com")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should use the correct authorize url" do
|
16
|
+
expect(subject.options.client_options.authorize_path).to eq("/oauth/authorize")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rack/test'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
require 'omniauth'
|
4
|
+
require 'omniauth-crozdesk'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.include WebMock::API
|
8
|
+
config.include Rack::Test::Methods
|
9
|
+
config.extend OmniAuth::Test::StrategyMacros, type: :strategy
|
10
|
+
|
11
|
+
config.expect_with :rspec do |expectations|
|
12
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
13
|
+
end
|
14
|
+
|
15
|
+
config.mock_with :rspec do |mocks|
|
16
|
+
mocks.verify_partial_doubles = true
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-crozdesk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexandru Stoian
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-14 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: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.21'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.21'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-test
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.6'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- alex@crozdesk.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- lib/omniauth-crozdesk.rb
|
82
|
+
- lib/omniauth/crozdesk.rb
|
83
|
+
- lib/omniauth/crozdesk/version.rb
|
84
|
+
- lib/omniauth/strategies/crozdesk.rb
|
85
|
+
- omniauth-crozdesk.gemspec
|
86
|
+
- spec/omniauth/strategies/crozdesk_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
homepage: https://github.com/crozdesk/omniauth-crozdesk
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.6
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Crozdesk OAuth2 Strategy for OmniAuth
|
112
|
+
test_files:
|
113
|
+
- spec/omniauth/strategies/crozdesk_spec.rb
|
114
|
+
- spec/spec_helper.rb
|