Skip to content

Commit

Permalink
set only user oidc claim only if cs3 claim is userid
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek committed Nov 15, 2021
1 parent d05df2f commit e67a759
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions proxy/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config)
middleware.UserProvider(userProvider),
middleware.OIDCIss(cfg.OIDC.Issuer),
middleware.UserOIDCClaim(cfg.UserOIDCClaim),
middleware.UserCS3Claim(cfg.UserCS3Claim),
middleware.CredentialsByUserAgent(cfg.Reva.Middleware.Auth.CredentialsByUserAgent),
),
middleware.SignedURLAuth(
Expand Down
1 change: 1 addition & 0 deletions proxy/pkg/middleware/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func newBasicAuth(options Options) func(http.Handler) http.Handler {
AccountsClient(options.AccountsClient),
OIDCIss(options.OIDCIss),
UserOIDCClaim(options.UserOIDCClaim),
UserCS3Claim(options.UserCS3Claim),
CredentialsByUserAgent(options.CredentialsByUserAgent),
)
}
5 changes: 4 additions & 1 deletion proxy/pkg/middleware/basic_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ func BasicAuth(optionSetters ...Option) func(next http.Handler) http.Handler {
// fake oidc claims
claims := map[string]interface{}{
oidc.OwncloudUUID: user.Id.OpaqueId,
options.UserOIDCClaim: user.Id.OpaqueId,
oidc.Iss: user.Id.Idp,
oidc.PreferredUsername: user.Username,
oidc.Email: user.Mail,
}
if options.UserCS3Claim == "userid" {
claims[options.UserOIDCClaim] = user.Id.OpaqueId
// OpaqueId contains the userid configured in STORAGE_LDAP_USER_SCHEMA_UID
}

next.ServeHTTP(w, req.WithContext(oidc.NewContext(req.Context(), claims)))
},
Expand Down

0 comments on commit e67a759

Please sign in to comment.