- Notifications
You must be signed in to change notification settings - Fork928
chore: support multi-org group sync with runtime configuration#14578
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
99c97c2
bfddeb6
f2857c6
791a059
4326e9d
6d3ed2e
0803619
596e7b4
b9476ac
ee8e4e4
d5ff0f7
86c0f6f
2f03e18
ec8092d
d63727d
2a1769c
640e86e
c544a29
476be45
164aeac
986498d
290cfa5
c563b10
d2c247f
12685bd
bf0d4ed
f95128e
88b0ad9
6491f6a
bd23288
a390ec4
a0a1c53
a86ba83
0df7f28
7a802a9
611f1e3
7f28a53
41994d2
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -63,6 +63,29 @@ type DeploymentSyncSettings struct { | ||
// placed into the default organization. This is mostly a hack to support | ||
// legacy deployments. | ||
OrganizationAssignDefault bool | ||
// GroupField at the deployment level is used for deployment level group claim | ||
// settings. | ||
GroupField string | ||
// GroupAllowList (if set) will restrict authentication to only users who | ||
// have at least one group in this list. | ||
// A map representation is used for easier lookup. | ||
GroupAllowList map[string]struct{} | ||
Comment on lines +71 to +75 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. At some point we should disconnect these from the default org. Might need to move the existing config env and flags, and deprecate the old. | ||
} | ||
func FromDeploymentValues(dv *codersdk.DeploymentValues) DeploymentSyncSettings { | ||
if dv == nil { | ||
panic("Developer error: DeploymentValues should not be nil") | ||
} | ||
return DeploymentSyncSettings{ | ||
OrganizationField: dv.OIDC.OrganizationField.Value(), | ||
OrganizationMapping: dv.OIDC.OrganizationMapping.Value, | ||
OrganizationAssignDefault: dv.OIDC.OrganizationAssignDefault.Value(), | ||
GroupField: dv.OIDC.GroupField.Value(), | ||
GroupAllowList: ConvertAllowList(dv.OIDC.GroupAllowList.Value()), | ||
} | ||
} | ||
type SyncSettings struct { | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package enidpsync_test | ||
import ( | ||
"testing" | ||
"github.com/golang-jwt/jwt/v4" | ||
"github.com/stretchr/testify/require" | ||
"cdr.dev/slog/sloggers/slogtest" | ||
"github.com/coder/coder/v2/coderd/entitlements" | ||
"github.com/coder/coder/v2/coderd/idpsync" | ||
"github.com/coder/coder/v2/coderd/runtimeconfig" | ||
"github.com/coder/coder/v2/enterprise/coderd/enidpsync" | ||
"github.com/coder/coder/v2/testutil" | ||
) | ||
func TestEnterpriseParseGroupClaims(t *testing.T) { | ||
t.Parallel() | ||
t.Run("NoEntitlements", func(t *testing.T) { | ||
t.Parallel() | ||
s := enidpsync.NewSync(slogtest.Make(t, &slogtest.Options{}), | ||
runtimeconfig.NewNoopManager(), | ||
entitlements.New(), | ||
idpsync.DeploymentSyncSettings{}) | ||
ctx := testutil.Context(t, testutil.WaitMedium) | ||
params, err := s.ParseGroupClaims(ctx, jwt.MapClaims{}) | ||
require.Nil(t, err) | ||
require.False(t, params.SyncEnabled) | ||
}) | ||
} |