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

- make sure that we can generate offline tokens for Epic providers (u… #190

Merged
merged 3 commits into from
Jul 21, 2023

Conversation

AnalogJ
Copy link
Member

@AnalogJ AnalogJ commented Jul 20, 2023

…sing dynamic client registration - https://fhir.epic.com/Documentation?docId=Oauth2&section=Standalone-Oauth2-OfflineAccess-0)

  • when SourceCredential is sent to the CreateSource API, we'll check if dynamic client regirstion is enabled. If it is, we'll use this token to register a new client, store the client information, and geneate a new Access Token using the key pair associated with this newly registered client.
  • added additional fields to SourceCredential table (registration_endpoint, dynamic_client_registration_mode, dynamic_client_jwks, dynamic_client_id)
  • renamed RefreshTokens to SetTokens in SourceCredential model - to have consistent naming
  • added IsDynamicClient and RefreshDynamicClientAccessToken methods to SourceCredential Model

fixes #178

TODO:

  • Experiment with PKCE support
  • Convert new Epic app to Production mode (after verifying)
  • Wait 24h for distribution
  • Update Epic Production Client ID in Lighthouse
  • Deploy Lighthouse Production
  • Populate Lighthouse Production Search
  • Make sure that SourceCredential is correctly updated in DB after sync.
  • Merge this PR - breaking change

…sing dynamic client registration - https://fhir.epic.com/Documentation?docId=Oauth2&section=Standalone-Oauth2-OfflineAccess-0)

- when SourceCredential is sent to the CreateSource API, we'll check if dynamic client regirstion is enabled. If it is, we'll use this token to register a new client, store the client information, and geneate a new Access Token using the key pair associated with this newly registered client.
- added additional fields to SourceCredential table (registration_endpoint, dynamic_client_registration_mode, dynamic_client_jwks, dynamic_client_id)
- renamed RefreshTokens to SetTokens in SourceCredential model - to have consistent naming
- added IsDynamicClient and RefreshDynamicClientAccessToken methods to SourceCredential Model

fixes #178
"client_id": {s.DynamicClientId},
}

tokenResp, err := http.PostForm(s.TokenEndpoint, postForm)

Check failure

Code scanning / CodeQL

Uncontrolled data used in network request Critical

The
URL
of this request depends on a
user-provided value
.
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", sourceCred.AccessToken))

registrationResponse, err := http.DefaultClient.Do(req)

Check failure

Code scanning / CodeQL

Uncontrolled data used in network request Critical

The
URL
of this request depends on a
user-provided value
.
Added an update source method.
After sync, if sourcecredential access token/refresh token has been updated make sure we store it int he database.
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 12.71% and project coverage change: +0.02 🎉

Comparison is base (be30cb0) 9.71% compared to head (07d01fc) 9.74%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff            @@
##            main    #190      +/-   ##
========================================
+ Coverage   9.71%   9.74%   +0.02%     
========================================
  Files        221     222       +1     
  Lines      27017   27244     +227     
  Branches     450     450              
========================================
+ Hits        2625    2654      +29     
- Misses     24255   24446     +191     
- Partials     137     144       +7     
Flag Coverage Δ
unittests 9.74% <12.71%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
backend/pkg/database/sqlite_repository.go 67.82% <0.00%> (-2.05%) ⬇️
backend/pkg/models/source_credential.go 0.00% <0.00%> (ø)
backend/pkg/web/handler/source.go 9.38% <0.00%> (-6.16%) ⬇️
...s-connected/medical-sources-connected.component.ts 14.54% <ø> (ø)
frontend/src/app/models/fasten/source.ts 0.00% <ø> (ø)
backend/pkg/jwk/jwk_utils.go 58.00% <58.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@AnalogJ AnalogJ merged commit ae4903e into main Jul 21, 2023
10 checks passed
@AnalogJ AnalogJ deleted the epic_dynamic_client_registration branch July 21, 2023 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when bulk importing from source
2 participants