OAuthリソース所有者のパスワード資格証明
OAuth ROPC権限を使用して保護されたREST APIの起動をサポートするには、OAUTH_RESOURCE_OWNER_PASSWORD_CREDENTIALS管理対象セキュリティ・ポリシーを使用します。 接続定義に必要なセキュリティ・ポリシーをカスタマイズできます。
概要
OAuthリソース所有者のパスワード資格証明セキュリティ・ポリシーでは、アクセス・トークンを取得するためのRESTコールを行い、アクセス・トークンを使用してAPIをコールします。
リソース所有者はその資格証明をクライアントと共有するため、このポリシーは、リソース所有者とクライアントの間に高い信頼度があるときに使用されます。 Oracle Integrationは、資格証明がボールトに安全に格納されるようにします。
このポリシーのデフォルト実装はRFC 6749です。 ただし、実装はRFCが示す方法とは異なる場合があります。 したがって、RFC 6749準拠ポリシーを拡張して、1つ以上のステップをオーバーライドします。 たとえば:
- アクセス・トークンを取得するには、認可サーバーに特定の形式でリクエストを指定する必要があります。 RFC 6749はフォーマットを定義します。 ただし、プロバイダごとに異なる形式が必要になる場合があります。 たとえば、サーバーが認可ヘッダー以外の追加情報を必要としたり、サーバーがリクエストをJSON本文の一部にする必要がある場合があります。 認可サーバーのドキュメントを確認して、必要な形式を確認します。
- アクセス・トークンに対して有効なリクエストを行うと、認可サーバーはなんらかの本文で200レスポンスを返します。 RFC 6749は、レスポンスの形式を指定します。 ただし、一部の認可サーバーはレスポンスをカスタマイズします。 たとえば、レスポンスはJSONではなくXMLです。 多くの場合、レスポンスは、多くのメタデータとネストされたトークンを含むネストされたJSONです。 レスポンスでアクセス・トークンとその有効期限を検索できる必要があります。 認可サーバーのドキュメントを確認して、レスポンスの形式を理解します。
OAuthリソース所有者のパスワード資格証明ポリシーをドキュメントに追加するには、使用可能な認証スキーム・テンプレートを使用します。 「新規接続定義の実装」を参照してください。
セキュリティ・プロパティ
このセキュリティ・ポリシーを使用する接続定義は、securityPropertiesセクションで次のプロパティを定義します。 「接続プロパティおよびサンプル・コード」を参照してください。
name, displayName, shortDescription列およびdescription列の値は、アダプタ定義ドキュメントにセキュリティ・ポリシーを挿入したときに表示されるデフォルト値を示します。 これらの値は、必要に応じて更新できます。
| name | displayName | shortDescription | description | データ型 | 必須 |
|---|---|---|---|---|---|
|
|
|
|
|
String |
はい |
|
|
|
|
|
パスワード |
はい |
|
|
|
|
|
String |
はい |
|
|
|
|
|
String |
いいえ |
|
|
|
|
|
String |
はい |
|
|
|
|
|
パスワード |
はい |
セキュリティ・ポリシーの拡張
必要に応じて、セキュリティ・ポリシーを拡張します。
セキュリティ・ポリシーは、HTTPリクエストの構造を定義します。 このセキュリティ・ポリシーのデフォルトの実装はRFC 6749です。 ただし、実装はRFCが示す方法とは異なる場合があります。 アダプタを作成するアプリケーションが標準セキュリティ・ポリシーをサポートしているが、追加情報が必要な場合は、RFC 6749準拠ポリシーを拡張して、1つ以上のステップをオーバーライドできます。 セキュリティ・ポリシーを拡張する場合は、リクエストの構造を変更します。
- OAuthプロバイダのドキュメントを読み、次の情報を収集します。
収集する情報 説明 AccessTokenRequest認可サーバーでは、
AccessTokenRequestが必要です。 必要な情報、および情報を承認サーバーに送信するメソッドを決定します。次の例は、RFC 6749に従ってトークン・リクエストにアクセスするためのサンプル・コードです:
{ "method": "POST", "uri": "<oauth.access.token.uri>", "params": { "template": {}, "query": { } }, "headers": { "Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json", "Authorization" : "Basic " + ((.securityProperties.oauth.client.id)+\":\"+(.securityProperties.oauth.client.secret") | @base64) }, "body": "grant_type=password&client_id=&client_secret=&username=&password=" }AccessTokenRequestのレスポンス認可サーバーがアクセス・トークン・リクエストへのレスポンスを返す方法、およびレスポンスで返される情報を確認します。 レスポンスのタイプはプロバイダごとに異なります。 ほとんどのプロバイダは、次の例に示すように、アクセス・トークン・レスポンスを返します:
{ "token_type": "Bearer", "access_token": "the access token value" }認可サーバーで想定される
RefreshTokenRequest必要な情報と、その情報を承認サーバーに送信する方法を決定します。
次のコード・スニペットは、RFC 6749に従ったアクセス・トークンの使用方法を示しています:
{ "method": "POST", "uri": "<oauth.access.token.uri>", "params": { "template": {}, "query": { } }, "headers": { "Content-Type": "application/x-www-form-urlencoded", "Authorization" : "Basic " + ((.securityProperties.oauth.client.id)+\":\"+(.securityProperties.oauth.client.secret") | @base64) }, "body": "grant_type=refresh_token&refresh_token=${refresh_token} }RefreshTokenRequestのレスポンス認可サーバーがリフレッシュ・トークン・リクエストへのレスポンスを返す方法と、レスポンスで返される情報を確認します。
{ "token_type": "Bearer", "access_token": "the access token value" }アプリケーションがアクセス・トークンをリクエストとともに送信することを想定するメソッド
多くのアプリケーションでは、アクセス・トークン以外の追加情報を求めています。-H "Authorization: Bearer [access_token]" - OAuthフローの1つ以上のステップを変更して、必要に応じて管理対象セキュリティ・ポリシーを拡張します。
サンプル・コード: OAuthのリソース所有者のパスワード資格証明
この例では、次のセキュリティ・プロパティにデフォルト値があり、非表示になっています:
oauth.access.token.uri: デフォルト値はhttps://login.eloqua.com/auth/oauth2/tokenですoauth.scope: デフォルト値はhttps://www.googleapis.com/auth/driveですclientAuthentication: デフォルト値はclient_credentials_as_headerですoauth.request.content.type: デフォルト値はapplication/x-www-form-urlencodedです
"securityPolicies": [
{
"type": "managed",
"policy": "OAUTH_RESOURCE_OWNER_PASSWORD_CREDENTIALS",
"description": "OAuth Resource Owner Password Credentials",
"displayName": "OAuth Resource Owner Password Credentials",
"scope": "ACTION",
"securityProperties": [
{
"name": "oauth.client.id",
"displayName": "Client Id",
"description": "Client Id",
"shortDescription": "Client Id",
"required": true,
"hidden": false
}, {
"name": "oauth.client.secret",
"displayName": "Client Secret",
"description": "Client Secret",
"shortDescription": "Client Secret",
"required": true,
"hidden": false
}, {
"name": "oauth.access.token.uri",
"default": "https://login.eloqua.com/auth/oauth2/token",
"required": false,
"hidden": true
}, {
"name": "oauth.scope",
"default": "",
"required": false,
"hidden": false
}, {
"name": "username",
"displayName": "Username",
"description": "The resource owner user name.",
"required": true,
"hidden": false
}, {
"name": "password",
"displayName": "Password",
"description": "The resource owner user password.",
"required": true,
"hidden": false
}, {
"name": "oauth.request.content.type",
"default": "application/x-www-form-urlencoded",
"required": false,
"hidden": true
}, {
"name": "clientAuthentication",
"default": "client_credentials_as_header",
"required": false,
"hidden": true
}
]
}
],
"test": "flow:TestConnectionFlow"
サンプル・コード: OAuthリソース所有者のパスワード資格証明、拡張
次のコード・サンプルは、拡張コード認可ポリシーを示しています:
"securityPolicies": [
{
"type": "managed",
"policy": "OAUTH_RESOURCE_OWNER_PASSWORD_CREDENTIALS",
"description": "OAuth Resource Owner Password Credentials Policy",
"displayName": "OAuth Resource Owner Password Credentials Policy",
"scope": "ACTION",
"securityProperties": [
{
"name": "oauth.client.id",
"displayName": "Client Id",
"description": "Client Id",
"shortDescription": "Client Id",
"required": true,
"hidden": false
}, {
"name": "oauth.client.secret",
"displayName": "Client Secret",
"description": "Client Secret",
"shortDescription": "Client Secret",
"required": true,
"hidden": false
}, {
"name": "oauth.access.token.uri",
"default": "https://login.ABCXYZ.com/auth/oauth2/token",
"required": false,
"hidden": true
}, {
"name": "oauth.scope",
"default": "",
"required": false,
"hidden": false
}, {
"name": "username",
"displayName": "Username",
"description": "The resource owner user name.",
"required": true,
"hidden": false
}, {
"name": "password",
"displayName": "Password",
"description": "The resource owner user password.",
"required": true,
"hidden": false
}, {
"name": "oauth.request.content.type",
"default": "application/x-www-form-urlencoded",
"required": false,
"hidden": true
}, {
"name": "clientAuthentication",
"default": "client_credentials_as_header",
"required": false,
"hidden": true
}
],
"authExtension": {
"accessTokenRequest": {
"method": "POST",
"uri": "<authorization_uri>",
"params": {
"template": {
},
"query": {
"client_id": "[your_client_id]",
"client_secret": "[your_client_secret]",
"grant_type": "password"
}
},
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic " + ({.securityProperties.oauth.client.id}+\":\"+{.securityProperties.oauth.client.secret"}) | @base64)
},
"body": "false"
},
"refreshTokenRequest": {
"method": "POST",
"uri": "<access_token_uri>",
"params": {
"template": {
},
"query": {
"refresh_token": "${refresh_token}",
"client_id": "[your_client_id]",
"client_secret": "[your_client_secret]",
"grant_type": "refresh_token"
}
},
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"body": "false"
},
"fetchRules": {
"access_token": "access.[tT]oken",
"refresh_token": "refresh.[tT]oken",
"expiry": "expires.*",
"token_type": "token.?[tT]ype"
},
"accessTokenUsage": {
"headers": {
"Authorization": "Bearer : ${access_token}"
}
}
}
}
],
"test": "flow:testConnectionFlow"
}