Refactor IdP Config Structure for Improved Management #337

Closed
opened 2025-11-20 05:09:51 -05:00 by saavagebueno · 0 comments
Owner

Originally created by @bcmmbaga on GitHub (May 17, 2023).

Is your feature request related to a problem? Please describe.

Currently, Netbird contains several Identity Providers (IdPs), and their configurations are managed within a single IdP struct. As the number of IdPs increases, it becomes challenging to effectively manage the client config within this struct. This issue aims to refactor the IdP config structure to improve manageability and maintainability.

Describe the solution you'd like

The proposed solution is to refactor the existing struct to have a more generic configuration for all IdPs, along with an additional config that can hold key-value pairs for IdP-specific settings. Here's the suggested updated structure:

type Config struct {
    ManagerType  string
    ClientConfig    IdpClientConfig
    ExtraConfig     ExtraConfig
}

type IdpClientConfig struct {
    Issuer                  string
    TokenEndpoint   string
    GrantType          string
    ClientID               string
    ClientSecret.      string
    // other common client config 
}

type ExtraConfig map[string]string

With this refactored structure, the ManagerType remains intact, representing the type of the IdP manager. The ClientConfig field is introduced to hold the generic IdP configurations shared by all IdPs, such as the Issuer, TokenEndpoint, and GrantType. Additionally, the ExtraConfig field is introduced as a key-value map to store any IdP-specific configurations that are not common across all IdPs.

Describe alternatives you've considered

An alternative approach could have been creating separate configuration structs for each IdP. However, this would result in code duplication and make the overall configuration management more cumbersome. By refactoring the structure as proposed, we can achieve a balance between generic and specific IdP configurations, simplifying the management process.

Additional context

The current approach of managing IdP configurations within a single struct poses challenges as the number of IdPs grows. This refactoring will provide a cleaner and more maintainable codebase, making it easier to manage and extend the configuration options for various IdPs in the future.

Originally created by @bcmmbaga on GitHub (May 17, 2023). **Is your feature request related to a problem? Please describe.** Currently, Netbird contains several Identity Providers (IdPs), and their configurations are managed within a single IdP struct. As the number of IdPs increases, it becomes challenging to effectively manage the client config within this struct. This issue aims to refactor the IdP config structure to improve manageability and maintainability. **Describe the solution you'd like** The proposed solution is to refactor the existing struct to have a more generic configuration for all IdPs, along with an additional config that can hold key-value pairs for IdP-specific settings. Here's the suggested updated structure: ```code type Config struct { ManagerType string ClientConfig IdpClientConfig ExtraConfig ExtraConfig } type IdpClientConfig struct { Issuer string TokenEndpoint string GrantType string ClientID string ClientSecret. string // other common client config } type ExtraConfig map[string]string ``` With this refactored structure, the ManagerType remains intact, representing the type of the IdP manager. The ClientConfig field is introduced to hold the generic IdP configurations shared by all IdPs, such as the Issuer, TokenEndpoint, and GrantType. Additionally, the ExtraConfig field is introduced as a key-value map to store any IdP-specific configurations that are not common across all IdPs. **Describe alternatives you've considered** An alternative approach could have been creating separate configuration structs for each IdP. However, this would result in code duplication and make the overall configuration management more cumbersome. By refactoring the structure as proposed, we can achieve a balance between generic and specific IdP configurations, simplifying the management process. **Additional context** The current approach of managing IdP configurations within a single struct poses challenges as the number of IdPs grows. This refactoring will provide a cleaner and more maintainable codebase, making it easier to manage and extend the configuration options for various IdPs in the future.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#337