8000 chore: implement organization sync and create idpsync package by Emyrk · Pull Request #14432 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: implement organization sync and create idpsync package #14432

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 23 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup compile issues
  • Loading branch information
Emyrk committed Aug 29, 2024
commit 210239f1f41079cd8bc43edf0945f75d8ff38f71
3 changes: 2 additions & 1 deletion cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
SSHConfigOptions: configSSHOptions,
},
AllowWorkspaceRenames: vals.AllowWorkspaceRenames.Value(),
Entitlements: entitlements.New(),
NotificationsEnqueuer: notifications.NewNoopEnqueuer(), // Changed further down if notifications enabled.
}
if httpServers.TLSConfig != nil {
Expand Down Expand Up @@ -674,7 +675,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
// Missing:
// - Userinfo
// - Verify
oc, err := createOIDCConfig(ctx, options.Logger, vals)
oc, err := createOIDCConfig(ctx, options.Logger, options.Entitlements, vals)
if err != nil {
return xerrors.Errorf("create oidc config: %w", err)
}
Expand Down
6 changes: 4 additions & 2 deletions coderd/idpsync/idpsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
// So instead, if the code is compiled with the enterprise logic, it will
// override this function to return the enterprise IDP sync object.
// For unit testing, the callers can specifically choose which "NewSync" to use.
var NewSync = NewAGPLSync
var NewSync = func(logger slog.Logger, entitlements *entitlements.Set, settings SyncSettings) IDPSync {
return NewAGPLSync(logger, entitlements, settings)
}

type IDPSync interface {
// ParseOrganizationClaims takes claims from an OIDC provider, and returns the
Expand Down Expand Up @@ -54,7 +56,7 @@ type SyncSettings struct {
OrganizationAssignDefault bool
}

func NewAGPLSync(logger slog.Logger, _ *entitlements.Set, settings SyncSettings) IDPSync {
func NewAGPLSync(logger slog.Logger, _ *entitlements.Set, settings SyncSettings) *AGPLIDPSync {
return &AGPLIDPSync{
Logger: logger.Named("idp-sync"),
SyncSettings: settings,
Expand Down
8 changes: 5 additions & 3 deletions enterprise/coderd/enidpsync/enidpsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ import (
)

func init() {
idpsync.NewSync = NewSync
idpsync.NewSync = func(logger slog.Logger, entitlements *entitlements.Set, settings idpsync.SyncSettings) idpsync.IDPSync {
return NewSync(logger, entitlements, settings)
}
}

type EnterpriseIDPSync struct {
entitlements *entitlements.Set
*idpsync.AGPLIDPSync
}

func NewSync(logger slog.Logger, entitlements *entitlements.Set, settings idpsync.SyncSettings) idpsync.IDPSync {
func NewSync(logger slog.Logger, entitlements *entitlements.Set, settings idpsync.SyncSettings) *EnterpriseIDPSync {
return &EnterpriseIDPSync{
entitlements: entitlements,
AGPLIDPSync: idpsync.NewAGPLSync(logger, entitlements, settings),
AGPLIDPSync: idpsync.NewAGPLSync(logger.With(slog.F("enterprise_capable", "true")), entitlements, settings),
}
}
0