Skip to content

Commit 70f3568

Browse files
committed
Merge branch 'gh-pages' of github.com:WP-API/docs-ja into gh-pages
2 parents 8319179 + 28940f5 commit 70f3568

File tree

1 file changed

+48
-57
lines changed

1 file changed

+48
-57
lines changed

guide/authentication/index.md

+48-57
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
---
2-
title: Authentication
2+
title: 認証
33
---
44

5-
There are two options for authenticating with the API. The basic choice boils
6-
down to:
5+
このAPIにおいては、認証には2つの選択肢があり、基本的に以下のように選びましょう。
76

8-
* Are you a plugin/theme running on the site? Use **cookie authentication**
9-
* Are you a desktop/web/mobile client accessing the site externally? Use
10-
**OAuth authentication**
7+
* そのサイトで有効化されたテーマやプラグインから利用するのであれば **クッキー認証**
8+
* デスクトップアプリ、ウェブアプリ、モバイルアプリなどのサイトの外からアクセスするクライアントから API を利用するのであれば **OAuth 認証**
119

12-
13-
Cookie Authentication
10+
クッキー認証
1411
---------------------
15-
Cookie authentication is the basic authentication method included with
16-
WordPress. When you log in to your dashboard, this sets up the cookies correctly
17-
for you, so plugin and theme developers need only to have a logged-in user.
18-
19-
However, the REST API includes a technique called [nonces][] to avoid [CSRF][] issues.
20-
This prevents other sites from forcing you to perform actions without explicitly
21-
intending to do so. This requires slightly special handling for the API.
12+
クッキー認証は、WordPress に実装された基礎的な認証です。
13+
管理画面にログインするときには、このクッキー認証が利用されており、ログインするユーザーのクッキーが正しく発行されています。
14+
したがって、プラグインやテーマ開発者が必要とするのはログインしているユーザーのみとなります。
2215

23-
For developers using the built-in Javascript API, this is handled automatically
24-
for you. This is the recommended way to use the API for plugins and themes.
25-
Custom data models can extend `wp.api.models.Base` to ensure this is sent
26-
correctly for any custom requests.
16+
しかしながら、REST API では [CSRF][] の問題を解決するために [nonces][] と呼ばれる技術を利用しています。
17+
そのおかげで、他のサイトを経由して、あなたが明示的に意図していない行動をとってしまうのを防いでいるのですが、
18+
同時に、API 利用のために少し特殊な操作が必要になります。
2719

20+
プラグインやテーマの作者がビルトイン Javascript API を利用する場合には、この処理は自動的に行われます(推奨)。
21+
独自のデータモデルからアクセスする場合には、 `wp.api.models.Base` を継承することで、
22+
あらゆるカスタムリクエストで nonce がきちんと送信されることが保証されます。
2823

29-
For developers making manual Ajax requests, the nonce will need to be passed
30-
with each request. The API uses nonces with the action set to `wp_rest`. These
31-
can then be passed to the API via the `_wpnonce` data parameter (either POST data or in the query for GET requests), or via the `X-WP-Nonce` header.
24+
マニュアルで Ajax リクエストを送る場合、nonce は各リクエストで毎回送信する必要があります。
25+
送信された nonce は `wp_rest` にセットされたアクションと一緒に利用されます。
26+
API への nonce の受け渡しは、POST のデータや GET のクエリの `_wpnonce` パラメータ、
27+
あるいは`X-WP-Nonce` ヘッダーにセットして行います。
3228

33-
Note: Until recently, most software had spotty support for `DELETE` requests. For instance, PHP doesn't transform the request body of a `DELETE` request into a super global. As such, supplying the nonce as a header is the most reliable approach.
29+
Note: Until recently, most software had spotty support for `DELETE` requests. For instance, PHP doesn't transform the request body of a `DELETE` request into a super global. 従って、ヘッダーとして nonce を供給するやり方が最も信頼できるアプローチとなります。
3430

35-
It is important to keep in mind that this authentication method relies on WordPress cookies. As a result this method is only applicable when the REST API is used inside of WordPress and the current user is logged in. In addition, the current user must have the appropriate capability to perform the action being performed.
31+
この認証は WordPress のクッキーに依存しているということは覚えておきましょう。
32+
このクッキー認証が利用できるのは、REST API が WordPress の内部から使われていて、
33+
かつ、ユーザーがログインしている時のみであるということです。
34+
さらに、そのログインユーザーが、実行しようとしているアクションに必要な権限を与えられているということも条件となります。
3635

37-
As an example, this is how the built-in Javascript client creates the nonce:
36+
以下は、ビルトインの Javascript クライアントが nonce を生成する例です。
3837

3938
```php
4039
<?php
@@ -53,7 +52,7 @@ options.beforeSend = function(xhr) {
5352
};
5453
```
5554

56-
Here is an example of editing the title of a post, using jQuery AJAX:
55+
以下は、jQuery AJAX を使って投稿のタイトルを書き換える例です。
5756

5857
```javascript
5958
$.ajax( {
@@ -74,23 +73,21 @@ $.ajax( {
7473
[CSRF]: http://en.wikipedia.org/wiki/Cross-site_request_forgery
7574

7675

77-
OAuth Authentication
76+
OAuth 認証
7877
--------------------
79-
OAuth authentication is the main authentication handler used for external
80-
clients. With OAuth authentication, users still only ever log in via the normal
81-
WP login form, and then authorize clients to act on their behalf. Clients are
82-
then issued with OAuth tokens that enable them to access the API. This access
83-
can be revoked by users at any point.
78+
OAuth 認証は外部クライアントのための認証方法です。
79+
OAuth 認証でも、ユーザーは通常の WordPress ログイン画面を通じてのみログインを行い、
80+
その後、自身に代わって処理を行うクライアントを認証します。
81+
クライアントには、OAuth トークンが発行され、API へのアクセスが許可されます。このアクセス権はユーザー側からいつでも取り消すことができます。
8482

85-
OAuth authentication uses the [OAuth 1.0a specification][oauth] (published as
86-
RFC5849) and requires installing the [OAuth plugin][oauth-plugin] on the site.
87-
(This plugin will be included with the API when merged into core.)
83+
OAuth 認証は、[OAuth 1.0a specification][oauth] (published as
84+
RFC5849) を利用しており、[OAuth plugin][oauth-plugin] がサイトで
85+
有効化されていることが必要です(このプラグインは将来的にコアにマージされます)。
8886

89-
Once you have WP API and the OAuth server plugins activated on your server,
90-
you'll need to create a "consumer". This is an identifier for the application,
91-
and includes a "key" and "secret", both needed to link to your site.
87+
WP API と OAuth サーバー用のプラグインを有効化したら、コンシューマを作成しましょう。
88+
コンシューマは、アプリケーションの識別子であり、サイトとリンクするために必要な key と secret からなります。
9289

93-
To create the consumer, run the following on your server:
90+
コンシューマの作成には、サーバで以下を実行します。
9491

9592
```bash
9693
$ wp oauth1 add
@@ -100,36 +97,30 @@ Key: sDc51JgH2mFu
10097
Secret: LnUdIsyhPFnURkatekRIAUfYV7nmP4iF3AVxkS5PRHPXxgOW
10198
```
10299

103-
This key and secret is your consumer key and secret, and needs to be used
104-
throughout the authorization process. Currently no UI exists to manage this,
105-
however this is planned for a future release.
100+
上記の key と secret を認証のプロセス全体で利用します。
101+
現状 UI は無いのですが、将来的に導入されます。
106102

107-
For examples on how to use this, both the [CLI client][client-cli] and the
108-
[API console][api-console] make use of the OAuth functionality, and are a great
109-
starting point.
103+
利用方法の事例として、[CLI client][client-cli] および、 [API console][api-console] を見てみるといいでしょう。
110104

111105
[oauth]: http://tools.ietf.org/html/rfc5849
112106
[oauth-plugin]: https://github.com/WP-API/OAuth1
113107
[client-cli]: https://github.com/WP-API/client-cli
114108
[api-console]: https://github.com/WP-API/api-console
115109

116110

117-
Basic Authentication
111+
ベーシック認証
118112
--------------------
119-
Basic authentication is an optional authentication handler for external clients.
120-
Due to the complexity of OAuth authentication, basic authentication can be
121-
useful during development. However, Basic authentication requires passing your
122-
username and password on every request, as well as giving your credentials to
123-
clients, so it is heavily discouraged for production use.
113+
ベーシック認証は、外部クライアントから利用できる認証の代替的な方法です。
114+
OAuth 認証は複雑なので、開発段階ではベーシック認証が便利でしょう。
115+
ただし、ベーシック認証ではすべてのリクエストにおいてユーザー名とパスワードを送る必要があり、
116+
本番の環境で利用することは超非推奨です。
124117

125-
Basic authentication uses [HTTP Basic Authentication][http-basic] (published as
126-
RFC2617) and requires installing the [Basic Auth plugin][basic-auth-plugin].
118+
ベーシック認証は、 [HTTP Basic Authentication][http-basic] (published as RFC2617) を利用しており [Basic Auth plugin][basic-auth-plugin] プラグインの有効化が必要です。
127119

128-
To use Basic authentication, simply pass the username and password with each
129-
request through the `Authorization` header. This value should be encoded (using base64 encoding) as per
130-
the HTTP Basic specification.
120+
ベーシック認証の利用時、ユーザー名とパスワードは各リクエストの `Authorization` ヘッダーを通じて渡します。
121+
この値は、HTTP Basic 認証の仕様に従い、base64 でエンコードされるべきです。
131122

132-
This is an example of how to update a post, using Basic authentication, via the WordPress HTTP API:
123+
以下は、ベーシック認証による、WordPress のHTTP API を使った投稿の更新の例です。
133124

134125
```php
135126
$headers = array (

0 commit comments

Comments
 (0)