-
Notifications
You must be signed in to change notification settings - Fork 45
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 the default time durations configurable on User Form Interface #212
base: main
Are you sure you want to change the base?
Conversation
1ee1dee
to
d4aacac
Compare
🙏 this is incredible work thank you so much for fleshing out this proof of concept for dynamically loaded configs. I have some questions about specific parts of the approach, I don't consider these blocking concerns but am curious about some specific decisions around loading the config from the static folder instead of pre-populating the js with config values. I'll add more detail around specific implementations but this round trip to retrieve config values is my biggest current open question. |
craco.config.js
Outdated
@@ -15,5 +17,23 @@ module.exports = { | |||
alias: { | |||
'@mui/styled-engine': '@mui/styled-engine-sc', | |||
}, | |||
plugins: [ | |||
new CopyWebpackPlugin({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been awhile since I've looked at webpack plugins, but I think instead of doing a blind copy
of the config file into the build dir it might be possible to populate config values server-side and generate a "config" module that has the right values pre-populated from something like an *.env
file. The benefits of doing it this way would be to save a round trip and make the initial time to render faster but if there are cons to this approach happy to discuss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to be able to configure the access time dropdowns. The first PR (#194) used environment variables in .env.production
. My attempt uses a config file because in the discord discussion (https://discord.com/channels/1232815453907189922/1306560215130443827) the proposed revision was to use a config file that would be copied in with webpack.
populate config values server-side
Unfortunately, I don't understand what you want :(
I am not well-versed in React so that might be the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@savathoon please see my latest commit.
- removed config files and config loader
- create access_config.py to create a typed
AccessConfig
instance, looking for env vars that override individual properties. - created Flask endpoint in
app.py
to serve/access_config.js
- use
public/index.html
to load the/access_config.js
script in every page - updated the front-end config loader to use
window.__ACCESS_CONFIG__
as the source of the config - updated the callsites
Please see what you think, because I'm not sure that I understand what you want.
be05a70
to
465439c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't include a roundtrip in every page load to load static config. This static config should be included in the JS bundle during build time.
d4aacac
to
4f29c36
Compare
I believe I've made the changes you requested. In this latest iteration. Please let me know what you think. |
4f29c36
to
aa01f11
Compare
aa01f11
to
8bdff73
Compare
Ok. Now you can set a build arg for Docker to use the config override file specified at ACCESS_FILE_CONFIG_PATH. |
330a2d1
to
b5e2b66
Compare
This is looking much better, thanks for adding this! I'm going to let @savathoon give it another review when they get a chance before I approve |
b5e2b66
to
e735f5c
Compare
…e path supplied as a build arg to Docker
e735f5c
to
28237c2
Compare
@savathoon do you have some time to look at this PR this week? |
Let us know if there's anything additional to get this merged upstream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late turnaround, thank you for making the previous round of changes. Most of what I suggested is in the interest of simplification/consolidation but would love to get your thoughts.
Before I do any further work on this, I'd like to confirm that @somethingnew2-0 agrees with the changes requested in this review. Further, I'd like us to agree that the override config file will be kept in cc @jonathanhle |
I've reviewed @savathoon's comments, they suggested to me privately taking at forking and suggesting a few commits to simplify things.
That sounds good to me. IMO simplicity is preferred. So if we can remove the need for a build arg in the Dockerfile, all the better. |
1. Move config files to project-level config directory 2. Move logic out of craco.config.js to src/config/loadAccessConfig.js 3. Update README
c54be0a
to
d1968e5
Compare
README.md
Outdated
|
||
To override values on the back-end, modify these key-value pairs inside the `BACKEND` key in your custom config file. | ||
|
||
_There are currently no supported back-end configuration overrides but this is planned to change soon._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be working on a follow-on PR, where I need to override some strings on the backend related to the regex name pattern used for Okta Group names.
config/config.default.json
Outdated
}, | ||
"DEFAULT_ACCESS_TIME": "1209600" | ||
}, | ||
"BACKEND": {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be working on a follow-on PR, where I need to override some strings on the backend related to the regex name pattern used for Okta Group names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I added that in d1968e5 to show why having the same config file for front-end and back-end is useful (much like how we use .env.production
for env vars in both React and Flask)
@somethingnew2-0 @savathoon Review requested again. As requested, the need for the Docker build arg is removed. I tried to make the change @savathoon suggested, to convert the config to a Typescript object. This failed for multiple reasons:
Whilst I was doing that, @jonathanhle and I spoke about his need to be able to configure the Access app on both the front-end and the back-end. His use case is simple: our pre-existing Okta entities use a different pattern to the one hard-coded in the Flask and React app. So keeping the access config file JSON gives us the flexibility to do this neatly: now you can specify a pattern and a custom error message. I also wrote an access config file loader and tests. Please re-review. |
- add and test access config loader in Flask back-end app - add sample configuration both both front- and back-end: extract name validation pattern to config - update README
d1968e5
to
9c09df1
Compare
Any chance this approach would work? It solves a need for overrides on the frontend and backend and keeps the related overrides in the same spot. We can maintain a slightly departed fork too for our needs, was just trying to avoid that. |
This PR is looking good to me, I love how we can specify/validate the same config for both frontend and backend. ❤️ The current python segmentation fault test failure is unrelated and something I'm trying to track down with Github support. Tests pass locally for me. Totally understand the issue of not being able to use Typescript during buildtime in the craco config. I'm going to let @savathoon give a final pass for any opinions, but to me this is looking ready to ship. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Works in my local testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Some open questions but nothing that's a blocking concern, will sanity check locally.
We fixed the unrelated test failures in #229 Could you rebase or merge from main, so we can run the tests and then merge if they pass? |
This is a rewrite of #194 after the discussion in the Discord channel at https://discord.com/channels/1232815453907189922/1306560215130443827.
This PR creates a default configuration file for the access app, and allows an environment-specific override configuration file path to be supplied as a build arg to Docker. See the README for details.
During the build process, craco uses webpack Define plugin to make the access config contents globally available as part of the static build artifacts.
cc @jonathanhle