allow storing client_id and client_secret in coman config for envs without keyring#61
allow storing client_id and client_secret in coman config for envs without keyring#61
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
coman/src/cscs/handlers.rs
Outdated
| .cscs | ||
| .client_secret | ||
| .map(Secret) | ||
| .unwrap_or(match get_secret(CLIENT_SECRET_SECRET_NAME).await { |
There was a problem hiding this comment.
Repeated pattern for client_secret; consider refactoring into a helper function.
| .unwrap_or(match get_secret(CLIENT_SECRET_SECRET_NAME).await { | |
| .unwrap_or_else(|| get_secret(CLIENT_SECRET_SECRET_NAME).await.unwrap_or_else(|e| Err(e)?)) |
#ai-review-inline
| Ok(None) => Err(eyre!("not logged in"))?, | ||
| Err(e) => Err(e)?, | ||
| }; | ||
| let config = Config::new()?; |
There was a problem hiding this comment.
Consider extracting config loading into a separate function for better readability and testability.
| let config = Config::new()?; | |
| let config = Config::new()?; |
#ai-review-inline
coman/src/cscs/handlers.rs
Outdated
| .cscs | ||
| .client_id | ||
| .map(Secret) | ||
| .unwrap_or(match get_secret(CLIENT_ID_SECRET_NAME).await { |
There was a problem hiding this comment.
The unwrap_or pattern can be simplified by using or with a closure for cleaner logic.
| .unwrap_or(match get_secret(CLIENT_ID_SECRET_NAME).await { | |
| .unwrap_or_else(|| get_secret(CLIENT_ID_SECRET_NAME).await.unwrap_or_else(|e| Err(e)?)) |
#ai-review-inline
70a86eb to
2b9c037
Compare
2b9c037 to
9a0059a
Compare
PR Type
Enhancement
Description
Added support for storing CSCS client credentials in config
Enhanced authentication flow to fallback to keyring when config values missing
Improved configuration flexibility for environments without keyring
Updated token retrieval logic to prioritize config over keyring
Diagram Walkthrough
flowchart LR A["Config::new()"] -- "loads cscs config" --> B["CscsConfig"] B -- "client_id" --> C["Secret::from_config"] B -- "client_secret" --> D["Secret::from_config"] C -- "fallback to keyring" --> E["get_secret(CLIENT_ID_SECRET_NAME)"] D -- "fallback to keyring" --> F["get_secret(CLIENT_SECRET_SECRET_NAME)"] E -- "or None" --> G["Err('not logged in')"] F -- "or None" --> GFile Walkthrough
config.rs
Add CSCS client credential fields to configcoman/src/config.rs
client_idfield toCscsConfigstructclient_secretfield toCscsConfigstructhandlers.rs
Update auth flow to use config credentials firstcoman/src/cscs/handlers.rs
get_access_tokento check config before keyringconfig.values.cscs.client_idconfig.values.cscs.client_secret