Skip to content

Conversation

@skrobul
Copy link
Collaborator

@skrobul skrobul commented Apr 28, 2025

This pull request introduces a new operator that enables dynamic management of OAuth2 clients in Dex using standard Kubernetes objects.

Currently, creating a Client involves several manual steps:

  • Generating a password locally on the developer's machine
  • Storing the password in a compatible Kubernetes YAML Secret manifest
  • Sealing the Secret on the running cluster, committing it to the repository
  • Updating Dex's deployment to read the secret and export it as an environment variable
  • Configuring Dex to reference the new environment variable

This process is not ideal, as it imposes a significant administrative burden and security risks due to the use of environment variables. Moreover, updating passwords becomes challenging.

By deploying the operator from this pull request, we can simplify this process significantly. The operator will handle generating secrets and updating Dex configurations for the listed Clients, eliminating the need for manual intervention. Additionally, it leverages dynamic configuration of Dex, allowing us to make changes without requiring a restart. As an added security benefit, the actual password values will never leave the cluster, reducing the risk of exposure and improving overall security.

Key benefits of this change include reduced administrative burden, improved security, and easier password updates.

Note

To the reviewer:
Part of this PR is boiler plate that is automatically generated by operator-sdk. This can be ignored or skimmed through:

  • Stuff in config/ folder is automatically generated with exception of config/samples
  • dist/ contains an autogenerated YAML for non-helm installs
  • Makefile is autogenerated with adjustments to the IMAGE_TAG_BASE only

@skrobul skrobul requested a review from a team April 28, 2025 15:41
@skrobul skrobul changed the title dexop - operator to manage Oauth2 clients in Dex feat: dexop - operator to manage Oauth2 clients in Dex Apr 28, 2025
@skrobul skrobul force-pushed the dexop branch 17 times, most recently from 2f506f3 to a239090 Compare April 29, 2025 06:48
type SecretManager struct {
}

func (s SecretManager) readSecret(r *ClientReconciler, ctx context.Context, name, namespace string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reasons for not using pointer here func (s *SecretManager)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods in SecretManager do not alter the struct's state, and because SecretManager is currently an empty struct, there's no need for a pointer receiver. A value receiver suffices for stateless behavior and avoids unnecessary complexity of pointer management.


toolchain go1.23.6

require (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to run go mod tidy
current go.mod is missing some packages that are used.
Like: github.com/sethvargo/go-password

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch,thanks! fixed in rebase

Copy link
Contributor

@cardoe cardoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems like what we're aiming to achieve.

skrobul added 19 commits May 7, 2025 14:48
Up till now all tests required the Dex server to be already running on
the developer's machine. It was also assumed that the server will be
preconfigured for the gRPC communication. This required the appropriate
certificates to be generated, configured in Dex and copied over to the
project directory.

This commit removes that requirement altogether by automatically
starting "dex serve" with appropriate configuration and shutting it down
when the tests complete.
grpc.Dial deprecation will be done in separate commit in case w need to
revert.
This deploys basic version of the operator.
This changes how the automatically generated Kubernetes Secret looks
like:

- the `secret` key was renamed to `client-secret`
- the `client-id` key is now populated
- the `issuer` is populated

Caveat: The Issuer information can be obtained from Dex dynamically only
starting from newest version (2.42) of Dex. To avoid triggering failed
discovery, the same information can be provided as a command line
argument.
Copy link
Contributor

@abhimanyu003 abhimanyu003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@skrobul skrobul added this pull request to the merge queue May 7, 2025
Merged via the queue into main with commit 0d9d868 May 7, 2025
18 checks passed
@skrobul skrobul deleted the dexop branch May 7, 2025 14:24
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.

4 participants