bcgov / nr-forests-access-management

Authorization solution for BC natural resource sector
Apache License 2.0
8 stars 2 forks source link

Support Forest Client: BC Service Card login issue #1155

Closed MCatherine1994 closed 8 months ago

MCatherine1994 commented 9 months ago

Describe the task Team Alliance is getting bc service card login issue. They found that when try to login using test BC Service Card account, sometimes they will get a read time out error. I found that as well sometimes when using the OIDC debugger tool. And if try to login again, it works fine, the login will be successful.

Image

The original email from Maria is in the screenshot: Image

Acceptance Criteria

Additional context

MCatherine1994 commented 9 months ago

API Lambda logs when bc service card login fail, it generates 2 logs:

1st one: log-events-viewer-result.csv

2st one: log-events-viewer-result (1).csv

Try to login again, and successfully login, it generates 1 more log, and add logs in the last 2:

The last 2 logs with more information: log-events-viewer-result (2).csv log-events-viewer-result (3).csv

The new generated log: log-events-viewer-result (4).csv

Image

MCatherine1994 commented 9 months ago

From the AWS documentation https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html, when Amazon Cognito calls your Lambda function, it must respond within 5 seconds.

When checking the logs in the login failure case, the call to get the bc service card token takes about 3s, in the login successful case, it takes about 0.5s.

code where we make the call: Image

failure case: Image

successful case: Image

So next step we need to contact Wesley and ask about the response time for making the call to https://idtest.gov.bc.ca/oauth2/token

basilv commented 9 months ago

Decided resolution is for the BCSC team to cache (hardcode) our public key in their system, to avoid the ~2 sec key lookup overhead that was causing the Cognito get user info call to our get user info endpoint to timeout after 5 seconds.

I've researched our use of the key and documented it in our secret registry that when we change it we'll need to update the BCSC team.