omniauth-authic 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-authic.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,2 @@
1
+ require 'omniauth-authic/version'
2
+ require 'omniauth/strategies/authic'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Authic
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ require 'omniauth-oauth2'
2
+ require 'active_support/core_ext/string'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Authic < OmniAuth::Strategies::OAuth2
7
+
8
+ option :name, "authic"
9
+ option :scope, "email"
10
+ option :subdomain, "" # Comes in from config
11
+ option :domain, "authic.com"
12
+
13
+ uid{ raw_info['id'] }
14
+
15
+ info do
16
+ {
17
+ :name => raw_info['name'],
18
+ :email => raw_info['email']
19
+ }
20
+ end
21
+
22
+ extra do
23
+ {
24
+ 'raw_info' => raw_info
25
+ }
26
+ end
27
+
28
+ def client
29
+ raise "You must specify your Authic subdomain in setup i.e. :subdomain => 'mysubdomain'" if options[:subdomain].blank?
30
+ # Make sure we set the site correctly before creating a client
31
+ options[:client_options][:site] = "http://#{options[:subdomain]}.#{options[:domain]}"
32
+ super
33
+ end
34
+
35
+ def raw_info
36
+ @raw_info ||= access_token.get("/authic_user_info.json").parsed
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-authic/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-authic"
7
+ s.version = Omniauth::Authic::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Authic"]
10
+ s.email = ["support@authic.com"]
11
+ s.homepage = "https://github.com/authic/omniauth-authic"
12
+ s.summary = %q{Omniauth plugin for the Authic service}
13
+ s.description = %q{An Omniauth strategy to integrate your application with Authic}
14
+
15
+ s.rubyforge_project = "omniauth-authic"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency 'omniauth-oauth2', '>= 1.0.2'
23
+ s.add_development_dependency 'minitest'
24
+ s.add_development_dependency 'mocha'
25
+ end
@@ -0,0 +1,64 @@
1
+ require 'omniauth-authic'
2
+ require 'minitest/autorun'
3
+ require 'mocha'
4
+
5
+ class TestMeme < MiniTest::Unit::TestCase
6
+ def setup
7
+
8
+ @client_id = '1234567890'
9
+ @client_secret = 'qwertyuiop'
10
+ @subdomain = 'dev-subdomain'
11
+ @domain = "authic.com"
12
+ @options = {:subdomain => @subdomain}
13
+ @uid = 'lkjhgfdsa'
14
+ @name = "Johnny Rotten"
15
+ @email = "jrotten@email.com"
16
+ @raw_info = {'id' => @uid, 'name' => @name, 'email' => @email}
17
+
18
+ @request = stub('Request')
19
+ @request.stubs(:params).returns({})
20
+ @request.stubs(:cookies).returns({})
21
+ @request.stubs(:env).returns({})
22
+
23
+ args = [@client_id, @client_secret, @options].compact
24
+ @strategy = OmniAuth::Strategies::Authic.new(nil, *args)
25
+ @strategy.stubs(:request).returns(@request)
26
+ @strategy.stubs(:raw_info).returns(@raw_info)
27
+
28
+ end
29
+
30
+ def test_that_subdomain_is_passed_in
31
+ assert_equal @subdomain, @strategy.options[:subdomain]
32
+ end
33
+
34
+ def test_that_subdomain_is_passed_in
35
+ assert_raises RuntimeError do
36
+ @strategy.options[:subdomain] = ""
37
+ @strategy.client
38
+ end
39
+ end
40
+
41
+ def test_that_client_site_url_is_correct
42
+ client = @strategy.client
43
+ test_uri = URI.parse "http://#{@subdomain}.#{@domain}"
44
+ actual_uri = URI.parse @strategy.options[:client_options][:site]
45
+ assert_equal test_uri.host, actual_uri.host
46
+ end
47
+
48
+ def test_that_uid_is_returned
49
+ assert_equal @uid, @strategy.uid
50
+ end
51
+
52
+ def test_that_extra_data_is_returned
53
+ assert_equal @raw_info, @strategy.extra['raw_info']
54
+ end
55
+
56
+ def test_that_info_name_is_returned
57
+ assert_equal @name, @strategy.info[:name]
58
+ end
59
+
60
+ def test_that_info_email_is_returned
61
+ assert_equal @email, @strategy.info[:email]
62
+ end
63
+
64
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-authic
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Authic
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-10-21 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: omniauth-oauth2
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.2
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: minitest
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: mocha
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id003
48
+ description: An Omniauth strategy to integrate your application with Authic
49
+ email:
50
+ - support@authic.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - .gitignore
59
+ - Gemfile
60
+ - Rakefile
61
+ - lib/omniauth-authic.rb
62
+ - lib/omniauth-authic/version.rb
63
+ - lib/omniauth/strategies/authic.rb
64
+ - omniauth-authic.gemspec
65
+ - test/omniauth-authic/test.rb
66
+ homepage: https://github.com/authic/omniauth-authic
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0"
86
+ requirements: []
87
+
88
+ rubyforge_project: omniauth-authic
89
+ rubygems_version: 1.8.24
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Omniauth plugin for the Authic service
93
+ test_files:
94
+ - test/omniauth-authic/test.rb