omniauth-miicard 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.
@@ -0,0 +1,4 @@
1
+ require "omniauth-miicard/version"
2
+ require "omniauth/strategies/miicard"
3
+
4
+ OmniAuth.config.add_camelization('miicard', 'MiiCard')
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module MiiCard
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,59 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class MiiCard < OmniAuth::Strategies::OAuth
7
+ option :name, 'MiiCard'
8
+
9
+ option :client_options, {
10
+ :access_token_path => "/auth/oauth.ashx",
11
+ :authorize_path => "/auth/oauth.ashx",
12
+ :request_token_path => "/auth/oauth.ashx",
13
+ :site => "https://sts.miicard.com",
14
+ :http_method => :get
15
+ }
16
+
17
+ uid {
18
+ raw_info['Username']
19
+ }
20
+
21
+ info do
22
+ {
23
+ :name => user_info[:name],
24
+ :first_name => user_info[:first_name],
25
+ :last_name => user_info[:last_name],
26
+ :email => user_info[:email],
27
+ :phone => user_info[:phone],
28
+ :urls => user_info[:urls]
29
+ }
30
+ end
31
+
32
+ extra do
33
+ {
34
+ :raw_info => raw_info,
35
+ :user_hash => raw_info
36
+ }
37
+ end
38
+
39
+ def raw_info
40
+ @raw_info ||= (MultiJson.decode(access_token.post('/api/v1/Claims.svc/json/GetClaims').body)['Data']) if access_token
41
+ rescue ::Errno::ETIMEDOUT
42
+ raise ::Timeout::Error
43
+ end
44
+
45
+ def user_info
46
+ @user_info ||= raw_info.nil? ? {} :
47
+ {
48
+ :name => raw_info['FirstName'] + " " + raw_info['LastName'],
49
+ :name_public => raw_info['FirstName'] + " " + raw_info['LastName'],
50
+ :first_name => raw_info['FirstName'],
51
+ :last_name => raw_info['LastName'],
52
+ :phone => (raw_info['PhoneNumbers'].nil? || raw_info['PhoneNumbers'].empty?) ? nil : '+' + raw_info['PhoneNumbers'][0]['CountryCode'] + raw_info['PhoneNumbers'][0]['NationalNumber'],
53
+ :email => (raw_info['EmailAddresses'].nil? || raw_info['EmailAddresses'].empty?) ? nil : raw_info['EmailAddresses'][0]['Address'],
54
+ :urls => !raw_info['HasPublicProfile'] ? nil : { "Identity assured by miiCard" => raw_info['ProfileUrl'] }
55
+ }
56
+ end
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-miicard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Paul O'Neill
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ description: OmniAuth strategy for miiCard
31
+ email:
32
+ - info@miicard.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/omniauth-miicard.rb
38
+ - lib/omniauth/strategies/miicard.rb
39
+ - lib/omniauth-miicard/version.rb
40
+ homepage: https://github.com/miicard/modules-ruby-omniauth
41
+ licenses: []
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project: omniauth-miicard
60
+ rubygems_version: 1.8.24
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: OmniAuth strategy for miiCard
64
+ test_files: []