-
Notifications
You must be signed in to change notification settings - Fork 43
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
Initial implementation of IDP interface and Keycloak implementation #3155
Conversation
Note that the vast majority of this is checking in the keycloak OpenAPI YAML (11k lines) and the generated client code (5k lines). I chose to download and generate our own client because most of the generated libraries out there seemed to be old, and the published Keycloak OpenAPI docs seemed to be relatively new. |
3adf732
to
8988f2d
Compare
82fd831
to
d1c6b95
Compare
d1c6b95
to
c177b79
Compare
@@ -157,6 +157,7 @@ func TestEntityContextProjectInterceptor(t *testing.T) { | |||
} | |||
|
|||
for _, tc := range testCases { | |||
tc := tc |
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.
Same comment as below - curious if you ran into a problem that required this to be reinserted.
@@ -103,6 +104,15 @@ var serveCmd = &cobra.Command{ | |||
return fmt.Errorf("unable to prepare authz client for run: %w", err) | |||
} | |||
|
|||
kc, err := keycloak.NewKeyCloak("", cfg.Identity.Server) |
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.
What is the significance of the name
argument to NewKeyCloak
, and why is it left blank here?
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.
From the definition of IdentityProvider:
// String returns the name of the identity provider. This should be a short
// one-word string suitable for presentation. As a special case, a _single_
// provider may use the empty string as its name to act as a default / fallback
// provider.
We're using KeyCloak as the default provider. At some point in the future, I'd like to be able to add various machine identities as providers which can be granted access to the system without needing to have accounts in our primary IDP. (For example, an AWS role, a GCP service account, or a GitHub Action -- these might be stored as user:gha/repo:octo-org/octo-repo:environment:prod
as the user key in OpenFGA, for example.)
I'm not ready to commit to implementing one of these machine identity providers yet, but I wanted to put the foundations in place while I was doing this refactoring.
Currently, we only have the one default identity provider, which is Keycloak. This PR doesn't switch over all our Keycloak identity usage yet, only puts a backwards-compatible shim over the Keycloak + OpenFGA combination.
Changes LGTM aside from the small questions. |
4c23ed5
to
f67c638
Compare
This is ready for review. Sorry it got a bit large, but hopefully it's not too painful to review. Writing the tests already helped me catch a couple bugs that weren't in the common path, so yay tests! |
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'm guessing we'll need a migration from our current role assignments to assignments using the new subjects, right?
No, that's what the |
Okay, @dmjb, I implemented a fake for |
f9706b6
to
2014e7a
Compare
Summary
Defines and implements an IDP interface and a Keycloak implementation of said interface which allows us to specify and look up users by their GitHub login aliases while recording their KeyCloak user IDs in the actual database. Manually tested with the following after logging in both
evankanderson
andstacklokdemo
:The data written to OpenFGA uses the Keycloak user IDs as
user:<GUID>
, but the API reports the github names.As part of this change, I've introduced the use of OpenFeature with the GO Feature Flag library in module configuration (i.e. reading from a file). To activate, you'll need to add the following
flags-config.yaml
to your minder directory:(There are many more fine-grained options, but this turns on the flag. The file is mounted into the Docker container, and the server will notice updates within a minute or two, so you can toggle the feature on and off live.)
Fixes #3151
Change Type
Mark the type of change your PR introduces:
Testing
I've added unit tests with decent coverage for the various new code. I've also put the feature behind a feature flag, because there's more work to be done to clean up and unify this interface.
Review Checklist: