@@ -16,6 +16,14 @@
Charsets::Japanese
StackTrace
+
+ Authentication
+ Authentication::Store::DBIC
+ Authentication::Credential::Password
+
+ Session
+ Session::Store::FastMmap
+ Session::State::Cookie
/;
use Digest::SHA;authentication:
dbic:
user_class: SecureSBMDB::User
user_field: user_email
password_field: user_password
password_type: hashed
password_hash_type: SHA-1何度も繰り返しますが,.yml のファイルはタブコードを使用せずに,空白でインデントを付けてください.この設定は前に設定した Plugin のためのものです.各フィールドの意味は次の通り.
$ ./script/securesbm_create.pl controller Login
(出力省略)
$ ./script/securesbm_create.pl controller Logout
(出力省略)
$ sub index : Private {
my ($self, $c) = @_;
# ログイン名とパスワードの取得
my $loginname = $c->req->params->{user_email} || "";
my $password = $c->req->params->{user_password} || "";
$loginname =~ tr/A-Z/a-z/;
if ($loginname && $password) {
# ログイン試行
if ($c->login($loginname, $password)) {
# ログイン成功
$c->log->debug('*** Login Success: user['
. $c->user .']');
if( $loginname eq 'admin' ){
$c->res->redirect($c->uri_for('/admin'));
}else{
$c->res->redirect($c->uri_for('/'));
}
return;
} else {
# ログイン失敗
$c->log->debug('*** Login Failed: [' . $loginname
. '/' . $password . ']');
$c->log->info('*** Login Failed: ['
. $loginname . ']');
}
}
$c->log->debug('*** user/password [' . $loginname . '/'
. $password . ']');
$c->forward('loginform');
}sub loginform : Path('/loginform') {
my ($self, $c) = @_;
$c->stash->{template} = 'login.tt';
}<div id="login_center">
<h1>ログインページ</h1>
<p>ユーザ名とパスワードを入力してください</p>
<form action="/login" method="POST" name="login" id="login">
<table>
<tr><td>ユーザ名: </td>
<td><input type="text" name="user_email" width="30"
id="user_email"></td></tr>
<tr><td>パスワード:</td>
<td> <input type="password" name="user_password" width="30"
id="user_password"></td></tr>
<tr><td></td>
<td align="right"><input type="submit" name="submit" value="ログイン"
id="login_submit">
<input type="reset" id="login_reset"></td></tr>
</table>
</form>
</div> <!-- end of login_center -->
[%#
This Program is distributed under version 1.0 of the Rinza Public
License Agreement, that is bundled with this package in the file
LICENSE, and is available through the website at the following URL:
http://www.tyzoh.jp/rinza/licenses/LICENSE-1.0.txt.
This is the Original Program.
The Initial Developer of the Original Program is Nihon Unisys, Ltd.
The Original Program is copyrighted (C) 2006-2007 by Nihon Unisys, Ltd. with
all rights reserved.
There is NO WARRANTY OF ANY KIND by the Initial Developer of the
Original Program.
%]
sub index : Private {
my ($self, $c) = @_;
# ログアウト
$c->logout;
# Top ページに戻す
$c->response->redirect($c->uri_for('/'));
}sub auto : Private {
my ( $self, $c ) = @_;
$c->log->debug( '*** Controller [' . $c->controller . '].' );
$c->log->debug( '*** action [' . $c->req->action . '].' );
# Controller が Login か Root の場合には,認証を必要としない
if ( $c->controller eq $c->controller('Login')
|| $c->controller eq $c->controller('Root') ){
return 1;
}
# $c->user_exists が false の場合は,ログインをしていない.
if (!$c->user_exists) {
$c->log->
debug('*** Root::auto User not found, forwarding to /login');
$c->response->redirect($c->uri_for('/login'));
return 0;
}
# ユーザが見つかった場合
$c->log->debug('*** Root::auto User Found');
return 1;
}
Keyword: Perl Catalyst Secure-SBM SSBM セキュア・ソーシャル・ブックマーク
タグ:Secure-SBM
いかちょー (2007-06-12 09:36) | コメント(0)| トラックバック(0)
トラックバックURL:
月別アーカイブ
Copyright (C) 2004-2011 Nihon Unisys, Ltd. All Rights Reserved.
Powered by Movable Type Open Source