Skip to content

Commit

Permalink
parse Authorization header with method
Browse files Browse the repository at this point in the history
before => Authorization: cnVtaWRpZXI6MTIzNA
after  => Authorization: Basic cnVtaWRpZXI6MTIzNA

http://en.wikipedia.org/wiki/Basic_access_authentication
> The Authorization header is constructed as follows:
>   1. Username and password are combined into a string "username:password"
>   2. The resulting string literal is then encoded using Base64
>   3. The authorization method and a space i.e. "Basic " is then put
>      before the encoded string.

3번 rule 에 따라 method 를 명시해줘야 합니다.

`curl` 의 -u|--user 옵션을 사용해서 test req 를 쉽게 만들 수 있습니다.
  • Loading branch information
aanoaa committed Dec 18, 2012
1 parent 978b034 commit 78fc07f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Silex/Donnenwa/Web/Controller/Root.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sub auto :Private {
if ($mobile_user) {
## $auth is 'cnVtaWRpZXI6MTIzNA==
## MIME::Base64::encode
my $user_info = decode_base64($mobile_user);
my $user_info = decode_base64((split / /, $mobile_user)[1]);
my ( $username, $password ) = $self->api->mobile_user($user_info);

if ($username && $password) {
Expand Down

0 comments on commit 78fc07f

Please sign in to comment.