4
4
"context"
5
5
"encoding/json"
6
6
"fmt"
7
- "regexp"
8
7
9
8
"github.com/golang-jwt/jwt/v4"
10
9
"github.com/google/uuid"
@@ -15,7 +14,9 @@ import (
15
14
"github.com/coder/coder/v2/coderd/database/db2sdk"
16
15
"github.com/coder/coder/v2/coderd/database/dbauthz"
17
16
"github.com/coder/coder/v2/coderd/runtimeconfig"
17
+ "github.com/coder/coder/v2/coderd/util/ptr"
18
18
"github.com/coder/coder/v2/coderd/util/slice"
19
+ "github.com/coder/coder/v2/codersdk"
19
20
)
20
21
21
22
type GroupParams struct {
@@ -28,6 +29,7 @@ func (AGPLIDPSync) GroupSyncEnabled() bool {
28
29
// AGPL does not support syncing groups.
29
30
return false
30
31
}
32
+
31
33
func (s AGPLIDPSync ) GroupSyncSettings () runtimeconfig.RuntimeEntry [* GroupSyncSettings ] {
32
34
return s .Group
33
35
}
@@ -93,12 +95,12 @@ func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user dat
93
95
94
96
// Legacy deployment settings will override empty settings.
95
97
if orgID == defaultOrgID && settings .Field == "" {
96
- settings = & GroupSyncSettings {
98
+ settings = ptr . Ref ( GroupSyncSettings (codersdk. GroupSyncSettings {
97
99
Field : s .Legacy .GroupField ,
98
100
LegacyNameMapping : s .Legacy .GroupMapping ,
99
101
RegexFilter : s .Legacy .GroupFilter ,
100
102
AutoCreateMissing : s .Legacy .CreateMissingGroups ,
101
- }
103
+ }))
102
104
}
103
105
orgSettings [orgID ] = * settings
104
106
}
@@ -239,27 +241,7 @@ func (s AGPLIDPSync) ApplyGroupDifference(ctx context.Context, tx database.Store
239
241
return nil
240
242
}
241
243
242
- type GroupSyncSettings struct {
243
- // Field selects the claim field to be used as the created user's
244
- // groups. If the group field is the empty string, then no group updates
245
- // will ever come from the OIDC provider.
246
- Field string `json:"field"`
247
- // Mapping maps from an OIDC group --> Coder group ID
248
- Mapping map [string ][]uuid.UUID `json:"mapping"`
249
- // RegexFilter is a regular expression that filters the groups returned by
250
- // the OIDC provider. Any group not matched by this regex will be ignored.
251
- // If the group filter is nil, then no group filtering will occur.
252
- RegexFilter * regexp.Regexp `json:"regex_filter"`
253
- // AutoCreateMissing controls whether groups returned by the OIDC provider
254
- // are automatically created in Coder if they are missing.
255
- AutoCreateMissing bool `json:"auto_create_missing_groups"`
256
- // LegacyNameMapping is deprecated. It remaps an IDP group name to
257
- // a Coder group name. Since configuration is now done at runtime,
258
- // group IDs are used to account for group renames.
259
- // For legacy configurations, this config option has to remain.
260
- // Deprecated: Use Mapping instead.
261
- LegacyNameMapping map [string ]string `json:"legacy_group_name_mapping,omitempty"`
262
- }
244
+ type GroupSyncSettings codersdk.GroupSyncSettings
263
245
264
246
func (s * GroupSyncSettings ) Set (v string ) error {
265
247
return json .Unmarshal ([]byte (v ), s )
0 commit comments