subbarao-sinatra-openid 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +28 -0
- data/lib/sinatra/openid.rb +45 -0
- data/test/openid_test.rb +7 -0
- data/test/sinatra-openid_test.rb +7 -0
- data/test/test_helper.rb +11 -0
- metadata +100 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 SubbaRao Pasupuleti
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= sinatra-openid
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Copyright
|
6
|
+
|
7
|
+
Copyright (c) 2009 SubbaRao Pasupuleti. See LICENSE for details.
|
8
|
+
|
9
|
+
== sample sinatra application
|
10
|
+
|
11
|
+
require 'rubygems'
|
12
|
+
require 'sinatra'
|
13
|
+
gem 'sinatra-openid'
|
14
|
+
require 'sinatra/openid'
|
15
|
+
|
16
|
+
get '/' do
|
17
|
+
'<a href="/login">login</a>'
|
18
|
+
end
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "sinatra-openid"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "subbarao.pasupuleti@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/subbarao/sinatra-openid"
|
11
|
+
gem.authors = ["SubbaRao Pasupuleti"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/*_test.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
task :default => :test
|
28
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
gem 'rack-openid'
|
2
|
+
require 'rack'
|
3
|
+
require 'rack/openid'
|
4
|
+
require 'sinatra/base'
|
5
|
+
module Sinatra
|
6
|
+
module Openid
|
7
|
+
def self.registered(app)
|
8
|
+
use Rack::Session::Cookie
|
9
|
+
use Rack::OpenID
|
10
|
+
get '/login' do
|
11
|
+
%{<form action="/login" method="post">
|
12
|
+
<p>
|
13
|
+
<label for="openid_identifier">OpenID:</label>
|
14
|
+
<input id="openid_identifier" name="openid_identifier" type="text" />
|
15
|
+
</p>
|
16
|
+
|
17
|
+
<p>
|
18
|
+
<input name="commit" type="submit" value="Sign in" />
|
19
|
+
</p>
|
20
|
+
</form>}
|
21
|
+
end
|
22
|
+
|
23
|
+
get '/logout' do
|
24
|
+
session.clear
|
25
|
+
[ 302, { 'Location' => '/' }, [] ]
|
26
|
+
end
|
27
|
+
|
28
|
+
post '/login' do
|
29
|
+
if resp = request.env["rack.openid.response"]
|
30
|
+
if resp.status == :success
|
31
|
+
"Welcome: #{resp.display_identifier}"
|
32
|
+
else
|
33
|
+
"Error: #{resp.status}"
|
34
|
+
end
|
35
|
+
else
|
36
|
+
headers 'WWW-Authenticate' => Rack::OpenID.build_header(
|
37
|
+
:identifier => params["openid_identifier"]
|
38
|
+
)
|
39
|
+
throw :halt, [401, 'got openid?']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
register Openid
|
45
|
+
end
|
data/test/openid_test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
require 'sinatra'
|
8
|
+
require 'sinatra/openid'
|
9
|
+
|
10
|
+
class Test::Unit::TestCase
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: subbarao-sinatra-openid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SubbaRao Pasupuleti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-20 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sinatra
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rack
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rack-test
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.3.0
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rack-openid
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
description: ""
|
56
|
+
email: subbarao.pasupuleti@gmail.com
|
57
|
+
executables: []
|
58
|
+
|
59
|
+
extensions: []
|
60
|
+
|
61
|
+
extra_rdoc_files:
|
62
|
+
- LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
files:
|
65
|
+
- .document
|
66
|
+
- .gitignore
|
67
|
+
- LICENSE
|
68
|
+
- README.rdoc
|
69
|
+
- Rakefile
|
70
|
+
- lib/sinatra/openid.rb
|
71
|
+
- test/test_helper.rb
|
72
|
+
- test/sinatra-openid_test.rb
|
73
|
+
has_rdoc: false
|
74
|
+
homepage: http://github.com/subbarao/sinatra-openid
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --charset=UTF-8
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
version:
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 1.2.0
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: WELCOME
|
99
|
+
test_files:
|
100
|
+
- test/openid_test.rb
|