Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5667

Show
Ignore:
Timestamp:
12/03/06 01:05:49 (2 years ago)
Author:
david
Message:

Make it invitingly easy for someone to implement digest authentication -- come on, you can do it!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/http_authentication/lib/http_authentication.rb

    r5665 r5667  
    11require 'http_authentication/basic' 
     2# IMPLEMENT ME: require 'http_authentication/digest'  
  • plugins/http_authentication/lib/http_authentication/digest.rb

    r5665 r5667  
    2222 
    2323    def user_name_and_password(request) 
    24       Base64.decode64(credentials(request)).split(/:/, 2) 
    25     end 
    26    
    27     def credentials(request) 
    28       authorization(request).split.last 
     24      decode_credentials(request).split(/:/, 2) 
    2925    end 
    3026   
     
    3531    end 
    3632   
     33    def decode_credentials(request) 
     34      # Fancy nouncing goes here 
     35    end 
     36 
     37    def encode_credentials(user_name, password) 
     38      # You compute me 
     39    end 
     40 
    3741    def authentication_request(controller, realm) 
    38       controller.headers["WWW-Authenticate"] = %(Basic realm="#{realm.gsub(/"/, "")}") 
     42      # Proper headers 
    3943      controller.render :text => "Access denied.\n", :status => :unauthorized 
    4044      return false     
  • plugins/http_authentication/README

    r5666 r5667  
    22=================== 
    33 
    4 Makes it dead easy to do HTTP authentication using either the vanilla Basic or the more advanced Digest approach
     4Makes it dead easy to do HTTP Basic authentication
    55 
    66Simple Basic example: 
     
    7070  end 
    7171 
     72 
    7273Todo: 
    7374 
    74 * Implement Digest authentication scheme 
     75* Implement Digest authentication scheme (be a hero, implement it!) 
    7576 
    7677 
  • plugins/http_authentication/test/basic_test.rb

    r5666 r5667  
    33require 'http_authentication' 
    44 
    5 class HttpAuthenticationTest < Test::Unit::TestCase 
     5class HttpBasicAuthenticationTest < Test::Unit::TestCase 
    66  include HttpAuthentication::Basic 
    77