omniauth-socialstream 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ *.gem
2
+ .bundle
3
+ .config
4
+ .yardoc
5
+ Gemfile.lock
6
+ coverage
7
+ doc/
8
+ /pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-social_stream.gemspec
4
+ gemspec
@@ -0,0 +1,26 @@
1
+ # OmniAuth Social Stream
2
+
3
+ This is the official OmniAuth strategy for authenticating to a Social Stream node
4
+ that includes the [Social Stream OAuth2 Server gem](https://github.com/ging/social_stream/oauth2_server). To use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
+ on the Social Stream node. There is an example in [Social Stream's demo site](http://demo-social-stream.dit.upm.es).
6
+
7
+ ## Usage
8
+
9
+ provider :socialstream, ENV['SS_KEY'], ENV['SS_SECRET'],
10
+ {
11
+ :client_options => {
12
+ :site => 'https://demo-social-stream.dit.upm.es/api',
13
+ :authorize_url => 'https://demo-social-stream.dit.upm.es/login/oauth/authorize',
14
+ :token_url => 'https://demo-social-stream.dit.upm.es/login/oauth/access_token',
15
+ }
16
+ }
17
+
18
+ ## License
19
+
20
+ Copyright (c) 2013 Universidad Politécnica de Madrid
21
+
22
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth/socialstream/version"
2
+ require 'omniauth/strategies/socialstream'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Socialstream
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Socialstream < OmniAuth::Strategies::OAuth2
6
+ option :name, 'socialstream'
7
+
8
+ option :client_options, {
9
+ :site => 'https://demo-social-stream.dit.upm.es',
10
+ :authorize_url => 'https://demo-social-stream.dit.upm.es/oauth2/authorize',
11
+ :token_url => 'https://demo-social-stream.dit.upm.es/oauth2/token'
12
+ }
13
+
14
+ uid { raw_info['id'].to_s }
15
+
16
+ info do
17
+ {
18
+ 'nickname' => raw_info['slug'],
19
+ 'email' => raw_info['email'],
20
+ 'name' => raw_info['name'],
21
+ 'image' => raw_info['avatar_url'],
22
+ }
23
+ end
24
+
25
+ extra do
26
+ {:raw_info => raw_info}
27
+ end
28
+
29
+ def raw_info
30
+ access_token.options[:mode] = :query
31
+ @raw_info ||= access_token.get('user').parsed
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth/socialstream/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = [ "Antonio Tapiador",
6
+ "GING - DIT - UPM" ]
7
+ gem.email = [ "social-stream@dit.upm.es"]
8
+ gem.description = "Official OmniAuth strategy for Social Stream."
9
+ gem.summary = "Social Stream is a Ruby on Rails engine for building social network websites. This is the official OmniAuth strategy for Social Stream's Oauth2 Server."
10
+ gem.homepage = "https://github.com/ging/omniauth-socialstream"
11
+
12
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ gem.name = "omniauth-socialstream"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = OmniAuth::Socialstream::VERSION
18
+
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1.1'
20
+
21
+ gem.add_development_dependency 'rspec', '~> 2.7'
22
+ gem.add_development_dependency 'rake'
23
+ gem.add_development_dependency 'rack-test'
24
+ gem.add_development_dependency 'simplecov'
25
+ gem.add_development_dependency 'webmock'
26
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Socialstream do
4
+ let(:access_token) { stub('AccessToken', :options => {}) }
5
+ let(:parsed_response) { stub('ParsedResponse') }
6
+ let(:response) { stub('Response', :parsed => parsed_response) }
7
+
8
+ let(:other_site) { 'https://some.other.site.com' }
9
+ let(:other_authorize_url) { 'https://some.other.site.com/login/oauth/authorize' }
10
+ let(:other_token_url) { 'https://some.other.site.com/login/oauth/access_token' }
11
+ let(:other) do
12
+ OmniAuth::Strategies::Socialstream.new('SS_KEY', 'SS_SECRET',
13
+ {
14
+ :client_options => {
15
+ :site => other_site,
16
+ :authorize_url => other_authorize_url,
17
+ :token_url => other_token_url
18
+ }
19
+ }
20
+ )
21
+ end
22
+
23
+ subject do
24
+ OmniAuth::Strategies::Socialstream.new({})
25
+ end
26
+
27
+ before(:each) do
28
+ subject.stub!(:access_token).and_return(access_token)
29
+ end
30
+
31
+ context "client options" do
32
+ it 'should have correct site' do
33
+ subject.options.client_options.site.should eq("https://demo-social-stream.dit.upm.es")
34
+ end
35
+
36
+ it 'should have correct authorize url' do
37
+ subject.options.client_options.authorize_url.should eq('https://demo-social-stream.dit.upm.es/oauth2/authorize')
38
+ end
39
+
40
+ it 'should have correct token url' do
41
+ subject.options.client_options.token_url.should eq('https://demo-social-stream.dit.upm.es/oauth2/token')
42
+ end
43
+
44
+ describe "should be overrideable" do
45
+ it "for site" do
46
+ other.options.client_options.site.should eq(other_site)
47
+ end
48
+
49
+ it "for authorize url" do
50
+ other.options.client_options.authorize_url.should eq(other_authorize_url)
51
+ end
52
+
53
+ it "for token url" do
54
+ other.options.client_options.token_url.should eq(other_token_url)
55
+ end
56
+ end
57
+ end
58
+
59
+ context "#raw_info" do
60
+ it "should use relative paths" do
61
+ access_token.should_receive(:get).with('user').and_return(response)
62
+ subject.raw_info.should eq(parsed_response)
63
+ end
64
+ end
65
+ 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-socialstream'
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,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-socialstream
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Antonio Tapiador
9
+ - GING - DIT - UPM
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-01-25 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: omniauth-oauth2
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 1.1.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 1.1.1
31
+ - !ruby/object:Gem::Dependency
32
+ name: rspec
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '2.7'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '2.7'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !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: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rack-test
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: simplecov
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: webmock
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Official OmniAuth strategy for Social Stream.
112
+ email:
113
+ - social-stream@dit.upm.es
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - .travis.yml
121
+ - Gemfile
122
+ - README.md
123
+ - Rakefile
124
+ - lib/omniauth-socialstream.rb
125
+ - lib/omniauth/socialstream/version.rb
126
+ - lib/omniauth/strategies/socialstream.rb
127
+ - omniauth-socialstream.gemspec
128
+ - spec/omniauth/strategies/socialstream_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/ging/omniauth-socialstream
131
+ licenses: []
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 1.8.24
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Social Stream is a Ruby on Rails engine for building social network websites.
154
+ This is the official OmniAuth strategy for Social Stream's Oauth2 Server.
155
+ test_files: []
156
+ has_rdoc: