2024-09-11 13:43:50 -05:00
|
|
|
package enidpsync
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/golang-jwt/jwt/v4"
|
|
|
|
|
|
|
|
|
|
"github.com/coder/coder/v2/coderd/idpsync"
|
|
|
|
|
"github.com/coder/coder/v2/codersdk"
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-08 08:44:14 -06:00
|
|
|
func (e EnterpriseIDPSync) GroupSyncEntitled() bool {
|
2024-09-11 13:43:50 -05:00
|
|
|
return e.entitlements.Enabled(codersdk.FeatureTemplateRBAC)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ParseGroupClaims parses the user claims and handles deployment wide group behavior.
|
|
|
|
|
// Almost all behavior is deferred since each organization configures it's own
|
|
|
|
|
// group sync settings.
|
|
|
|
|
// GroupAllowList is implemented here to prevent login by unauthorized users.
|
|
|
|
|
// TODO: GroupAllowList overlaps with the default organization group sync settings.
|
|
|
|
|
func (e EnterpriseIDPSync) ParseGroupClaims(ctx context.Context, mergedClaims jwt.MapClaims) (idpsync.GroupParams, *idpsync.HTTPError) {
|
2025-08-20 10:09:13 -05:00
|
|
|
resp, err := e.AGPLIDPSync.ParseGroupClaims(ctx, mergedClaims)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return idpsync.GroupParams{}, err
|
2024-09-11 13:43:50 -05:00
|
|
|
}
|
|
|
|
|
return idpsync.GroupParams{
|
2025-08-20 10:09:13 -05:00
|
|
|
SyncEntitled: e.GroupSyncEntitled(),
|
|
|
|
|
MergedClaims: resp.MergedClaims,
|
2024-09-11 13:43:50 -05:00
|
|
|
}, nil
|
|
|
|
|
}
|