Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VI-252] MAP SecurityToken duration validation #19635

Closed
wants to merge 4 commits into from

Conversation

bramleyjl
Copy link
Contributor

@bramleyjl bramleyjl commented Nov 26, 2024

Summary

  • Updates MAP STS service to validate the expiration time of the returned token; tokens valid for more than 900 seconds are considered invalid and will result in a 502 bad gateway error if requested through the MAP services controller.

Related issue(s)

Testing done

  • New code is covered by unit tests
  • Create an STS token for a MAP token request & make the request: locahost:3000/v0/map_services/chatbot/token - you should receive a 200 response & a token
  • Testing behavior on localhost is controlled through vets-api-mockdata file - vets-api-mockdata/map/secure_token_service/token.yml
  • Update the mockdata expires_in value to greater than 900 & re-request the token - you should receive a 502 Bad Gateway error

Screenshots

image

What areas of the site does it impact?

MAP STS requests

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Requested Feedback

(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?

@bramleyjl bramleyjl force-pushed the VI-252_security_token_logs branch from 5baf574 to 0f749ed Compare December 2, 2024 20:32
@va-vfs-bot va-vfs-bot temporarily deployed to VI-252_security_token_logs/main/main December 2, 2024 20:50 Inactive
@bramleyjl bramleyjl marked this pull request as ready for review December 2, 2024 20:53
@bramleyjl bramleyjl requested a review from a team as a code owner December 2, 2024 20:53
@bramleyjl bramleyjl changed the title [VI-252] MAP SecurityToken event log updates [VI-252] MAP SecurityToken duration validation Dec 3, 2024
@@ -66,6 +66,10 @@ def client_assertion_patient_id_type
'icn'
end

def max_token_duration
900
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we make this 900.seconds? just so it's clear

rescue Errors::InvalidTokenDurationError => e
raise e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think you need to rescue and re-raise here. This should get rescued in the token method

Comment on lines 60 to 63
if response_body['expires_in'].to_i > config.max_token_duration
raise Errors::InvalidTokenDurationError,
"#{config.logging_prefix} token failed, token duration exceeds maximum"
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move this check to a separate method? I think it would make it a bit easier to read

@bramleyjl
Copy link
Contributor Author

Scope has changed enough that I'm closing this ticket and opening a different PR here: #19907

@bramleyjl bramleyjl closed this Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants