Index: [Article Count Order] [Thread]

Date: Wed, 18 Dec 2002 01:26:25 +0900 (JST)
From: GOTOU Yuuzou <gotoyuzo@notwork.org>
Subject: [webrickja:70] Re: Basic Auth
To: webrickja@notwork.org
Message-Id: <20021218.012625.74164629.gotoyuzo@kotetsu.does.notwork.org>
In-Reply-To: <20021218004444.7d94ad91.sgs02516@nifty.com>
References: <20021218004444.7d94ad91.sgs02516@nifty.com>
X-Mail-Count: 00070

ごとうゆうぞうです。

In message <20021218004444.7d94ad91.sgs02516@nifty.com>,
 `たむらけんいち <sgs02516@nifty.com>' wrote:
> 自分でも挑戦したのですが、うまく動かないのでアドバイスお願いします。
> WEBrickでの Basic認証です。

ええと、これでいかがでしょう。

   def basic_auth(req, res)
     STDERR.puts "basic auth ..."
     if proc = Proc.new{|user,pass| 
-       user = 'ruby' && pass = encode64('matz')
+       user == 'ruby' && pass == 'matz'
     } then
       realm = "Basic Auth"
       WEBrick::HTTPAuth::basic_auth(req,res,realm,&proc)
     end
     req.header.delete("basic-authorization")
   end