fotolifeAPIの挙動がおかしい?
うーん... iOSでfotolife APIを呼んでるんだけど変な挙動する。
一回正しいWSSE Token作ってhttp://f.hatena.ne.jp/atomにアクセスした後、間違った適当なユーザー名と適当なパスワードでアクセスすると、結構な割合で認証に通る。しかも元のユーザのIDで認証が通ってるっぽい。
kent013で認証した後、別のユーザでログインしてみたログ。
ユーザ名:"d", パスワード:"d"
でリクエストヘッダ(改行してあります)
2012-03-10 01:07:01.332 tottepost[96207:1a303] { Authorization = "WSSE profile=\"UsernameToken\""; "X-Wsse" = "UsernameToken Username=\"d\", PasswordDigest=\"UKsxV+dhFHnLQinj4nu/V7VrGEQ=\", Nonce=\"MTMzMTMwOTIyMS4zMzA0OTQ=\", Created=\"2012-03-09T16:07:01Z\""; }
そのレスポンス
2012-03-10 01:07:01.374 tottepost[96207:1a303] <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://purl.org/atom/ns#"> <link type="application/x.atom+xml" rel="service.post" href="http://f.hatena.ne.jp/atom/post" title="kent013's fotolife" /> <link type="application/x.atom+xml" rel="service.feed" href="http://f.hatena.ne.jp/atom/feed" title="kent013's fotolife" /> </feed>,
kent013のfeedが返ってくる。レスポンスのヘッダは、
{ Age = 8412; Connection = "Keep-Alive"; "Content-Encoding" = gzip; "Content-Length" = 198; "Content-Type" = "application/x.atom+xml; charset=utf-8"; Date = "Fri, 09 Mar 2012 16:07:01 GMT"; "Keep-Alive" = "timeout=7, max=5"; Server = "Apache/2.2.3 (CentOS)"; Vary = "Accept-Encoding,User-Agent"; Via = "1.1 fotolifesquid01.hatena.ne.jp:80 (squid/2.7.STABLE6)"; "X-Cache" = "HIT from squid.hatena.ne.jp"; "X-Cache-Lookup" = "HIT from squid.hatena.ne.jp:80"; "X-Framework" = "Hatena/2.0"; "X-PageMaker" = Atom; "X-Server" = fotolifebackend02; }
なんか、キャッシュにHITしてる。
二回目のリクエスト、ユーザー名:"k", パスワード:"k"
2012-03-10 01:07:18.290 tottepost[96207:1a303] { Authorization = "WSSE profile=\"UsernameToken\""; "X-Wsse" = "UsernameToken Username=\"k\", PasswordDigest=\"tZ4EPCQGnE08ytIHjotyIapWltc=\", Nonce=\"MTMzMTMwOTIzOC4yOTAzMTM=\", Created=\"2012-03-09T16:07:18Z\""; }
レスポンス。やっぱりkent013
2012-03-10 01:07:18.328 tottepost[96207:1a303] <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://purl.org/atom/ns#"> <link type="application/x.atom+xml" rel="service.post" href="http://f.hatena.ne.jp/atom/post" title="kent013's fotolife" /> <link type="application/x.atom+xml" rel="service.feed" href="http://f.hatena.ne.jp/atom/feed" title="kent013's fotolife" /> </feed>,
そしてレスポンスヘッダ
{ Age = 8429; Connection = "Keep-Alive"; "Content-Encoding" = gzip; "Content-Length" = 198; "Content-Type" = "application/x.atom+xml; charset=utf-8"; Date = "Fri, 09 Mar 2012 16:07:18 GMT"; "Keep-Alive" = "timeout=7, max=5"; Server = "Apache/2.2.3 (CentOS)"; Vary = "Accept-Encoding,User-Agent"; Via = "1.1 fotolifesquid01.hatena.ne.jp:80 (squid/2.7.STABLE6)"; "X-Cache" = "HIT from squid.hatena.ne.jp"; "X-Cache-Lookup" = "HIT from squid.hatena.ne.jp:80"; "X-Framework" = "Hatena/2.0"; "X-PageMaker" = Atom; "X-Server" = fotolifebackend02; }
やっぱりHIT。MISSしたときは403が返ってくる。当然403が正しい挙動だよね...?うーん。おれの実装がおかしいのかfotolifeがおかしいのか、判断に困るな...
追記
ヘッダに
"Cache-Control" = "no-cache";
って付けたら正しく403が返ってくるようになったけど、うーん...