Skip to content

Commit

Permalink
idp/proxy: Match users by ID instead of name by default
Browse files Browse the repository at this point in the history
Reconfigure the oidc clients for lico, so that lico adds the "lg.uuid" to
tokens and userinfo by default. That claim will contain the userid. So
we can now use the userid for matching users when using the default
idm/idp configuration. This fixes further problems so that users being
recreated with the same name are correctly treated as differnt users.

Fixes: #904
  • Loading branch information
rhafer committed May 23, 2023
1 parent e17194d commit 52951b4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions changelog/3.0.0_2023-05-22/fix-idp-sub-recreation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ claim. So that user's recreated with the same name will be treated as different
users by the IDP.

https://github.com/owncloud/ocis/issues/904
https://github.com/owncloud/ocis/pull/6326
https://github.com/owncloud/ocis/pull/6338
1 change: 1 addition & 0 deletions services/idp/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type Client struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Trusted bool `yaml:"trusted"`
ImplicitScopes []string `yaml:"implicit_scopes"`
Secret string `yaml:"secret"`
RedirectURIs []string `yaml:"redirect_uris"`
Origins []string `yaml:"origins"`
Expand Down
10 changes: 7 additions & 3 deletions services/idp/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ func DefaultConfig() *config.Config {
},
Clients: []config.Client{
{
ID: "web",
Name: "ownCloud Web app",
Trusted: true,
ID: "web",
Name: "ownCloud Web app",
ImplicitScopes: []string{"LibgreGraph.UUID"},
Trusted: true,
RedirectURIs: []string{
"{{OCIS_URL}}/",
"{{OCIS_URL}}/oidc-callback.html",
Expand All @@ -87,6 +88,7 @@ func DefaultConfig() *config.Config {
ID: "xdXOt13JKxym1B1QcEncf2XDkLAexMBFwiT9j6EfhhHFJhs2KM9jbjTmf8JBXE69",
Secret: "UBntmLjC2yYCeHwsyj73Uwo9TAaecAetRwMw0xYcvNL9yRdLSUi0hUAHfvCHFeFh",
Name: "ownCloud desktop app",
ImplicitScopes: []string{"LibgreGraph.UUID"},
ApplicationType: "native",
RedirectURIs: []string{
"http://127.0.0.1",
Expand All @@ -97,6 +99,7 @@ func DefaultConfig() *config.Config {
ID: "e4rAsNUSIUs0lF4nbv9FmCeUkTlV9GdgTLDH1b5uie7syb90SzEVrbN7HIpmWJeD",
Secret: "dInFYGV33xKzhbRmpqQltYNdfLdJIfJ9L5ISoKhNoT9qZftpdWSP71VrpGR9pmoD",
Name: "ownCloud Android app",
ImplicitScopes: []string{"LibgreGraph.UUID"},
ApplicationType: "native",
RedirectURIs: []string{
"oc://android.owncloud.com",
Expand All @@ -106,6 +109,7 @@ func DefaultConfig() *config.Config {
ID: "mxd5OQDk6es5LzOzRvidJNfXLUZS2oN3oUFeXPP8LpPrhx3UroJFduGEYIBOxkY1",
Secret: "KFeFWWEZO9TkisIQzR3fo7hfiMXlOpaqP8CFuTbSHzV1TUuGECglPxpiVKJfOXIx",
Name: "ownCloud iOS app",
ImplicitScopes: []string{"LibgreGraph.UUID"},
ApplicationType: "native",
RedirectURIs: []string{
"oc://ios.owncloud.com",
Expand Down
6 changes: 4 additions & 2 deletions services/proxy/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,10 @@ func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config,
if cfg.EnableBasicAuth {
logger.Warn().Msg("basic auth enabled, use only for testing or development")
authenticators = append(authenticators, middleware.BasicAuthenticator{
Logger: logger,
UserProvider: userProvider,
Logger: logger,
UserProvider: userProvider,
UserCS3Claim: cfg.UserCS3Claim,
UserOIDCClaim: cfg.UserOIDCClaim,
})
}

Expand Down
4 changes: 2 additions & 2 deletions services/proxy/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func DefaultConfig() *config.Config {
Enabled: true,
},
AccountBackend: "cs3",
UserOIDCClaim: "preferred_username",
UserCS3Claim: "username",
UserOIDCClaim: "lg.uuid",
UserCS3Claim: "userid",
AutoprovisionAccounts: false,
EnableBasicAuth: false,
InsecureBackends: false,
Expand Down

0 comments on commit 52951b4

Please sign in to comment.