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

Support multiple, configurable client ids to protect API limits. #18677

Merged
merged 16 commits into from
Oct 24, 2024

Conversation

kjduensing
Copy link
Contributor

@kjduensing kjduensing commented Sep 30, 2024

This work enables different integrations to send their own client number so the upstream API can differentiate traffic and enforce rate limits appropriately.

It looks like this:

classDiagram
  class AuthManager {
    -token_client
    +initialize(int, User)
  }
  AuthManager *-- TokenClient
  class ClaimsService {
    +get_claims()
  }
  ClaimsService o-- AuthManager
  ClaimsController o-- ClaimsService
Loading

It works like this:

sequenceDiagram
RailsRouter ->> ClaimsController: GET claims/
ClaimsController ->> AuthManager: user, client_number
ClaimsController ->> ClaimsService: get_claims()
ClaimsService ->> AuthManager: authorize()
ClaimsService ->> TravelPayAPI: GET /btsss/claims
TravelPayAPI ->> ClaimsService: claims data
ClaimsService ->> ClaimsController: claims data
Loading

Closes department-of-veterans-affairs/va.gov-team#91982

Copy link

github-actions bot commented Oct 9, 2024

1 Warning
⚠️ This PR changes 243 LoC (not counting whitespace/newlines).

In order to ensure each PR receives the proper attention it deserves, we recommend not exceeding
200. Expect some delays getting reviews.

File Summary

Files

  • modules/travel_pay/app/controllers/travel_pay/v0/claims_controller.rb (+4/-8)

  • modules/travel_pay/app/services/travel_pay/appointments_service.rb (+5/-1)

  • modules/travel_pay/app/services/travel_pay/{token_service.rb => auth_manager.rb} (+19/-21)

  • modules/travel_pay/app/services/travel_pay/claims_service.rb (+9/-3)

  • modules/travel_pay/app/services/travel_pay/expenses_service.rb (+5/-1)

  • modules/travel_pay/app/services/travel_pay/token_client.rb (+11/-19)

  • modules/travel_pay/spec/services/appointments_client_spec.rb (+0/-5)

  • modules/travel_pay/spec/services/appointments_service_spec.rb (+8/-9)

  • modules/travel_pay/spec/services/{token_service_spec.rb => auth_manager_spec.rb} (+9/-6)

  • modules/travel_pay/spec/services/claims_client_spec.rb (+0/-5)

  • modules/travel_pay/spec/services/claims_service_spec.rb (+26/-29)

  • modules/travel_pay/spec/services/expenses_client_spec.rb (+0/-5)

  • modules/travel_pay/spec/services/expenses_service_spec.rb (+15/-14)

  • modules/travel_pay/spec/services/token_client_spec.rb (+3/-3)

    Note: We exclude files matching the following when considering PR size:

    *.csv, *.json, *.tsv, *.txt, *.md, Gemfile.lock, app/swagger, modules/mobile/docs, spec/fixtures/, spec/support/vcr_cassettes/, modules/mobile/spec/support/vcr_cassettes/, db/seeds, modules/vaos/app/docs, modules/meb_api/app/docs, modules/appeals_api/app/swagger/, *.bru, *.pdf
    

Big PRs are difficult to review, often become stale, and cause delays.

Generated by 🚫 Danger

LindseySaari
LindseySaari previously approved these changes Oct 9, 2024
Copy link

github-actions bot commented Oct 9, 2024

Backend-review-group approval confirmed.

Copy link
Contributor

@liztownd liztownd left a comment

Choose a reason for hiding this comment

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

I think this mostly makes sense.... I do have some comments, and am curious about next steps re: authenticated sessions per user in addition to per client (but I understand this PR is only in re: the client aspect).

modules/travel_pay/app/services/travel_pay/session.rb Outdated Show resolved Hide resolved
liztownd
liztownd previously approved these changes Oct 24, 2024
Copy link
Contributor

@liztownd liztownd left a comment

Choose a reason for hiding this comment

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

Looks great! I see a few places where you commented out the before do call to allow the token call to go through, not sure if you were leaving the commented code there for a reason or if it can be removed, but not gonna block you for that, so still approved. 🎉

@kjduensing kjduensing merged commit 8e7daa4 into master Oct 24, 2024
24 checks passed
@kjduensing kjduensing deleted the btsss/multi-client-ids branch October 24, 2024 16:48
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.

Allow each client to have own set of credentials
6 participants