����Web���ץ�Ǥ��ꤿ���ʡ��Ȥ�������Catalyst�Ǥ��äĤ�ǧ�ڽ�������ΤϾ������ݡ�
�����ǡ�Catalyst�Ǻ�ή�Ԥ�(?)���ϤƤ�ǧ����Ȥ�����Υץ饰�����Ƥߤޤ�������Ȥ�Hatena::API::Auth��ñ�˻ȤäƤߤ�������
��Catalyst::Plugin::Authentication::Credential::HatenaAuth
�����Ȥ��Ȥ���ʴ����˽�褦�ˤʤ�ޤ���
use Catalyst qw/Authentication::Credential::HatenaAuth/;
MyApp->config->{authentication}{hatenaauth} = {
secret => 'xxxxxxxxx',
api_key => 'xxxxxxxxxxxxxxxxxxxx',
};
__PACKAGE__->setup;
sub default : Private {
my ( $self, $c ) = @_;
$c->authenticate_hatena;
$c->res->redirect('/') if $c->req->param('cert');
if( $c->req->cookies->{hatenaauth} ){
my %data = $c->req->cookies->{hatenaauth}->value;
$c->stash->{username} = $data{name};
$c->stash->{image_url} = $data{image_url};
$c->stash->{thumbnail_url} = $data{thumbnail_url};
}
}
sub login : Local {
my ( $self, $c ) = @_;
$c->res->redirect( $c->config->{hatena_api}->uri_to_login );
}�ʲ�������Ȥ�����
�ϤƤ�ǧ�ڤ�ɬ�פʤΤ���̩����API�����ʤΤǡ�config��YAML�ե�����Τɤ��餫�˻��ꤷ�Ƥ����ޤ���
# config�˽��
MyApp->config->{authentication}{hatenaauth} = {
secret => 'xxxxxxxxx',
api_key => 'xxxxxxxxxxxxxxxxxxxx',
};# myapp.yml�˽��
authentication:
hatenaauth:
secret: xxxxxxxxx
api_key: xxxxxxxxxxxxxxxxxxxxCookie�˳�Ǽ���줿�ǡ����μ������ȡ��ϤƤ�ǧ��API�����ǧ�ڷ�̼������(������Хå�URL)��������Ǥϥȥåץڡ�����ξ����äƤ��ޤ���
cert�դ���URL�ǡֹ����ץܥ�������ȥ��顼�ˤʤ�Τǡ��ϤƤʤ�ǧ�ڷ�̤�����(cert������Ȥ�)�ϥ�����쥯�Ȥ��Ƥ��ޤ���
sub default : Private {
my ( $self, $c ) = @_;
$c->authenticate_hatena; # �����callback URL�˽�
$c->res->redirect('/') if $c->req->param('cert'); #
if( $c->req->cookies->{hatenaauth} ){
my %data = $c->req->cookies->{hatenaauth}->value;
$c->stash->{username} = $data{name};
$c->stash->{image_url} = $data{image_url};
$c->stash->{thumbnail_url} = $data{thumbnail_url};
}
}http://example.com/login���������URL�Ȥ��롣
sub login : Local {
my ( $self, $c ) = @_;
$c->res->redirect( $c->config->{hatena_api}->uri_to_login );
}���TT��Ŭ����ʬ�����Ƥ�����С���������Ѥߤξ��ϥ桼�������ɽ�����������Ǥʤ����ˤϥ�������URL��ɽ������Ȥ������Ȥ��Ǥ��ޤ���
�ȡ������ǽƤߤޤ������̤����Ƥ���ʤΤ˰�̣������Τ��ɤ����������������Υ⥸�塼���ΤϽ��ƤʤΤǸ����㤤�Τ��ȤƤ���ΤǤϤʤ����Ȼפ��ƻ���������ޤ��ʤ����������褦�ʵ���(��)�������ʤ�Cookie�ˤ֤�����Ȥ����Τ�ɤ��ʤΤ�顣��ꤢ�����������Ǥ����ۤ�TypeKey�Τ���Υѥ���Ǥ�����
�����Ѥʥȥ��ʤɤ���Ф���Ŧ����������й����Ǥ����Ȥ����������Ԥ������������κ�äƤ���ʤ����ʤ���
����
http://www.tcool.org/catalyst/WritingPlugins.html
http://qootas.org/blog/archives/2005/06/catalyst_authen.html
http://blog.nomadscafe.jp/archives/000540.html
http://blog.nomadscafe.jp/archives/000501.html
http://d.hatena.ne.jp/hyuki/20060424