idpsync
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- func ConvertAllowList(allowList []string) map[string]struct{}
- func ParseStringSliceClaim(claim interface{}) ([]string, error)
- type AGPLIDPSync
- func (s AGPLIDPSync) ApplyGroupDifference(ctx context.Context, tx database.Store, user database.User, add []uuid.UUID, ...) error
- func (AGPLIDPSync) GroupSyncEntitled() bool
- func (s AGPLIDPSync) GroupSyncSettings(ctx context.Context, orgID uuid.UUID, db database.Store) (*GroupSyncSettings, error)
- func (AGPLIDPSync) OrganizationRoleSyncEnabled(_ context.Context, _ database.Store, _ uuid.UUID) (bool, error)
- func (AGPLIDPSync) OrganizationSyncEnabled(_ context.Context, _ database.Store) bool
- func (AGPLIDPSync) OrganizationSyncEntitled() bool
- func (s AGPLIDPSync) OrganizationSyncSettings(ctx context.Context, db database.Store) (*OrganizationSyncSettings, error)
- func (s AGPLIDPSync) ParseGroupClaims(_ context.Context, _ jwt.MapClaims) (GroupParams, *HTTPError)
- func (s AGPLIDPSync) ParseOrganizationClaims(_ context.Context, claims jwt.MapClaims) (OrganizationParams, *HTTPError)
- func (s AGPLIDPSync) ParseRoleClaims(_ context.Context, _ jwt.MapClaims) (RoleParams, *HTTPError)
- func (AGPLIDPSync) RoleSyncEntitled() bool
- func (s AGPLIDPSync) RoleSyncSettings(ctx context.Context, orgID uuid.UUID, db database.Store) (*RoleSyncSettings, error)
- func (AGPLIDPSync) RolesFromClaim(field string, claims jwt.MapClaims) ([]string, error)
- func (AGPLIDPSync) SiteRoleSyncEnabled() bool
- func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user database.User, params GroupParams) error
- func (s AGPLIDPSync) SyncOrganizations(ctx context.Context, tx database.Store, user database.User, ...) error
- func (s AGPLIDPSync) SyncRoles(ctx context.Context, db database.Store, user database.User, params RoleParams) error
- func (s AGPLIDPSync) UpdateGroupSyncSettings(ctx context.Context, orgID uuid.UUID, db database.Store, ...) error
- func (s AGPLIDPSync) UpdateOrganizationSyncSettings(ctx context.Context, db database.Store, settings OrganizationSyncSettings) error
- func (s AGPLIDPSync) UpdateRoleSyncSettings(ctx context.Context, orgID uuid.UUID, db database.Store, ...) error
- type DefaultOrgLegacySettings
- type DeploymentSyncSettings
- type ExpectedGroup
- type GroupParams
- type GroupSyncSettings
- func (s GroupSyncSettings) HandleMissingGroups(ctx context.Context, tx database.Store, orgID uuid.UUID, add []ExpectedGroup) ([]uuid.UUID, error)
- func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClaims) ([]ExpectedGroup, error)
- func (s *GroupSyncSettings) Set(v string) error
- func (s *GroupSyncSettings) String() string
- type HTTPError
- type IDPSync
- type OrganizationParams
- type OrganizationSyncSettings
- type RoleParams
- type RoleSyncSettings
- type SyncSettings
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcConvertAllowList¶added inv2.16.0
funcParseStringSliceClaim¶
ParseStringSliceClaim parses the claim for groups and roles, expected []string.
Some providers like ADFS return a single string instead of an array if thereis only 1 element. So this function handles the edge cases.
Types¶
typeAGPLIDPSync¶
type AGPLIDPSync struct {Loggerslog.LoggerManager *runtimeconfig.ManagerSyncSettings}
AGPLIDPSync is the configuration for syncing user information from an externalIDP. All related code to syncing user information should be in this package.
funcNewAGPLSync¶
func NewAGPLSync(loggerslog.Logger, manager *runtimeconfig.Manager, settingsDeploymentSyncSettings) *AGPLIDPSync
func (AGPLIDPSync)ApplyGroupDifference¶added inv2.16.0
func (sAGPLIDPSync) ApplyGroupDifference(ctxcontext.Context, txdatabase.Store, userdatabase.User, add []uuid.UUID, removeIDs []uuid.UUID)error
ApplyGroupDifference will add and remove the user from the specified groups.
func (AGPLIDPSync)GroupSyncEntitled¶added inv2.18.0
func (AGPLIDPSync) GroupSyncEntitled()bool
func (AGPLIDPSync)GroupSyncSettings¶added inv2.16.0
func (sAGPLIDPSync) GroupSyncSettings(ctxcontext.Context, orgIDuuid.UUID, dbdatabase.Store) (*GroupSyncSettings,error)
func (AGPLIDPSync)OrganizationRoleSyncEnabled¶added inv2.16.0
func (AGPLIDPSync)OrganizationSyncEnabled¶
func (AGPLIDPSync)OrganizationSyncEntitled¶added inv2.18.0
func (AGPLIDPSync) OrganizationSyncEntitled()bool
func (AGPLIDPSync)OrganizationSyncSettings¶added inv2.18.0
func (sAGPLIDPSync) OrganizationSyncSettings(ctxcontext.Context, dbdatabase.Store) (*OrganizationSyncSettings,error)
func (AGPLIDPSync)ParseGroupClaims¶added inv2.16.0
func (sAGPLIDPSync) ParseGroupClaims(_context.Context, _ jwt.MapClaims) (GroupParams, *HTTPError)
func (AGPLIDPSync)ParseOrganizationClaims¶
func (sAGPLIDPSync) ParseOrganizationClaims(_context.Context, claims jwt.MapClaims) (OrganizationParams, *HTTPError)
func (AGPLIDPSync)ParseRoleClaims¶added inv2.16.0
func (sAGPLIDPSync) ParseRoleClaims(_context.Context, _ jwt.MapClaims) (RoleParams, *HTTPError)
func (AGPLIDPSync)RoleSyncEntitled¶added inv2.16.0
func (AGPLIDPSync) RoleSyncEntitled()bool
func (AGPLIDPSync)RoleSyncSettings¶added inv2.16.0
func (sAGPLIDPSync) RoleSyncSettings(ctxcontext.Context, orgIDuuid.UUID, dbdatabase.Store) (*RoleSyncSettings,error)
func (AGPLIDPSync)RolesFromClaim¶added inv2.16.0
func (AGPLIDPSync) RolesFromClaim(fieldstring, claims jwt.MapClaims) ([]string,error)
func (AGPLIDPSync)SiteRoleSyncEnabled¶added inv2.16.0
func (AGPLIDPSync) SiteRoleSyncEnabled()bool
func (AGPLIDPSync)SyncGroups¶added inv2.16.0
func (sAGPLIDPSync) SyncGroups(ctxcontext.Context, dbdatabase.Store, userdatabase.User, paramsGroupParams)error
func (AGPLIDPSync)SyncOrganizations¶
func (sAGPLIDPSync) SyncOrganizations(ctxcontext.Context, txdatabase.Store, userdatabase.User, paramsOrganizationParams)error
SyncOrganizations if enabled will ensure the user is a member of the providedorganizations. It will add and remove their membership to match the expected set.
func (AGPLIDPSync)SyncRoles¶added inv2.16.0
func (sAGPLIDPSync) SyncRoles(ctxcontext.Context, dbdatabase.Store, userdatabase.User, paramsRoleParams)error
func (AGPLIDPSync)UpdateGroupSyncSettings¶added inv2.19.0
func (sAGPLIDPSync) UpdateGroupSyncSettings(ctxcontext.Context, orgIDuuid.UUID, dbdatabase.Store, settingsGroupSyncSettings)error
func (AGPLIDPSync)UpdateOrganizationSyncSettings¶added inv2.19.0
func (sAGPLIDPSync) UpdateOrganizationSyncSettings(ctxcontext.Context, dbdatabase.Store, settingsOrganizationSyncSettings)error
func (AGPLIDPSync)UpdateRoleSyncSettings¶added inv2.19.0
func (sAGPLIDPSync) UpdateRoleSyncSettings(ctxcontext.Context, orgIDuuid.UUID, dbdatabase.Store, settingsRoleSyncSettings)error
typeDefaultOrgLegacySettings¶added inv2.16.0
typeDeploymentSyncSettings¶added inv2.16.0
type DeploymentSyncSettings struct {// OrganizationField selects the claim field to be used as the created user's// organizations. If the field is the empty string, then no organization updates// will ever come from the OIDC provider.OrganizationFieldstring// OrganizationMapping controls how organizations returned by the OIDC provider get mappedOrganizationMapping map[string][]uuid.UUID// OrganizationAssignDefault will ensure all users that authenticate will be// placed into the default organization. This is mostly a hack to support// legacy deployments.OrganizationAssignDefaultbool// GroupField at the deployment level is used for deployment level group claim// settings.GroupFieldstring// 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{}// Legacy deployment settings that only apply to the default org.LegacyDefaultOrgLegacySettings// SiteRoleField selects the claim field to be used as the created user's// roles. If the field is the empty string, then no site role updates// will ever come from the OIDC provider.SiteRoleFieldstring// SiteRoleMapping controls how groups returned by the OIDC provider get mapped// to site roles within Coder.// map[oidcRoleName][]coderRoleNameSiteRoleMapping map[string][]string// SiteDefaultRoles is the default set of site roles to assign to a user if role sync// is enabled.SiteDefaultRoles []string}
DeploymentSyncSettings are static and are sourced from the deployment config.
funcFromDeploymentValues¶added inv2.16.0
func FromDeploymentValues(dv *codersdk.DeploymentValues)DeploymentSyncSettings
typeExpectedGroup¶added inv2.16.0
func (ExpectedGroup)Equal¶added inv2.16.0
func (aExpectedGroup) Equal(bExpectedGroup)bool
Equal compares two ExpectedGroups. The org id must be the same.If the group ID is set, it will be compared and take priority, ignoring thename value. So 2 groups with the same ID but different names will beconsidered equal.
typeGroupParams¶added inv2.16.0
type GroupParams struct {// SyncEntitled if false will skip syncing the user's groupsSyncEntitledboolMergedClaims jwt.MapClaims}
typeGroupSyncSettings¶added inv2.16.0
type GroupSyncSettingscodersdk.GroupSyncSettings
func (GroupSyncSettings)HandleMissingGroups¶added inv2.16.0
func (sGroupSyncSettings) HandleMissingGroups(ctxcontext.Context, txdatabase.Store, orgIDuuid.UUID, add []ExpectedGroup) ([]uuid.UUID,error)
HandleMissingGroups ensures all ExpectedGroups convert to uuids.Groups can be referenced by name via legacy params or IDP group names.These group names are converted to IDs for easier assignment.Missing groups are created if AutoCreate is enabled.TODO: Batching this would be better, as this is 1 or 2 db calls per organization.
func (GroupSyncSettings)ParseClaims¶added inv2.16.0
func (sGroupSyncSettings) ParseClaims(orgIDuuid.UUID, mergedClaims jwt.MapClaims) ([]ExpectedGroup,error)
ParseClaims will take the merged claims from the IDP and return the groupsthe user is expected to be a member of. The expected group can either be aname or an ID.It is unfortunate we cannot use exclusively names or exclusively IDs.When configuring though, if a group is mapped from "A" -> "UUID 1234", andthe group "UUID 1234" is renamed, we want to maintain the mapping.We have to keep names because group sync supports syncing groups by name ifthe external IDP group name matches the Coder one.
func (*GroupSyncSettings)Set¶added inv2.16.0
func (s *GroupSyncSettings) Set(vstring)error
func (*GroupSyncSettings)String¶added inv2.16.0
func (s *GroupSyncSettings) String()string
typeHTTPError¶
HTTPError is a helper struct for returning errors from the IDP sync process.A regular error is not sufficient because many of these errors are surfacedto a user logging in, and the errors should be descriptive.
funcIsHTTPError¶
IsHTTPError handles us being inconsistent with returning errors as values orpointers.
typeIDPSync¶
type IDPSync interface {OrganizationSyncEntitled()boolOrganizationSyncSettings(ctxcontext.Context, dbdatabase.Store) (*OrganizationSyncSettings,error)UpdateOrganizationSyncSettings(ctxcontext.Context, dbdatabase.Store, settingsOrganizationSyncSettings)error// OrganizationSyncEnabled returns true if all OIDC users are assigned// to organizations via org sync settings.// This is used to know when to disable manual org membership assignment.OrganizationSyncEnabled(ctxcontext.Context, dbdatabase.Store)bool// ParseOrganizationClaims takes claims from an OIDC provider, and returns the// organization sync params for assigning users into organizations.ParseOrganizationClaims(ctxcontext.Context, mergedClaims jwt.MapClaims) (OrganizationParams, *HTTPError)// SyncOrganizations assigns and removed users from organizations based on the// provided params.SyncOrganizations(ctxcontext.Context, txdatabase.Store, userdatabase.User, paramsOrganizationParams)errorGroupSyncEntitled()bool// ParseGroupClaims takes claims from an OIDC provider, and returns the params// for group syncing. Most of the logic happens in SyncGroups.ParseGroupClaims(ctxcontext.Context, mergedClaims jwt.MapClaims) (GroupParams, *HTTPError)// SyncGroups assigns and removes users from groups based on the provided params.SyncGroups(ctxcontext.Context, dbdatabase.Store, userdatabase.User, paramsGroupParams)error// GroupSyncSettings is exposed for the API to implement CRUD operations// on the settings used by IDPSync. This entry is thread safe and can be// accessed concurrently. The settings are stored in the database.GroupSyncSettings(ctxcontext.Context, orgIDuuid.UUID, dbdatabase.Store) (*GroupSyncSettings,error)UpdateGroupSyncSettings(ctxcontext.Context, orgIDuuid.UUID, dbdatabase.Store, settingsGroupSyncSettings)error// RoleSyncEntitled returns true if the deployment is entitled to role syncing.RoleSyncEntitled()bool// OrganizationRoleSyncEnabled returns true if the organization has role sync// enabled.OrganizationRoleSyncEnabled(ctxcontext.Context, dbdatabase.Store, orguuid.UUID) (bool,error)// SiteRoleSyncEnabled returns true if the deployment has role sync enabled// at the site level.SiteRoleSyncEnabled()bool// RoleSyncSettings is similar to GroupSyncSettings. See GroupSyncSettings for// rational.RoleSyncSettings(ctxcontext.Context, orgIDuuid.UUID, dbdatabase.Store) (*RoleSyncSettings,error)UpdateRoleSyncSettings(ctxcontext.Context, orgIDuuid.UUID, dbdatabase.Store, settingsRoleSyncSettings)error// ParseRoleClaims takes claims from an OIDC provider, and returns the params// for role syncing. Most of the logic happens in SyncRoles.ParseRoleClaims(ctxcontext.Context, mergedClaims jwt.MapClaims) (RoleParams, *HTTPError)// SyncRoles assigns and removes users from roles based on the provided params.// Site & org roles are handled in this method.SyncRoles(ctxcontext.Context, dbdatabase.Store, userdatabase.User, paramsRoleParams)error}
IDPSync is an interface, so we can implement this as AGPL and as enterprise,and just swap the underlying implementation.IDPSync exists to contain all the logic for mapping a user's external IDPclaims to the internal representation of a user in Coder.TODO: Move group + role sync into this interface.
typeOrganizationParams¶
type OrganizationParams struct {// SyncEntitled if false will skip syncing the user's organizations.SyncEntitledbool// MergedClaims are passed to the organization level for syncingMergedClaims jwt.MapClaims}
typeOrganizationSyncSettings¶added inv2.18.0
type OrganizationSyncSettings struct {// Field selects the claim field to be used as the created user's// organizations. If the field is the empty string, then no organization updates// will ever come from the OIDC provider.Fieldstring `json:"field"`// Mapping controls how organizations returned by the OIDC provider get mappedMapping map[string][]uuid.UUID `json:"mapping"`// AssignDefault will ensure all users that authenticate will be// placed into the default organization. This is mostly a hack to support// legacy deployments.AssignDefaultbool `json:"assign_default"`}
func (*OrganizationSyncSettings)ParseClaims¶added inv2.18.0
func (s *OrganizationSyncSettings) ParseClaims(ctxcontext.Context, dbdatabase.Store, mergedClaims jwt.MapClaims) ([]uuid.UUID,error)
ParseClaims will parse the claims and return the list of organizations the usershould sync to.
func (*OrganizationSyncSettings)Set¶added inv2.18.0
func (s *OrganizationSyncSettings) Set(vstring)error
func (*OrganizationSyncSettings)String¶added inv2.18.0
func (s *OrganizationSyncSettings) String()string
typeRoleParams¶added inv2.16.0
typeRoleSyncSettings¶added inv2.16.0
type RoleSyncSettingscodersdk.RoleSyncSettings
func (*RoleSyncSettings)Set¶added inv2.16.0
func (s *RoleSyncSettings) Set(vstring)error
func (*RoleSyncSettings)String¶added inv2.16.0
func (s *RoleSyncSettings) String()string
typeSyncSettings¶
type SyncSettings struct {DeploymentSyncSettingsGroupruntimeconfig.RuntimeEntry[*GroupSyncSettings]Roleruntimeconfig.RuntimeEntry[*RoleSyncSettings]Organizationruntimeconfig.RuntimeEntry[*OrganizationSyncSettings]}