Node.js 애플리케이션 및 SDK 검토
솔루션의 이 섹션에서 다음을 수행합니다.
-
Node.js 웹 응용 프로그램의 동작 및 코드 검사
-
Node.js 웹 애플리케이션이 Oracle Identity Cloud Service로 시작하는 성공 및 실패한 로그인 시도와 연관된 진단 데이터를 확인합니다.
Node.js 애플리케이션의 동작 검토
Node.js 웹 애플리케이션의 동작은 권한 부여 코드 권한 부여 유형으로 정의된 3단계 인증 플로우를 따릅니다.
웹 브라우저를 사용하여 애플리케이션 및 Oracle Identity Cloud Service가 수행하는 요청, 응답 및 재지정을 모두 확인하려면 브라우저의 개발자 모드를 사용으로 설정합니다. 이 솔루션은 Google Chrome을 사용합니다.
브라우저의 개발자 로그에 다음과 같은 이벤트 흐름이 표시되어야 합니다.
-
/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.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는 웹 브라우저를 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]
응용 프로그램 및 SDK 로그 검사
응용 프로그램이 명령행 window에 정보를 기록합니다. 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 웹 애플리케이션이 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 애플리케이션 실행 항목의 단계를 완료합니다.
-
빨간색 Oracle 아이콘을 누릅니다.
-
사인인 시도에 실패하려면 Oracle Identity Cloud Service 사인인 페이지에 잘못된 사용자 이름 또는 비밀번호를 입력합니다.
-
성공적으로 사인인하려면 올바른 사용자 이름과 비밀번호를 입력하십시오.
-
Node.js 웹 애플리케이션을 사용하여 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
파일의 맨 위에 가장 최근 로그가 표시됩니다.