omniauth-prx 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/lib/omniauth-prx.rb +1 -0
- data/lib/omniauth/prx.rb +2 -0
- data/lib/omniauth/prx/version.rb +5 -0
- data/lib/omniauth/strategies/prx.rb +47 -0
- data/omniauth-prx.gemspec +22 -0
- metadata +119 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# OmniAuth PRX
|
2
|
+
|
3
|
+
An upcoming release of PRX (www.prx.org) will provide OAuth2 support for login and access to v2 of the PRX API.
|
4
|
+
|
5
|
+
Currently, PRX supports OpenID authentication, and uses an API key for access to V1 of the PRX API.
|
6
|
+
|
7
|
+
OmniAuth PRX is based on the OmniAuth-OAuth2 gem template for OAuth2 strategies.
|
8
|
+
|
9
|
+
https://github.com/intridea/omniauth-oauth2
|
10
|
+
|
11
|
+
## Installing
|
12
|
+
|
13
|
+
Add to your `Gemfile`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'omniauth-prx'
|
17
|
+
```
|
18
|
+
|
19
|
+
Then `bundle install`.
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
`OmniAuth::Strategies::PRX` is an OmniAuth OAuth2 Strategy based on the: https://github.com/intridea/omniauth.
|
24
|
+
|
25
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
29
|
+
provider 'PRX', ENV['PRX_KEY'], ENV['PRX_SECRET']
|
30
|
+
end
|
31
|
+
```
|
32
|
+
To get the key and secret, login to PRX, then visit:
|
33
|
+
|
34
|
+
https://www.prx.org/oauth_clients
|
35
|
+
|
36
|
+
to set-up your client application.
|
37
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/omniauth-prx.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "omniauth/prx"
|
data/lib/omniauth/prx.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class PRX < OmniAuth::Strategies::OAuth2
|
6
|
+
# Give your strategy a name.
|
7
|
+
option :name, "PRX"
|
8
|
+
|
9
|
+
# This is where you pass the options you would pass when
|
10
|
+
# initializing your consumer from the OAuth gem.
|
11
|
+
option :client_options, {:site => "https://www.prx.org"}
|
12
|
+
|
13
|
+
# These are called after authentication has succeeded. If
|
14
|
+
# possible, you should try to set the UID without making
|
15
|
+
# additional calls (if the user id is returned with the token
|
16
|
+
# or as a URI parameter). This may not be possible with all
|
17
|
+
# providers.
|
18
|
+
uid{ raw_info['id'] }
|
19
|
+
|
20
|
+
info do
|
21
|
+
{
|
22
|
+
:login => raw_info['login'],
|
23
|
+
:email => raw_info['email']
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
extra do
|
28
|
+
{
|
29
|
+
'raw_info' => raw_info
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def raw_info
|
34
|
+
@raw_info ||= get_raw_info
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_raw_info
|
38
|
+
t = access_token
|
39
|
+
puts "get_raw_info: access_token: #{t.inspect}"
|
40
|
+
r = access_token.get('/me').parsed
|
41
|
+
puts "get_raw_info: response: #{r.inspect}"
|
42
|
+
r
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth/prx/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-prx"
|
7
|
+
s.version = OmniAuth::PRX::VERSION
|
8
|
+
s.authors = ["Andrew Kuklewicz"]
|
9
|
+
s.email = ["andrew@prx.org"]
|
10
|
+
s.homepage = "https://github.com/prx/omniauth-prx"
|
11
|
+
s.summary = %q{PRX strategy for OmniAuth using OAuth2}
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_runtime_dependency "omniauth-oauth2", '~> 1.0.0'
|
19
|
+
|
20
|
+
s.add_development_dependency "rspec"
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-prx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Andrew Kuklewicz
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-12-07 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: omniauth-oauth2
|
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: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rake
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
description:
|
66
|
+
email:
|
67
|
+
- andrew@prx.org
|
68
|
+
executables: []
|
69
|
+
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files: []
|
73
|
+
|
74
|
+
files:
|
75
|
+
- .gitignore
|
76
|
+
- Gemfile
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- lib/omniauth-prx.rb
|
80
|
+
- lib/omniauth/prx.rb
|
81
|
+
- lib/omniauth/prx/version.rb
|
82
|
+
- lib/omniauth/strategies/prx.rb
|
83
|
+
- omniauth-prx.gemspec
|
84
|
+
has_rdoc: true
|
85
|
+
homepage: https://github.com/prx/omniauth-prx
|
86
|
+
licenses: []
|
87
|
+
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
version: "0"
|
111
|
+
requirements: []
|
112
|
+
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.4.2
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: PRX strategy for OmniAuth using OAuth2
|
118
|
+
test_files: []
|
119
|
+
|