ウェブサービスを使用する

提供:MoodleDocs
2013年12月4日 (水) 19:15時点におけるMitsuhiro Yoshida (トーク | 投稿記録)による版 (→‎サービスの作成)
移動先:案内検索


作成中です - Mitsuhiro Yoshida (トーク)

このドキュメントでは、ユーザがサービスにアクセスできるよう管理者がウェブサービスを設定する方法を説明します。サービスにアクセスするため、それぞれのユーザには特定のおよびユニークなセキュリティキー (「トークン」として知られています) があります。

ウェブサービスを有効にする

ウェブサービスを有効にする
  1. 「設定 > サイト管理 > 拡張機能」にアクセスしてください。
  2. 「ウェブサービスを有効にする」をチェックした後、「変更を保存する」ボタンをクリックしてください。

注意: セキュリティ上の理由から、あなたが使用したい場合のみ、ウェブサービスを有効にしてください。

プロトコルを有効にする

ファイル:Enable protocol.jpg
プロトコルを有効にする

通常、ユーザが使用したい外部アプリケーションが有効にすべきプロトコルを指示します。

  1. 「管理 > サイト管理 > プラグイン > ウェブサービス > プロトコル管理」にアクセスしてください。
  2. 必要に応じて、プロトコル (SOAP, REST, XMLRPC, AMF, ...) を有効にしてください。

ウェブサービス関数ドキュメンテーションを有効にする

ファイル:Security keys and documentation.jpg
セキュリティキーページのドキュメンテーションリンク

プロトコル管理ページにてウェブサービス関数ドキュメンテーションを有効にすることにより、それぞれのユーザはセキュリティキーページでユーザ固有のウェブサービスドキュメンテーションを利用できるようになります。このオプションは主にウェブサービスクライアント開発者に有用です。誰もウェブサービスクライアントを作成していない場合、この機能を有効にする必要はありません。

サービスの作成

あなたの要求に事前構築のウェブサービスが合致しない場合、カスタムサービスを作成することができます。例) そのサービス経由でどのような標準ウェブサービス関数が利用できるか選択します。

あなたが露出する必要のある特定の関数のみを有効にすることができます。そのため、セキュリティ上の危険にさらされることはありません。

ファイル:Create a service.jpg
サービスの作成
  1. 「管理 > サイト管理 > プラグイン > ウェブサービス > 外部サービス」にアクセスしてください。
  2. 「追加」リンクをクリックしてください。
    • 認証済みユーザのみ - 有効にした場合、あなたは手動で認証ユーザを選択する必要があります。そうでない場合、そうでない場合、適切なパーミッションのユーザすべてが許可されます。
    • 必須ケイパビリティ - If enabled, any user accessing the web service will be checked against this selected capability. (This is just an additional optional security layer.)
  3. 名称を入力して、有効にしてください。
  4. 「サービスを追加する」ボタンをクリックしてください。

サービスに関数を追加する

ファイル:Select a web service function.jpg
Adding functions to the service

Your service is currently empty and doesn't do anything. Web service functions need to be added. Your choice will be dictated by what you allow the external application to do. For this example, select 'Create group'.

  1. Click 'Add functions' link
  2. Select 'create group' function and click the 'Add functions' button

You should be back to the service functions list. 'Required capabilities' are indicated for each function. Users need the required capabilities to run a function. The function descriptions in the API Documentation can also give you more information about the required capabilities (Settings > Site administration > Plugins > Web services > API Documentation).

ケイパビリティを有効にする

The final step is to grant appropriate permissions. The following capabilities should be allowed:

Once done, the web service should be set up. Users should be able to obtain a personal security key.

代替設定

特定ユーザのみ認証する

  1. Settings > Site Administration > Plugins > Web services > External Services
  2. Select Authorised users link (the service must have been set as Authorised users only in the Edit link)
  3. Select some users and click Add

Moodle indicates if some capabilities need to be assigned to an authorised user. Moreover if you click on the authorised user fullname, you can set up some specific options: IP restriction and Valid until.

トークンを作成する

This feature allows you to create a token for specific user. It can be useful if a user doesn't have the moodle/create:token capability. This is also the only way to create a token for an administrator. For security reason, tokens are not automatically generated in the administrator security keys page.

  1. Settings > Site Administration > Plugins > Web services > Manage tokens
  2. Click on Add
  3. Select the created user and service
  4. Click on Saves changes

As you created a token for this user, you do not need to assign "moodle/webservice:createtoken" to him/her. Finally, note that, as for authorised users, you can also set IP restriction and Valid until on a token.

関連情報