Chrononaut-rpx_now 0.5.6

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
+ Manifest
2
+ pkg
3
+ .*.swp
4
+ .*.swo
data/CHANGELOG ADDED
@@ -0,0 +1,23 @@
1
+ 0.5.0
2
+ ----
3
+ * ApiError is raised when API KEY was invalid (before did only return nil)
4
+ * ServerError is now seperated into ApiError and ServiceUnavailableError
5
+
6
+ 0.4.2
7
+ ----
8
+ * default IDs are strings, not integers, since RPX supports both
9
+ * Added username field to standart parameters
10
+
11
+ 0.4
12
+ ----
13
+ * The RPXNow.api_version= can be set globally
14
+ * Most methods now support :api_version=>'123', so you can specify the api_version on each call
15
+ * Added support for unobtrusive code generation. This will make the gem play nicely with developers creating unobtrusive pages with frameworks such as jQuery;
16
+ * The RPXNOW JSON responses are now parsed by Florian Frank JSON gem (http://json.rubyforge.org/);
17
+ * Removed the dependency of ActiveSupport. However, if present, ActiveSupport will be used due to its convenience methods Array#to_query and Hash#to_query.
18
+ * Added support for multiple versions of the widget. By default, everything will point to version 2;
19
+ * The specs have been updated.
20
+
21
+ 0.3
22
+ ----
23
+ * RPXNow::ServerError will be thrown when something is invalid/goes wrong, so watch out (not for invalid tokens in user_data)...
data/MIGRATION ADDED
@@ -0,0 +1,9 @@
1
+ class AddIdentifierToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :identifier, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :users, :identifier
8
+ end
9
+ end
data/README.markdown ADDED
@@ -0,0 +1,107 @@
1
+ Problem
2
+ =======
3
+ - OpenID is complex, limited and hard to use for users
4
+ - Facebook / Twitter / Myspace / Google / MS-LiveId / AOL connections require different libraries and knowledge
5
+ - Multiple heterogenouse providers are hard to map to a single user
6
+
7
+ Solution
8
+ ========
9
+ - Use [RPX](http://rpxnow.com) for universal and usable user login
10
+ - Use view/controller helpers for easy integration
11
+
12
+ ![Single Interface for all providers](https://rpxnow.com/images/how_diagram.png)
13
+ ![Visitors choose from providers they already have](https://rpxnow.com/images/6providers.png?2)
14
+
15
+ Usage
16
+ =====
17
+ - Get an API key @ [RPX](http://rpxnow.com)
18
+ - run [MIGRATION](http://github.com/grosser/rpx_now/raw/master/MIGRATION)
19
+ - Build login view
20
+ - Communicate with RPX API in controller to create or login User
21
+ - for more advanced features have a look at the [RPX API Docs](https://rpxnow.com/docs)
22
+
23
+ Install
24
+ =======
25
+ - As Rails plugin: `script/plugin install git://github.com/grosser/rpx_now.git `
26
+ - As gem: `sudo gem install grosser-rpx_now --source http://gems.github.com/`
27
+
28
+ Examples
29
+ ========
30
+
31
+ View
32
+ ----
33
+ #'mywebsite' is your subdomain/realm on RPX
34
+ <%=RPXNow.embed_code('mywebsite',rpx_token_sessions_url)%>
35
+ OR
36
+ <%=RPXNow.popup_code('Login here...','mywebsite',rpx_token_sessions_url,:language=>'de')%>
37
+
38
+ `popup_code` can also be called with `:unobstrusive=>true`
39
+
40
+ Environment
41
+ -----------
42
+ Rails::Initializer.run do |config|
43
+ config.gem "grosser-rpx_now", :lib => "rpx_now", :source => "http://gems.github.com/"
44
+ ...
45
+ end
46
+ RPXNow.api_key = "YOU RPX API KEY"
47
+
48
+ Controller
49
+ ----------
50
+ # user_data
51
+ # found: {:name=>'John Doe', :username => 'john', :email=>'john@doe.com', :identifier=>'blug.google.com/openid/dsdfsdfs3f3'}
52
+ # not found: nil (can happen with e.g. invalid tokens)
53
+ def rpx_token
54
+ raise "hackers?" unless data = RPXNow.user_data(params[:token])
55
+ self.current_user = User.find_by_identifier(data[:identifier]) || User.create!(data)
56
+ redirect_to '/'
57
+ end
58
+
59
+ # raw request processing
60
+ RPXNow.user_data(params[:token]){|raw| {:email=>raw['profile']['verifiedEmail']} }
61
+
62
+ # raw request with extended parameters (most users and APIs do not supply them)
63
+ RPXNow.user_data(params[:token], :extended=>'true'){|raw| ...have a look at the RPX API DOCS...}
64
+
65
+ Advanced
66
+ --------
67
+ ###Versions
68
+ RPXNow.api_version = 2
69
+
70
+ ###Mappings
71
+ You can map your primary keys (e.g. user.id) to identifiers, so that
72
+ users can login to the same account with multiple identifiers.
73
+ RPXNow.map(identifier, primary_key) #add a mapping
74
+ RPXNow.unmap(identifier, primary_key) #remove a mapping
75
+ RPXNow.mappings(primary_key) # [identifier1,identifier2,...]
76
+ RPXNow.all_mappings # [["1",['google.com/dsdas','yahoo.com/asdas']], ["2",[...]], ... ]
77
+
78
+ After a primary key is mapped to an identifier, when a user logs in with this identifier,
79
+ `RPXNow.user_data` will contain his `primaryKey` as `:id`.
80
+ A identifyer can only belong to one user (in doubt the last one it was mapped to)
81
+
82
+ ###User integration (e.g. ActiveRecord)
83
+ class User < ActiveRecord::Base
84
+ include RPXNow::UserIntegration
85
+ end
86
+
87
+ user.rpx.identifiers == RPXNow.mappings(user.id)
88
+ user.rpx.map(identifier) == RPXNow.map(identifier, user.id)
89
+ user.rpx.unmap(identifier) == RPXNow.unmap(identifier, user.id)
90
+
91
+ ###Contacts (PRX Pro)
92
+ Retrieve all contacts for a given user:
93
+ RPXNow.contacts(identifier).each {|c| puts "#{c['displayName']}: #{c['emails']}}
94
+
95
+ TODO
96
+ ====
97
+ - add provider / credentials helpers ?
98
+
99
+ Author
100
+ ======
101
+ ###Contributors
102
+ - [DBA](http://github.com/DBA)
103
+ - [dbalatero](http://github.com/dbalatero)
104
+
105
+ [Michael Grosser](http://pragmatig.wordpress.com)
106
+ grosser.michael@gmail.com
107
+ Hereby placed under public domain, do what you want, just do not hold me accountable...
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'echoe'
3
+
4
+ desc "Run all specs in spec directory"
5
+ task :default do |t|
6
+ options = "--colour --format progress --loadby --reverse"
7
+ files = FileList['spec/**/*_spec.rb']
8
+ system("spec #{options} #{files}")
9
+ end
10
+
11
+ #Gemspec
12
+ begin
13
+ require 'jeweler'
14
+ Jeweler::Tasks.new do |gem|
15
+ project_name = 'rpx_now'
16
+ gem.name = project_name
17
+ gem.summary = "Helper to simplify RPX Now user login/creation"
18
+ gem.email = "grosser.michael@gmail.com"
19
+ gem.homepage = "http://github.com/grosser/#{project_name}"
20
+ gem.authors = ["Michael Grosser"]
21
+ gem.add_dependency ['activesupport']
22
+ end
23
+ rescue LoadError
24
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
25
+ end
26
+
27
+ task :update_gemspec => [:manifest, :build_gemspec]
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 5
3
+ :patch: 6
4
+ :major: 0