Node.jsアプリケーションおよびSDKの確認
解決策のこのセクションでは、次の操作を行います。
-
Node.js Webアプリケーションの動作とコードの確認
-
Node.js WebアプリケーションがOracle Identity Cloud Serviceに対して開始する、成功したログイン試行および失敗したログイン試行に関連する診断データをチェックします
Node.jsアプリケーションの動作の確認
Node.js Webアプリケーションの動作は、認可コード付与タイプによって定義された3-legged認証フローに従います。
アプリケーションおよびOracle Identity Cloud ServiceがWebブラウザを使用して実行するすべてのリクエスト、レスポンスおよびリダイレクトを確認するには、ブラウザの開発者モードを有効にします。このソリューションはGoogle Chromeを使用します。
ブラウザの開発者ログには、次のイベントフローが表示されます。
-
/auth/oracle
リソースをリクエストすると、WebブラウザはNode.js Webアプリケーションからリダイレクト・レスポンスを受信します。Request URL: http://localhost:3000/auth/oracle Request Method: GET Status Code: 302 Found Response Headers Location: https://idcs-1234.identity.domain.com/oauth2/v1/authorize?client_id=123456789abcdefghij&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&response_type=code&scope=openid&state=1234
-
Oracle Identity Cloud Serviceは、認可コード・リクエストを受信し、「サインイン」ページを表示します。
Request URL: https://idcs-1234.identity.domain.com/oauth2/v1/authorize?client_id=123456789abcdefghij&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&response_type=code&scope=openid&state=1234Request Method: GET Status Code: 303 See Other Response Headers Location: https://idcs-abcd1234.identity.domain.com/ui/v1/signin Set-cookie: ORA_OCIS_REQ_1=[value has been omitted for readability]
-
Oracle Identity Cloud Serviceにサインインします。Oracle Identity Cloud Serviceは、WebブラウザをNode.js WebアプリケーションのコールバックURLにリダイレクトします。
Request URL: http://localhost:3000/callback?code=[value has been omitted for readability]&state=1234 Request Method: GET Status Code: 302 Found Response Hearders Location: /auth.html Set-Cookie: idcs_user_assertion=[value has been omitted for readability]
この例では、コールバックURLによって、アクセス・トークンがCookieとして設定された/auth.html
ページにWebブラウザがリダイレクトされます。
この時点で、アプリケーションはpassport.authenticate()
メソッドを使用してローカルで認証し、リクエストを/home
ルートに転送します。
Request URL: http://localhost:3000/home
Request Method: GET
Status Code: 200 OK
Response Headers
Cookie:
connect.sid=[value has been omitted for readability]
アプリケーションおよびSDKログの確認
アプリケーションは、情報をコマンドライン・ウィンドウに記録します。SDKログを有効にすることもできます。
Using ClientId=123456789abcdefghij
Server started on port 3000
---Resource: /auth/oracle -- Logging in ----------------------------------
authZurl=https://idcs-abcd1234.identity.domain.com/oauth2/v1/authorize?client_id=123456789abcdefghij&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&response_type=code&scope=urn%3Aopc%3Aidm%3At.user.me%20openid&state=1234
---Resource: /callback -- Exchanging authzcode for a token ---------------------
authZcode=[value has been omitted for readability]
result.access_token = [value has been omitted for readability]
result.id_token = [value has been omitted for readability]
---Resource: /auth -- passport.authenticate ---------------------
---function ensureAuthenticated() -- Validating user logged in ---------------------
req.user=[The JSON object as String - value has been omitted for readability]
---Resource: /home -- Rendering home ---------------------
auth.js
ファイルを開き、必要に応じてLogLevel
の値をdebug
またはtrace
に置き換えます。- ファイルを保存し、Node.jsサーバーを再起動します。
診断データのチェック
Node.js WebアプリケーションがOracle Identity Cloud Serviceに対して開始するログイン試行の成功と失敗の両方が、Oracle Identity Cloud Serviceの診断ログ・ファイルに登録されます。
- Oracle Identity Cloud Serviceコンソールにサインインします。
- コンソールで、ナビゲーション・ドロワーを開き、「設定」、「診断」の順にクリックします。
- 診断タイプとして「アクティビティ・ビュー」を選択し、「保存」をクリックします。
- Oracle Identity Cloud Serviceからサインアウトします。
Oracle Identity Cloud Serviceは、次の15分間の診断データを取得します。
-
このソリューションの「Node.jsアプリケーションの実行」トピックのステップを完了して、Node.js Webアプリケーションの「ログイン」ページを表示します。
-
赤い「Oracle」アイコンをクリックします。
-
サインインを正常に試行するには、Oracle Identity Cloud Serviceの「サインイン」ページに不正なユーザー名またはパスワードを入力します。
-
正常にサインインするには、正しいユーザー名とパスワードを入力します。
-
Node.js Webアプリケーションを使用して、Oracle Identity Cloud Serviceからサインアウトします。
-
Oracle Identity Cloud Serviceコンソールに再度サインインします。
-
Oracle Identity Cloud Serviceコンソールで、ナビゲーション・ドロワーを開き、「レポート」、「診断データ」の順にクリックします。
-
時間範囲に「15分」、ログ・タイプに「アクティビティ・ビュー」、レポート形式に「CSV」を選択し、「レポートのダウンロード」をクリックします。
診断ログ・ファイルには、Oracle Identity Cloud Serviceにサインインするユーザーに関する次のような情報が含まれます。
Message: ID Token will be signed with User Tenant:idcs-abcd1234 Resource Tenant:idcs-abcd1234, clientId=123456789abcdefghij
Component: OAuth
Timestamp: [Date]
Actor ID: your.email@domain.com
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"request":{"tenant":"idcs-abcd1234","grant types":"authorization_code","scopes":["urn:opc:idm:t.user.me"]},"user":{"id":"111111","name":"your.email@domain.com","tenant":"idcs-abcd1234","auth-type":"PASSWORD"},"client":{"id":"123456789abcdefghij","name":"Sample App","tenant":"idcs-abcd1234","auth-type":"PASSWORD"},"environment":{"isCSR":"false","onBehalfOfUser":"false"},"response":{"result":"ALLOWED","scopes":["urn:opc:idm:t.user.me"],"custom-claims":{"clientAppRoles":["Authenticated Client","Me"],"userAppRoles":["Authenticated","Global Viewer","Identity Domain Administrator"],"user_isAdmin":"true"}}}
Component: Authorization/getAllowedScopes
Timestamp: [Date]
Actor ID: your.email@domain.com
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"Message":"SSO SignOn Policy evaluation result for user : 11111 is : effect:ALLOW,authenticationFactor:IDP,allowUserToSkip2FAEnrolment:false,2FAFrequency:SESSION,reAuthenticate:false,trustedDevice2FAFrequency:
Component:
Timestamp:
Actor ID:
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: [PolicyEngineUtil.evaluatePolicy] Evaluating Default Sign-On Policy
Component: PolicyEngine
Timestamp: [Date]
Actor ID: uiSignin
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: [PolicyEngineUtil.evaluateRule] Evaluating MFA rule
Component: PolicyEngine
Timestamp: [Date]
Actor ID: uiSignin
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: [PolicyEngineUtil.evaluatePolicy] Evaluating Default Authentication Target App Policy
Component: PolicyEngine
Timestamp: [Date]
Actor ID: idcssso
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"password":"********","authFactor":"USERNAME_PASSWORD","device":"{\"currentTime\":\"[date]",\"screenWidth\":1920,\"screenHeight\":1080,\"screenColorDepth\":24,\"screenPixelDepth\":24,\"windowPixelRatio\":1,\"language\":\"en\",\"userAgent\":\"Mozilla\/5.0 (Windows NT 10.0
Component:
Timestamp:
Actor ID:
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"Message":"No session found so need to collect credentials","Redirecting to Login URL: ":https://idcs-abcd1234.identity.domain.com/ui/v1/signin}
Component: SSO
Timestamp: [Date]
Actor ID: Unauthenticated
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: [PolicyEngineUtil.evaluatePolicy] Evaluating Default Identity Provider Policy
Component: PolicyEngine
Timestamp: [Date]
Actor ID: Unauthenticated
---------------------------------------------------------------
Message: Authorization Request, received parameters: scope[urn:opc:idm:t.user.me openid] response_type[code] state[1234] redirect_uri[http://localhost:3000/callback] client_id[123456789abcdefghij]
Component: OAuth
Timestamp: [Date]
Actor ID: Unauthenticated
最新のログがファイルの先頭に表示されます。