Node.js 애플리케이션 및 SDK 검사

이 솔루션 섹션에서는 다음 작업을 수행할 수 있습니다.

  • Node.js 웹 애플리케이션의 동작 및 코드 검사

  • Node.js 웹 애플리케이션이 Oracle Identity Cloud Service 에 시작한 성공 및 실패한 로그인 시도와 연관된 진단 데이터를 확인합니다.

Node.js 애플리케이션 동작 검사

Node.js 웹 응용 프로그램의 동작은 권한 부여 코드 권한 부여 유형으로 정의된 규정된 인증 플로우 3개를 따릅니다.

모든 요청, 응답 및 응용 프로그램과 Oracle Identity Cloud Service 이 웹 브라우저를 사용하여 수행되는지 재지정하려면 브라우저의 개발자 모드를 사용으로 설정합니다. 이 솔루션은 Google Chrome을 사용합니다.

  1. Node.js 웹 애플리케이션을 실행합니다.
  2. Google Chrome 웹 브라우저를 열고 http://localhost:3000 URL에 액세스하고 로그인 을 누릅니다.
  3. F12 을 누르고 네트워크 탭을 선택한 다음 로그 보존 체크 박스를 선택합니다.
    애플리케이션과 Oracle Identity Cloud Service 간의 모든 통신을 보려면 이 체크박스를 선택합니다.
  4. 로그인 페이지에서 오른쪽에 나타나는 빨간색 Oracle 아이콘을 누르거나 와 함께 로그인할 수 있습니다.

브라우저의 개발자 로그에는 다음 이벤트 흐름이 표시되어야 합니다.

  1. /auth/oracle 리소스를 요청하고 웹 브라우저가 Node.js 웹 애플리케이션에서 재지정 응답을 수신합니다.

    Request URL: http://localhost:3000/auth/oracle
    Request Method: GET
    Status Code: 302 Found
     
    Response Headers
    Location: https://idcs-1234.identity.oraclecloud.com/oauth2/v1/authorize?client_id=123456789abcdefghij&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&response_type=code&scope=openid&state=1234
  2. Oracle Identity Cloud Service 권한 부여 코드 요청을 수신하고 사인인 페이지를 제공합니다.

    Request URL: https://idcs-1234.identity.oraclecloud.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.oraclecloud.com/ui/v1/signin
    Set-cookie: ORA_OCIS_REQ_1=[value has been omitted for readability]
  3. Oracle Identity Cloud Service 에 사인인합니다. Oracle Identity Cloud Service - 웹 브라우저를 Node.js 웹 애플리케이션의 콜백 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이 쿠키로 설정된 사용자 액세스 토큰을 사용하여 웹 브라우저를 /auth.html 페이지로 재지정합니다.

이때 응용 프로그램은 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]

Node.js 애플리케이션 코드 검사

Oracle Identity Cloud Service 에 사인인하고 Node.js 웹 응용 프로그램의 콜백 URL로 리디렉션된 후 Node.js 웹 응용 프로그램은 명령행 창에서 정보를 기록합니다.

req.user={"name":"your.email@domain.com","displayName":"Your Name","id":"111111111111","tenant":"idcs-abcd1234","groups":[{"name":"Group 1","id":"2222222222222","location":"https://idcs-abcd1234.identity.oraclecloud.com/admin/v1/Groups/7787fbab31b34e08b39cdeedf1f4233a"}],"appRoles":[{"name":"Identity Domain Administrator","id":"333333333333333","location":"https://idcs-abcd1234.identity.oraclecloud.com/admin/v1/AppRoles/444444444444444","appName":"SampleApp","appID":"SampleAppId"}],"client":{"client_name":"Sample Apps","client_id":"555555555555","client_tenantname":"idcs-abcd1234","scope":"openid","audience":"https://idcs-abcd1234.identity.oraclecloud.com"}}

ensureAuthenticated() 메소드는 Oracle Identity Cloud Service 에 사인인된 사용자를 나타내는 JSON 객체에 대한 정보를 기록합니다.

ensureAuthenticated req.user={"name":"your.email@domain.com","displayName":"Your Name","id":"111111111111","tenant":"idcs-abcd1234","groups":[{"name":"Group 1","id":"2222222222222","location":"https://idcs-abcd1234.identity.oraclecloud.com/admin/v1/Groups/7787fbab31b34e08b39cdeedf1f4233a"}],"appRoles":[{"name":"Identity Domain Administrator","id":"333333333333333","location":"https://idcs-abcd1234.identity.oraclecloud.com/admin/v1/AppRoles/444444444444444","appName":"SampleApp","appID":"SampleAppId"}],"client":{"client_name":"Sample Apps","client_id":"555555555555","client_tenantname":"idcs-abcd1234","scope":"openid","audience":"https://idcs-abcd1234.identity.oraclecloud.com"}}

진단 데이터를 확인하십시오.

Node.js 웹 애플리케이션이 Oracle Identity Cloud Service 에 시작한 성공 및 실패 로그인 시도 모두 Oracle Identity Cloud Service 진단 로그 파일에 등록됩니다.

  1. Oracle Identity Cloud Service 에 사인인합니다.
  2. Identity Cloud Service 콘솔에서 탐색 드로어 를 확장하고 설정 을 누른 다음 진단 을 누릅니다.
  3. 진단 유형으로 작업 뷰 를 선택하고 저장 을 누릅니다.
  4. Oracle Identity Cloud Service 에서 사인아웃합니다.

Oracle Identity Cloud Service - 다음 15 분에 대한 진단 데이터를 캡처합니다.

  1. 이 솔루션의 Node.js 응용 프로그램 실행 항목에 있는 단계를 완료하여 Node.js 웹 응용 프로그램의 로그인 페이지를 표시합니다.

  2. 오른쪽에 나타나는 빨간색 Oracle 아이콘을 누르거나 으로 로그인할 수 있습니다.

  3. 사인인 시도를 실패하면 Oracle Identity Cloud Service 사인인 페이지에 잘못된 사용자 이름 또는 비밀번호를 입력합니다.

  4. 성공적으로 사인인하려면 올바른 사용자 이름 및 비밀번호를 입력하십시오.

  5. Node.js 웹 애플리케이션을 사용하여 Oracle Identity Cloud Service 에서 사인아웃합니다.

  6. Oracle Identity Cloud Service 에 다시 사인인합니다.

  7. Identity Cloud Service 콘솔에서 탐색 전환기를 확장하고 보고서 를 누른 다음 진단 데이터 를 누릅니다.

  8. 시간 범위의 경우 15-Minute, 로그 유형에 대한 작업 뷰 , 보고서 형식에 대한 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@example.com
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"request":{"tenant":"idcs-abcd1234","grant types":"authorization_code","scopes":["urn:opc:idm:t.user.me"]},"user":{"id":"111111","name":"your.email@example.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@example.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.oraclecloud.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

가장 최근 로그가 파일 상단에 나타납니다.