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

1. Allow to use well-known standard secrets.json file for storing a private key… #653

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mmusaev
Copy link

@mmusaev mmusaev commented Aug 4, 2023

… for a local development.

  1. Client api application can use appSettings.xxxxx.json and appSettings.yyyyy.json to accommodate various deployment environments, which OKTA's default implementation doesn't accommodate.
  2. Finally, this extensibility prevents null reference exceptions thrown if client app opts to provide a configuration file path.

There are a few things to consider optimizing the code in GetConfigurationOrDefault method:
4. Avoid calling configBuilder.Build() multiple times. Instead, call it once and store the result in a variable, then use that variable to retrieve the sections you need. This will reduce the number of times the configuration is built and improve performance.
5. Consider using AddJsonStream() instead of AddJsonFile() to read the appsettings.json file. This will avoid the overhead of opening and reading the file from disk.
6. Consider removing unnecessary configuration sources, such as AddYamlFile() and AddEnvironmentVariables() - not all applications use them.
7. Implemented the first optimization in the original code section of the GetConfigurationOrDefault method.

Summary

Fixes #

Related to #656

Type of PR

  • Bug Fix (non-breaking fixes to existing functionality)
  • New Feature (non-breaking changes that add new functionality)
  • Documentation update
  • Test Updates
  • Other (Please describe the type)

Test Information

  • My PR required test updates

.NET Version:
Os Version:

Signoff

  • Each commit message explains what the commit does
  • My code is covered by tests if required
  • I checked StyleCop warnings on my code

Obvious Fix

… for a local development.

2. Client api application can use appSettings.xxxxx.json and appSettings.yyyyy.json to accomodate various deployment environments, which OKTA's default implementation doesn't accomodate.
3. Finally this extensbility prevents null reference exceptions thrown if client app opts to provide a configuration file path.

There are a few things to consider to optimize the code in GetConfigurationOrDefault method:
4. Avoid calling configBuilder.Build() multiple times. Instead, call it once and store the result in a variable, then use that variable to retrieve the sections you need. This will reduce the number of times the configuration is built and improve performance.
5. Consider using AddJsonStream() instead of AddJsonFile() to read the appsettings.json file. This will avoid the overhead of opening and reading the file from disk.
6. Consider removing unnecessary configuration sources, such as AddYamlFile() and AddEnvironmentVariables() - not all applications use them.
7.  Implemented the first optimization in the original code section of the GetConfigurationOrDefault method.
@laura-rodriguez
Copy link
Collaborator

laura-rodriguez commented Aug 10, 2023

Hi @mmusaev,

Thanks for your contribution ⭐ ! Our team will review it soon. In the meantime, can you please sign the CLA? Check out the contribution guidelines to learn more.

Internal Ref: OKTA-637420

@mmusaev
Copy link
Author

mmusaev commented Aug 22, 2023

I forwarded the contract to my manager. As soon as I get the response, I will sign CLA.

Just got confirmation from my manager. Signed the contract and sent it. Sorry for the delay - the lawyers were busy. :)

@laura-rodriguez
Copy link
Collaborator

laura-rodriguez commented Oct 3, 2023

Hi @mmusaev,

I appreciate your patience. We received your CLA, and will review your PR as soon as possible.

In the meantime, can you please update the configuration reference section in the readme with a minimal code sample of how to use your proposed feature? Thank you!

@laura-rodriguez
Copy link
Collaborator

@mmusaev I've invited @rcollette to provide feedback on this PR, since he recently opened a related issue #656

docs: update the configuration reference section in the readme with a minimal code sample of how to use my proposed feature
@mmusaev
Copy link
Author

mmusaev commented Oct 3, 2023

@laura-rodriguez Updated README.md as per request with a code sample usage.

docs: use environmentName for json file
@mmusaev
Copy link
Author

mmusaev commented Oct 3, 2023

@rcollette Please see updated README.md with code sample, the proposed PR (being reviewed by OKTA team) will address your issue and other related issues.

@rcollette
Copy link

How configuration happens (where it comes from) should not be a concern of this library. Configuration mechanisms should be determined by the application.

@mmusaev
Copy link
Author

mmusaev commented Oct 4, 2023

@rcollette The extension to the library that I am proposing moves the library specific configuration responsibility to a client app instead of the library. I agree the separation of concerns must be adhered by the authors of the library.

fix: correct misspelling
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.

3 participants