omniauth-squiddio 0.0.1
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/Gemfile +3 -0
- data/README.md +42 -0
- data/Rakefile +8 -0
- data/lib/omniauth-squiddio.rb +2 -0
- data/lib/omniauth-squiddio/version.rb +5 -0
- data/lib/omniauth/strategies/squiddio.rb +49 -0
- data/omniauth-squiddio.gemspec +20 -0
- data/spec/omniauth/strategies/buffer_spec.rb +25 -0
- data/spec/spec_helper.rb +7 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5152b6ad90f9ec16ede6ab18f7531241f61c3b0
|
4
|
+
data.tar.gz: 63c5dc3b8843d38c93009b2c35e0477e776f1248
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 65fa47bb8e7c6434d17b84b176165df34b69030f025182cb88ca50593ea387d114a285d1038da8089cb2bacdd1f66ded4a290969bbae1a59e8e2c2ff42050aa3
|
7
|
+
data.tar.gz: cf37ab2b9208dc2e0ed6488d339a86da45eac3cee2072dc3ba3bbe9716e21e1a5a7740746719cf68b8ff2b6bdc19548638659efb5c6fe5c051a68f24495e71c5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
OmniAuth sQuiddio
|
2
|
+
================
|
3
|
+
Work in Progress
|
4
|
+
|
5
|
+
This gem is an OmniAuth Strategy for the [Squiddio API](https://github.com/mauroc/signalk-oauth-node/blob/master/API.md) which uses OAuth 2.0
|
6
|
+
|
7
|
+
Usage
|
8
|
+
-----
|
9
|
+
|
10
|
+
Add the strategy to your `Gemfile` alongside OmniAuth:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'omniauth'
|
14
|
+
gem 'omniauth-squiddio'
|
15
|
+
```
|
16
|
+
|
17
|
+
Then, to integrate the strategy into your middleware, add this to your omniauth.rb settings file:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
use OmniAuth::Builder do
|
21
|
+
provider :squiddio, ENV['SQUIDDIO_KEY'], ENV['SQUIDDIO_SECRET']
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
In Rails, you'll want to add to the middleware stack:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
29
|
+
provider :squiddio, ENV['SQUIDDIO_KEY'], ENV['SQUIDDIO_SECRET']
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
If you use Devise:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Devise.setup do |config|
|
37
|
+
config.omniauth :squiddio, ENV['SQUIDDIO_KEY'], ENV['SQUIDDIO__SECRET']
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
|
42
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Squiddio < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
option :name, "squiddio"
|
8
|
+
|
9
|
+
|
10
|
+
option :client_options, {
|
11
|
+
:site => "https://squidd.io" ,
|
12
|
+
:authorize_path => "/oauth/authorize",
|
13
|
+
:token_path => "/oauth/token"
|
14
|
+
#:access_token_path => "/oauth/token"
|
15
|
+
}
|
16
|
+
|
17
|
+
uid { raw_info["id"] }
|
18
|
+
|
19
|
+
info do
|
20
|
+
{
|
21
|
+
:email => raw_info["email"],
|
22
|
+
:first_name => raw_info["firstName"],
|
23
|
+
:last_name => raw_info["lastName"],
|
24
|
+
:boat => {
|
25
|
+
:id => raw_info["boat"]["id"],
|
26
|
+
:name => raw_info["boat"]["name"],
|
27
|
+
:mmsi => raw_info["boat"]["mmsi"]
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def raw_info
|
33
|
+
access_token.options[:mode] = :query
|
34
|
+
@raw_info ||= access_token.get('/signalk/api/v1/users/me').parsed
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_access_token
|
38
|
+
Rails.logger.debug "Omniauth build access token"
|
39
|
+
options.token_params.merge!(:headers => {'Authorization' => basic_auth_header, 'Content-Type' => 'application/x-www-form-urlencoded' })
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def basic_auth_header
|
44
|
+
"Basic " + Base64.strict_encode64("#{options[:client_id]}:#{options[:client_secret]}")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-squiddio/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "omniauth-squiddio"
|
6
|
+
gem.version = OmniAuth::Squiddio::VERSION
|
7
|
+
gem.authors = ["Mauro Calvi"]
|
8
|
+
gem.email = ["coupdemistral@gmail.com"]
|
9
|
+
gem.homepage = "https://github.com/mauroc/omniauth-squiddio"
|
10
|
+
gem.description = %q{OmniAuth strategy for squidd.io}
|
11
|
+
gem.summary = %q{OmniAuth strategy for squidd.io}
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
|
18
|
+
gem.add_dependency 'omniauth-oauth', '~> 1.1'
|
19
|
+
#gem.add_dependency 'box-api'
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Squiddio do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::Squiddio.new({})
|
6
|
+
end
|
7
|
+
|
8
|
+
context "client options" do
|
9
|
+
it 'should have correct name' do
|
10
|
+
subject.options.name.should eq("squiddio")
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have correct site' do
|
14
|
+
subject.options.client_options.site.should eq('http://squidd.io')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have correct authorize url' do
|
18
|
+
subject.options.client_options.authorize_url.should eq('https://squidd.io/oauth/authorize')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct token url' do
|
22
|
+
subject.options.client_options.token_url.should eq('https://squidd.io/oauth/token')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-squiddio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mauro Calvi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
description: OmniAuth strategy for squidd.io
|
28
|
+
email:
|
29
|
+
- coupdemistral@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/omniauth-squiddio.rb
|
39
|
+
- lib/omniauth-squiddio/version.rb
|
40
|
+
- lib/omniauth/strategies/squiddio.rb
|
41
|
+
- omniauth-squiddio.gemspec
|
42
|
+
- spec/omniauth/strategies/buffer_spec.rb
|
43
|
+
- spec/spec_helper.rb
|
44
|
+
homepage: https://github.com/mauroc/omniauth-squiddio
|
45
|
+
licenses: []
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.4.6
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: OmniAuth strategy for squidd.io
|
67
|
+
test_files: []
|