LoginSignup
2
5

More than 5 years have passed since last update.

bearer token による認証、認可

Last updated at Posted at 2017-03-18

最近はOwin(Open Web Interface for .NET)による Owin middlewareのお世話になることが多い。
認証・認可周りをいろいろと調べていて、2つの作法があることが分かってきた。

まずは、1つめは

 UseOAuthAuthorizationServer(this IAppBuilder app, OAuthAuthorizationServerOptions options)

系のメソッドで認可サーバの設定後、

 UseOAuthBearerAuthentication(this IAppBuilder app, OAuthBearerAuthenticationOptions options)

で呼び出されたヘッダ情報のベアラトークンを検証して、クレーム情報を操作する系。

そして2つ目の、よく見かける実装が

 UseOAuthBearerTokens(this IAppBuilder app, OAuthAuthorizationServerOptions options)

のやつ。

上記は
 Microsoft.Owin.Security.OAuth
パッケージに格納されているが、下のほう(UseOAuthBearerTokens)は
 Microsoft.AspNet.Identity.Owin
に格納されている。
ってことは生まれが違うんだね。

誰かがやっぱり議論していた。
http://stackoverflow.com/questions/28048355/useoauthbearertokens-vs-useoauthbearerauthentication
そのままずばりの内容ですね。

ひとつ目の方法の「UseOAuthAuthorizationServer」は「Authorization」って書いてあるからやっぱり「認可サーバ」についての設定だろうし、「UseOAuthBearerAuthentication」には「Authentication」って書いてあるからやっぱり「認証」関係の設定なんだろうな。
翻訳サイトで訳すと「Authorization」も「Authentication」も「認証」って訳されるんことが多いから気を付けましょう。
 

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5