prooflink_connect 0.0.2
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 +3 -0
- data/Gemfile +4 -0
- data/README.md +16 -0
- data/Rakefile +2 -0
- data/lib/prooflink_connect/assertion.rb +43 -0
- data/lib/prooflink_connect/configuration.rb +17 -0
- data/lib/prooflink_connect/portable_contacts/collection.rb +10 -0
- data/lib/prooflink_connect/portable_contacts/person.rb +64 -0
- data/lib/prooflink_connect/portable_contacts.rb +5 -0
- data/lib/prooflink_connect/version.rb +3 -0
- data/lib/prooflink_connect.rb +18 -0
- data/prooflink_connect.gemspec +22 -0
- metadata +95 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Prooflink Connect
|
2
|
+
=================
|
3
|
+
|
4
|
+
Library to connect to the prooflink identity service provider
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
* Add gem 'prooflink_connect' to your Gemfile
|
10
|
+
* run 'bundle install'
|
11
|
+
|
12
|
+
Usage
|
13
|
+
-----
|
14
|
+
|
15
|
+
To make use of this gem you need an account on prooflink with an api key
|
16
|
+
Adjust the prooflink configuration settings in your environment.rb:
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module ProoflinkConnect
|
2
|
+
class Assertion
|
3
|
+
attr_accessor :token
|
4
|
+
|
5
|
+
def initialize(token)
|
6
|
+
@token = token
|
7
|
+
end
|
8
|
+
|
9
|
+
def auth_info
|
10
|
+
url = URI.parse("#{ProoflinkConnect.config.protocol}://#{[ProoflinkConnect.config.subdomain, ProoflinkConnect.config.provider_endpoint].compact.join(".")}/client_assertions/auth_info/")
|
11
|
+
# query = partial_query.dup
|
12
|
+
query = {}
|
13
|
+
query['format'] = 'json'
|
14
|
+
query['token'] = @token
|
15
|
+
query['api_key'] = ProoflinkConnect.config.api_key
|
16
|
+
|
17
|
+
http = Net::HTTP.new(url.host, url.port)
|
18
|
+
|
19
|
+
if url.scheme == 'https'
|
20
|
+
http.use_ssl = true
|
21
|
+
end
|
22
|
+
data = query.map { |k,v|
|
23
|
+
"#{CGI::escape k.to_s}=#{CGI::escape v.to_s}"
|
24
|
+
}.join('&')
|
25
|
+
|
26
|
+
resp = http.post(url.path, data)
|
27
|
+
if resp.code == '200'
|
28
|
+
begin
|
29
|
+
data = JSON.parse(resp.body)
|
30
|
+
return PortableContacts::Person.new(data['entry'])
|
31
|
+
rescue JSON::ParserError => err
|
32
|
+
raise AuthinfoException.new(resp), 'Unable to parse JSON response' + resp.body.inspect
|
33
|
+
end
|
34
|
+
else
|
35
|
+
raise AuthinfoException, "Unexpected HTTP status code from server: #{resp.code}"
|
36
|
+
end
|
37
|
+
# PortableContacts::Person.new(data['entry'])
|
38
|
+
end
|
39
|
+
|
40
|
+
class AuthinfoException < ::StandardError
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ProoflinkConnect
|
2
|
+
class Configuration
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
@@defaults = {
|
6
|
+
:provider_endpoint => "prooflink.local",
|
7
|
+
:subdomain => "example",
|
8
|
+
:protocol => "https"
|
9
|
+
}
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@@defaults.each_pair{|k,v| self.send("#{k}=",v)}
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :provider_endpoint, :subdomain, :api_key, :protocol
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Collection < Array
|
2
|
+
attr_reader :total_entries, :per_page, :start_index
|
3
|
+
|
4
|
+
def initialize(data)
|
5
|
+
super data["entry"].collect{|e| PortableContacts::Person.new(e) }
|
6
|
+
@total_entries=data["totalResults"].to_i
|
7
|
+
@per_page=data["itemsPerPage"].to_i
|
8
|
+
@start_index=data["startIndex"].to_i
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module ProoflinkConnect::PortableContacts
|
2
|
+
class Person
|
3
|
+
|
4
|
+
# Encapsulates a person. Each of the portable contact and opensocial contact fields has a rubyfied (underscored) accessor method.
|
5
|
+
#
|
6
|
+
# @person = @person.display_name
|
7
|
+
#
|
8
|
+
|
9
|
+
def initialize(data={})
|
10
|
+
@data=data
|
11
|
+
end
|
12
|
+
|
13
|
+
SINGULAR_FIELDS = [
|
14
|
+
# Portable contacts singular fields
|
15
|
+
:id, :display_name, :name, :nickname, :published, :updated, :birthday, :anniversary,
|
16
|
+
:gender, :note, :preferred_username, :utc_offset, :connected,
|
17
|
+
|
18
|
+
# OpenSocial singular fields
|
19
|
+
:about_me, :body_type, :current_location, :drinker, :ethnicity, :fashion, :happiest_when,
|
20
|
+
:humor, :living_arrangement, :looking_for, :profile_song, :profile_video, :relationship_status,
|
21
|
+
:religion, :romance, :scared_of, :sexual_orientation, :smoker, :status
|
22
|
+
]
|
23
|
+
PLURAL_FIELDS = [
|
24
|
+
# Portable contacts plural fields
|
25
|
+
:emails, :urls, :phone_numbers, :ims, :photos, :tags, :relationships, :addresses,
|
26
|
+
:organizations, :accounts,
|
27
|
+
|
28
|
+
# OpenSocial plural fields
|
29
|
+
:activities, :books, :cars, :children, :food, :heroes, :interests, :job_interests,
|
30
|
+
:languages, :languages_spoken, :movies, :music, :pets, :political_views, :quotes,
|
31
|
+
:sports, :turn_offs, :turn_ons, :tv_shows
|
32
|
+
]
|
33
|
+
|
34
|
+
ENTRY_FIELDS = SINGULAR_FIELDS + PLURAL_FIELDS
|
35
|
+
|
36
|
+
def [](key)
|
37
|
+
@data[key.to_s.camelize(:lower)]
|
38
|
+
end
|
39
|
+
|
40
|
+
# primary email address
|
41
|
+
def email
|
42
|
+
@email||= begin
|
43
|
+
(emails.detect {|e| e['primary']=='true '} || emails.first)["value"] unless emails.empty?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def id
|
48
|
+
self["id"]
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
def method_missing(method,*args)
|
54
|
+
if respond_to?(method)
|
55
|
+
return self[method]
|
56
|
+
end
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def respond_to?(method)
|
61
|
+
ENTRY_FIELDS.include?(method) || @data.has_key?(method.to_s.camelize(:lower)) || super
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ProoflinkConnect
|
2
|
+
autoload :Configuration, "prooflink_connect/configuration"
|
3
|
+
autoload :Assertion, "prooflink_connect/assertion"
|
4
|
+
autoload :PortableContacts, "prooflink_connect/portable_contacts"
|
5
|
+
|
6
|
+
def self.config
|
7
|
+
Configuration.instance
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configure
|
11
|
+
yield config
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.embedded(options = {})
|
15
|
+
options = {:subdomain => ProoflinkConnect.config.subdomain, :token_url => 'https://example.com/auth/callbacks'}.merge(options)
|
16
|
+
"<iframe src='#{ProoflinkConnect.config.protocol}://#{[options[:subdomain], ProoflinkConnect.config.provider_endpoint].compact.join(".")}/authentications/embedded?token_url=#{options[:token_url]}' style='width: 500px; height: 220px; border: 0;display: block' ></iframe>".html_safe
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/prooflink_connect/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "prooflink_connect"
|
6
|
+
s.version = ProoflinkConnect::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Chiel Wester"]
|
9
|
+
s.email = "chiel.wester@holder.nl"
|
10
|
+
s.homepage = "https://github.com/chielwester/prooflink_connect"
|
11
|
+
s.summary = "Make a connection to the prooflink connect api"
|
12
|
+
s.description = "Make a connection to the prooflink connect api for single sign on authentication"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "prooflink_connect"
|
16
|
+
|
17
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
21
|
+
s.require_path = 'lib'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prooflink_connect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Chiel Wester
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-17 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bundler
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 1.0.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Make a connection to the prooflink connect api for single sign on authentication
|
38
|
+
email: chiel.wester@holder.nl
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- Gemfile
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- lib/prooflink_connect.rb
|
51
|
+
- lib/prooflink_connect/assertion.rb
|
52
|
+
- lib/prooflink_connect/configuration.rb
|
53
|
+
- lib/prooflink_connect/portable_contacts.rb
|
54
|
+
- lib/prooflink_connect/portable_contacts/collection.rb
|
55
|
+
- lib/prooflink_connect/portable_contacts/person.rb
|
56
|
+
- lib/prooflink_connect/version.rb
|
57
|
+
- prooflink_connect.gemspec
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: https://github.com/chielwester/prooflink_connect
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 23
|
82
|
+
segments:
|
83
|
+
- 1
|
84
|
+
- 3
|
85
|
+
- 6
|
86
|
+
version: 1.3.6
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: prooflink_connect
|
90
|
+
rubygems_version: 1.4.1
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Make a connection to the prooflink connect api
|
94
|
+
test_files: []
|
95
|
+
|