omniauth-singly 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ coverage/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-singly.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # OmniAuth Singly
2
+
3
+ This is the official OmniAuth strategy for authenticating to Singly. To
4
+ use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
+ on the [Singly Applications Page](https://dev.singly.com/apps).
6
+
7
+ ## Basic Usage
8
+
9
+ ### Rails
10
+
11
+ Rails.application.config.middleware.use OmniAuth::Builder do
12
+ provider :singly, ENV['SINGLY_ID'], ENV['SINGLY_SECRET']
13
+ end
14
+
15
+ ### Sinatra
16
+
17
+ use OmniAuth::Builder do
18
+ provider :singly, ENV['SINGLY_ID'], ENV['SINGLY_SECRET']
19
+ end
20
+
21
+ ## Services
22
+
23
+ You can authorize many services through Singly. Link to
24
+
25
+ /auth/singly?service=<service>
26
+
27
+ where `service` is anything from the list at http://dev.singly.com/authorization
28
+
29
+ ## License
30
+
31
+ Copyright (c) 2011 Singly, Inc.
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
34
+ this software and associated documentation files (the "Software"), to deal in
35
+ the Software without restriction, including without limitation the rights to
36
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
37
+ the Software, and to permit persons to whom the Software is furnished to do so,
38
+ subject to the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be included in all
41
+ copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
45
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
46
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
47
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
10
+
11
+ desc 'Run specs'
12
+ task :default => :spec
@@ -0,0 +1,33 @@
1
+ require "omniauth-oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Singly < OmniAuth::Strategies::OAuth2
6
+ option :name, "singly"
7
+
8
+ option :client_options, {
9
+ :site => "https://api.singly.com",
10
+ :authorize_url => "https://api.singly.com/oauth/authorize",
11
+ :token_url => "https://api.singly.com/oauth/access_token"
12
+ }
13
+
14
+ def authorize_params
15
+ super.merge(:service => request.params["service"])
16
+ end
17
+
18
+ uid { raw_info["id"] }
19
+
20
+ extra do
21
+ { :raw_info => raw_info }
22
+ end
23
+
24
+ def raw_info
25
+ @raw_info ||= begin
26
+ access_token.options[:mode] = :query
27
+ access_token.options[:param_name] = :access_token
28
+ access_token.get("/profiles").parsed
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Singly
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-singly/version"
2
+ require "omniauth/strategies/singly"
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-singly/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-singly"
7
+ s.version = Omniauth::Singly::VERSION
8
+ s.authors = ["Kristján Pétursson"]
9
+ s.email = ["kristjan@singly.com"]
10
+ s.homepage = "https://github.com/Singly/omniauth-singly"
11
+ s.summary = %q{Official Singly strategy for OmniAuth}
12
+ s.description = %q{Official Singly strategy for OmniAuth}
13
+
14
+ s.rubyforge_project = "omniauth-singly"
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_dependency 'omniauth', '~> 1.0'
22
+ s.add_dependency 'omniauth-oauth2', '~> 1.0'
23
+ s.add_development_dependency 'rspec', '~> 2.7'
24
+ s.add_development_dependency 'rack-test'
25
+ s.add_development_dependency 'simplecov'
26
+ s.add_development_dependency 'webmock'
27
+ end
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe OmniAuth::Strategies::Singly do
4
+ subject do
5
+ OmniAuth::Strategies::Singly.new({})
6
+ end
7
+
8
+ context "client_options" do
9
+ it "uses the correct site" do
10
+ subject.options.client_options.site.
11
+ should == "https://api.singly.com"
12
+ end
13
+
14
+ it "uses the correct authorize_url" do
15
+ subject.options.client_options.authorize_url.
16
+ should == "https://api.singly.com/oauth/authorize"
17
+ end
18
+
19
+ it "uses the correct token_url" do
20
+ subject.options.client_options.token_url.
21
+ should == "https://api.singly.com/oauth/access_token"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-singly'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-singly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kristján Pétursson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-15 00:00:00.000000000 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: omniauth
17
+ requirement: &2153605180 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2153605180
26
+ - !ruby/object:Gem::Dependency
27
+ name: omniauth-oauth2
28
+ requirement: &2153604680 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *2153604680
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &2153604220 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: '2.7'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *2153604220
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack-test
50
+ requirement: &2153603840 !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: *2153603840
59
+ - !ruby/object:Gem::Dependency
60
+ name: simplecov
61
+ requirement: &2153603380 !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: *2153603380
70
+ - !ruby/object:Gem::Dependency
71
+ name: webmock
72
+ requirement: &2153602960 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *2153602960
81
+ description: Official Singly strategy for OmniAuth
82
+ email:
83
+ - kristjan@singly.com
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - .gitignore
89
+ - Gemfile
90
+ - README.md
91
+ - Rakefile
92
+ - lib/omniauth-singly.rb
93
+ - lib/omniauth-singly/version.rb
94
+ - lib/omniauth/strategies/singly.rb
95
+ - omniauth-singly.gemspec
96
+ - spec/omniauth/strategies/singly_spec.rb
97
+ - spec/spec_helper.rb
98
+ has_rdoc: true
99
+ homepage: https://github.com/Singly/omniauth-singly
100
+ licenses: []
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project: omniauth-singly
119
+ rubygems_version: 1.6.2
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Official Singly strategy for OmniAuth
123
+ test_files:
124
+ - spec/omniauth/strategies/singly_spec.rb
125
+ - spec/spec_helper.rb