Skip to content

feat: implement patch and get api methods for role sync #14692

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

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Sep 16, 2024

No description provided.

@Emyrk Emyrk requested a review from f0ssel September 16, 2024 21:02
Base automatically changed from stevenmasley/org_role_sync to main September 17, 2024 00:03
@Emyrk Emyrk force-pushed the stevenmasley/role_sync_crud branch from 4a7bfcf to 2c9420d Compare September 17, 2024 00:08
// Mapping maps from an OIDC group --> Coder organization role
Mapping map[string][]string `json:"mapping"`
}
type RoleSyncSettings codersdk.RoleSyncSettings
Copy link
Contributor

Choose a reason for hiding this comment

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

I see why we alias (I think that's the correct terminology?) to add the additional methods, but I wonder if we could just implement those on the codersdk type? Or would that then be a dependency issue? It would just be nice to have a single type if possible, but not required.

Copy link
Member Author

Choose a reason for hiding this comment

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

@f0ssel techincally it's a type definition.

Aliasing is type RoleSyncSettings = codersdk.RoleSyncSettings. If you alias, it means the types are equivalent, and the alias is essentially replaced with the source at compile time. With a type definition, you create a new type.

I agree the aliasing is a bit strange. It exists because of an import cycle, and it also made sense to export via CoderSDK since the UI needs to consume it.

It felt strange for the idpsync package to not fully self contain it's own types. It is strange it depends on codersdk, but it is a consequence of our import cycles and not wanting to copy + paste a struct definition.

Ideally codersdk would type alias of the the idpsync.

Maybe we can change this in the future, I just didn't spend a ton of time on this. Kayla implemented this idea first, and it felt good enough to me for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah the import cycle is the nail in the coffin then, no worries this is still good.

r.Group(func(r chi.Router) {
r.Use(
apiKeyMiddleware,
httpmw.ExtractOrganizationParam(api.Database),
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this break any existing usages?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, it makes it more permissive, rather then restrictive. So it used to be gated by our experiment and premium licensing, but sync is an enterprise feature.

It makes sense to allow even single org deployments to configure this at runtime, so I dropped the entitlement requirements.

There is an entitlement check on the actual sync code, so tbd if we should also gate the patch endpoint, or just defer to some warning like "These settings require enterprise to function".

return
}

//nolint:gocritic // Requires system context to update runtime config
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to let org admins change this value? If this is a user action it feels weird to drop into system here. We usually just do that for non-user actors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Follow up would be fine

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I do want to. Just with the timelines, I did this as a stop gap.

I want to solve RBAC and runtime config fields in a more general reusable pattern. Until then, I just require a system context. And I use a system context so no one else can use these sync settings incorrectly. The dbauthz layer is currently pretty strict, and when this is fixed, we will make it more permissive. Always an easier way to move forward then the other way around.

@Emyrk Emyrk merged commit ce21b20 into main Sep 17, 2024
30 checks passed
@Emyrk Emyrk deleted the stevenmasley/role_sync_crud branch September 17, 2024 15:38
@github-actions github-actions bot locked and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants