rubycas-server 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +38 -0
- data/Manifest.txt +4 -11
- data/README.txt +1 -1
- data/Rakefile +2 -2
- data/bin/rubycas-server +16 -47
- data/bin/rubycas-server-ctl +13 -154
- data/config.example.yml +113 -64
- data/lib/casserver.rb +78 -80
- data/lib/casserver/authenticators/active_directory_ldap.rb +3 -0
- data/lib/casserver/authenticators/ldap.rb +14 -1
- data/lib/casserver/authenticators/sql_encrypted.rb +75 -0
- data/lib/casserver/controllers.rb +19 -8
- data/lib/casserver/environment.rb +23 -0
- data/lib/casserver/models.rb +104 -53
- data/lib/casserver/utils.rb +0 -24
- data/lib/casserver/version.rb +2 -2
- data/lib/casserver/views.rb +28 -0
- data/lib/rubycas-server.rb +1 -0
- metadata +77 -68
- data/vendor/camping-1.5.180/CHANGELOG +0 -99
- data/vendor/camping-1.5.180/COPYING +0 -18
- data/vendor/camping-1.5.180/README +0 -119
- data/vendor/camping-1.5.180/Rakefile +0 -117
- data/vendor/camping-1.5.180/lib/camping-unabridged.rb +0 -762
- data/vendor/camping-1.5.180/lib/camping.rb +0 -55
- data/vendor/camping-1.5.180/lib/camping/db.rb +0 -78
- data/vendor/camping-1.5.180/lib/camping/fastcgi.rb +0 -244
- data/vendor/camping-1.5.180/lib/camping/reloader.rb +0 -163
- data/vendor/camping-1.5.180/lib/camping/session.rb +0 -123
- data/vendor/camping-1.5.180/lib/camping/webrick.rb +0 -68
@@ -1,123 +0,0 @@
|
|
1
|
-
# == About camping/session.rb
|
2
|
-
#
|
3
|
-
# This file contains two modules which supply basic sessioning to your Camping app.
|
4
|
-
# Again, we're dealing with a pretty little bit of code: approx. 60 lines.
|
5
|
-
#
|
6
|
-
# * Camping::Models::Session is a module which adds a single <tt>sessions</tt> table
|
7
|
-
# to your database.
|
8
|
-
# * Camping::Session is a module which you will mix into your application (or into
|
9
|
-
# specific controllers which require sessions) to supply a <tt>@state</tt> variable
|
10
|
-
# you can use in controllers and views.
|
11
|
-
#
|
12
|
-
# For a basic tutorial, see the *Getting Started* section of the Camping::Session module.
|
13
|
-
require 'camping'
|
14
|
-
|
15
|
-
module Camping::Models
|
16
|
-
# A database table for storing Camping sessions. Contains a unique 32-character hashid, a
|
17
|
-
# creation timestamp, and a column of serialized data called <tt>ivars</tt>.
|
18
|
-
class Session < Base
|
19
|
-
serialize :ivars
|
20
|
-
def []=(k, v) # :nodoc:
|
21
|
-
self.ivars[k] = v
|
22
|
-
end
|
23
|
-
def [](k) # :nodoc:
|
24
|
-
self.ivars[k] rescue nil
|
25
|
-
end
|
26
|
-
|
27
|
-
RAND_CHARS = [*'A'..'Z'] + [*'0'..'9'] + [*'a'..'z']
|
28
|
-
|
29
|
-
# Generates a new session ID and creates a row for the new session in the database.
|
30
|
-
def self.generate cookies
|
31
|
-
rand_max = RAND_CHARS.size
|
32
|
-
sid = (0...32).inject("") { |ret,_| ret << RAND_CHARS[rand(rand_max)] }
|
33
|
-
sess = Session.create :hashid => sid, :ivars => Camping::H[]
|
34
|
-
cookies.camping_sid = sess.hashid
|
35
|
-
sess
|
36
|
-
end
|
37
|
-
|
38
|
-
# Gets the existing session based on the <tt>camping_sid</tt> available in cookies.
|
39
|
-
# If none is found, generates a new session.
|
40
|
-
def self.persist cookies
|
41
|
-
if cookies.camping_sid
|
42
|
-
session = Camping::Models::Session.find_by_hashid cookies.camping_sid
|
43
|
-
end
|
44
|
-
unless session
|
45
|
-
session = Camping::Models::Session.generate cookies
|
46
|
-
end
|
47
|
-
session
|
48
|
-
end
|
49
|
-
|
50
|
-
# Builds the session table in the database. To be used in your application's
|
51
|
-
# <tt>create</tt> method.
|
52
|
-
#
|
53
|
-
# Like so:
|
54
|
-
#
|
55
|
-
# def Blog.create
|
56
|
-
# Camping::Models::Session.create_schema
|
57
|
-
# unless Blog::Models::Post.table_exists?
|
58
|
-
# ActiveRecord::Schema.define(&Blog::Models.schema)
|
59
|
-
# end
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
def self.create_schema
|
63
|
-
unless table_exists?
|
64
|
-
ActiveRecord::Schema.define do
|
65
|
-
create_table :sessions, :force => true do |t|
|
66
|
-
t.column :id, :integer, :null => false
|
67
|
-
t.column :hashid, :string, :limit => 32
|
68
|
-
t.column :created_at, :datetime
|
69
|
-
t.column :ivars, :text
|
70
|
-
end
|
71
|
-
end
|
72
|
-
reset_column_information
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
module Camping
|
79
|
-
# The Camping::Session module is designed to be mixed into your application or into specific
|
80
|
-
# controllers which require sessions. This module defines a <tt>service</tt> method which
|
81
|
-
# intercepts all requests handed to those controllers.
|
82
|
-
#
|
83
|
-
# == Getting Started
|
84
|
-
#
|
85
|
-
# To get sessions working for your application:
|
86
|
-
#
|
87
|
-
# 1. <tt>require 'camping/session'</tt>
|
88
|
-
# 2. Mixin the module: <tt>module YourApp; include Camping::Session end</tt>
|
89
|
-
# 3. In your application's <tt>create</tt> method, add a call to <tt>Camping::Models::Session.create_schema</tt>
|
90
|
-
# 4. Throughout your application, use the <tt>@state</tt> var like a hash to store your application's data.
|
91
|
-
#
|
92
|
-
# If you are unfamiliar with the <tt>create</tt> method, see
|
93
|
-
# http://code.whytheluckystiff.net/camping/wiki/GiveUsTheCreateMethod.
|
94
|
-
#
|
95
|
-
# == A Few Notes
|
96
|
-
#
|
97
|
-
# * The session ID is stored in a cookie. Look in <tt>@cookies.camping_sid</tt>.
|
98
|
-
# * The session data is stored in the <tt>sessions</tt> table in your database.
|
99
|
-
# * All mounted Camping apps using this class will use the same database table.
|
100
|
-
# * However, your application's data is stored in its own hash.
|
101
|
-
# * Session data is only saved if it has changed.
|
102
|
-
module Session
|
103
|
-
# This <tt>service</tt> method, when mixed into controllers, intercepts requests
|
104
|
-
# and wraps them with code to start and close the session. If a session isn't found
|
105
|
-
# in the database it is created. The <tt>@state</tt> variable is set and if it changes,
|
106
|
-
# it is saved back into the database.
|
107
|
-
def service(*a)
|
108
|
-
session = Camping::Models::Session.persist @cookies
|
109
|
-
app = self.class.name.gsub(/^(\w+)::.+$/, '\1')
|
110
|
-
@state = (session[app] ||= Camping::H[])
|
111
|
-
hash_before = Marshal.dump(@state).hash
|
112
|
-
s = super(*a)
|
113
|
-
if session
|
114
|
-
hash_after = Marshal.dump(@state).hash
|
115
|
-
unless hash_before == hash_after
|
116
|
-
session[app] = @state
|
117
|
-
session.save
|
118
|
-
end
|
119
|
-
end
|
120
|
-
s
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# == About camping/webrick.rb
|
2
|
-
#
|
3
|
-
# For many who have Ruby installed, Camping and WEBrick is a great option.
|
4
|
-
# It's definitely the easiest configuration, however some performance is sacrificed.
|
5
|
-
# For better speed, check out Mongrel at http://mongrel.rubyforge.org/, which comes
|
6
|
-
# with Camping hooks and is supported by the Camping Tool.
|
7
|
-
require 'camping'
|
8
|
-
require 'webrick/httpservlet/abstract.rb'
|
9
|
-
|
10
|
-
module WEBrick
|
11
|
-
# WEBrick::CampingHandler is a very simple handle for hosting Camping apps in
|
12
|
-
# a WEBrick server. It's used much like any other WEBrick handler.
|
13
|
-
#
|
14
|
-
# == Mounting a Camping App
|
15
|
-
#
|
16
|
-
# Assuming Camping.goes(:Blog), the Blog application can be mounted alongside
|
17
|
-
# other WEBrick mounts.
|
18
|
-
#
|
19
|
-
# s = WEBrick::HTTPServer.new(:BindAddress => host, :Port => port)
|
20
|
-
# s.mount "/blog", WEBrick::CampingHandler, Blog
|
21
|
-
# s.mount_proc("/") { ... }
|
22
|
-
#
|
23
|
-
# == How Does it Compare?
|
24
|
-
#
|
25
|
-
# Compared to other handlers, WEBrick is well-equipped in terms of features.
|
26
|
-
#
|
27
|
-
# * The <tt>X-Sendfile</tt> header is supported, along with etags and
|
28
|
-
# modification time headers for the file served. Since this handler
|
29
|
-
# is a subclass of WEBrick::HTTPServlet::DefaultFileHandler, all of its
|
30
|
-
# logic is used.
|
31
|
-
# * IO is streaming up and down. When you upload a file, it is streamed to
|
32
|
-
# the server's filesystem. When you download a file, it is streamed to
|
33
|
-
# your browser.
|
34
|
-
#
|
35
|
-
# While WEBrick is a bit slower than Mongrel and FastCGI options, it's
|
36
|
-
# a decent choice, for sure!
|
37
|
-
class CampingHandler < WEBrick::HTTPServlet::DefaultFileHandler
|
38
|
-
# Creates a CampingHandler, which answers for the application within +klass+.
|
39
|
-
def initialize(server, klass)
|
40
|
-
super(server, klass)
|
41
|
-
@klass = klass
|
42
|
-
end
|
43
|
-
# Handler for WEBrick requests (also aliased as do_POST).
|
44
|
-
def service(req, resp)
|
45
|
-
puts @klass.inspect
|
46
|
-
puts req.body.inspect
|
47
|
-
puts req.meta_vars.inspect
|
48
|
-
controller = @klass.run((req.body and StringIO.new(req.body)), req.meta_vars)
|
49
|
-
resp.status = controller.status
|
50
|
-
@local_path = nil
|
51
|
-
controller.headers.each do |k, v|
|
52
|
-
if k =~ /^X-SENDFILE$/i
|
53
|
-
@local_path = v
|
54
|
-
else
|
55
|
-
[*v].each do |vi|
|
56
|
-
resp[k] = vi
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
if @local_path
|
62
|
-
do_GET(req, resp)
|
63
|
-
else
|
64
|
-
resp.body = controller.body.to_s
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|