Skip to content

Commit

Permalink
Merge pull request #3323 from rhafer/defaultrole
Browse files Browse the repository at this point in the history
Fix CreateHome for external users
  • Loading branch information
rhafer authored Mar 16, 2022
2 parents b3a1a14 + 6abf38d commit 439c203
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions proxy/pkg/user/backend/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,21 @@ func (c *cs3backend) GetUserByClaims(ctx context.Context, claim, value string, w
}
}

// if roles are empty, assume we haven't seen the user before and assign a
// default user role. At least until proper roles are provided. See
// https://github.com/owncloud/ocis/issues/1825 for more context.
if len(roleIDs) == 0 {
roleIDs = append(roleIDs, settingsService.BundleUUIDRoleUser, settingsService.SelfManagementPermissionID)
// if roles are empty, assume we haven't seen the user before and assign a default user role. At least until
// proper roles are provided. See https://github.com/owncloud/ocis/issues/1825 for more context.
//return user, nil
if user.Id.Type == cs3.UserType_USER_TYPE_PRIMARY {
c.logger.Info().Str("userid", user.Id.OpaqueId).Msg("user has no role assigned, assigning default user role")
_, err := c.settingsRoleService.AssignRoleToUser(ctx, &settingssvc.AssignRoleToUserRequest{
AccountUuid: user.Id.OpaqueId,
RoleId: settingsService.BundleUUIDRoleUser,
})
if err != nil {
c.logger.Error().Err(err).Msg("Could not add default role")
}
roleIDs = append(roleIDs, settingsService.BundleUUIDRoleUser)
}
}

enc, err := encodeRoleIDs(roleIDs)
Expand Down
2 changes: 1 addition & 1 deletion storage/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func DefaultConfig() *config.Config {
},
CommitShareToStorageGrant: true,
CommitShareToStorageRef: true,
DisableHomeCreationOnLogin: false,
DisableHomeCreationOnLogin: true,
ShareFolder: "Shares",
LinkGrants: "",
HomeMapping: "",
Expand Down

0 comments on commit 439c203

Please sign in to comment.