GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: A simple application written in merb to help you manage ad serving across multiple sites
Clone URL: git://github.com/kneath/greed.git
Add basic authentication
kneath (author)
Mon Apr 28 04:27:11 -0700 2008
commit  fab95a41a91a52b6b1ca7e34f12696f13c96e071
tree    864b0308033d6f073a3a26f104a190ccf202b840
parent  5442c11a349efbc3bb753ca4a17b9e34d6992341
...
2
3
4
 
5
6
7
...
2
3
4
5
6
7
8
0
@@ -2,6 +2,7 @@
0
 *.log
0
 *.pid
0
 config/database.yml
0
+config/greed.yml
0
 config/deploy.rb
0
 db/test.sqlite
0
 schema/*.sql
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
3
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -1,2 +1,16 @@
0
 class Application < Merb::Controller
0
+
0
+ before :authenticate
0
+
0
+ def authenticate
0
+ user = Merb::Config[:greed][:authentication][:username]
0
+ password = Merb::Config[:greed][:authentication][:password]
0
+ given_user, given_password = Base64.decode64(request.env['HTTP_AUTHORIZATION'].split.last).split(':') rescue [nil, nil]
0
+ unless user == given_user && password == given_password
0
+ headers['WWW-Authenticate'] = %{Basic realm="Idscms/Admin"}
0
+ render("HTTP Basic: Access denied.\n", :status => 401)
0
+ throw :halt
0
+ end
0
+ end
0
+
0
 end
0
\ No newline at end of file
...
13
14
15
 
16
17
18
...
13
14
15
16
17
18
19
0
@@ -13,6 +13,7 @@ Merb::Config.use do |c|
0
   # c[:session_id_key] = '_session_id'
0
   
0
   c[:session_store] = 'none'
0
+ c[:greed] = YAML.load_file(Merb.root / 'config' / 'greed.yml')
0
 end
0
 
0
 ### Merb doesn't come with database support by default. You need

Comments

    No one has commented yet.