Skip to content

Commit

Permalink
add userid to username mapping to public shares
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas committed Dec 16, 2020
1 parent 314157f commit a00412f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/ocs-share-api-userid.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ The ocs api should not send the users uuid. Replaced the uuid with the username.

https://github.com/owncloud/ocis/issues/990
https://github.com/cs3org/reva/pull/1375
https://github.com/cs3org/reva/pull/1376
7 changes: 5 additions & 2 deletions internal/http/services/owncloud/ocs/conversions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const (
ShareTypeFederatedCloudShare ShareType = 6
)

// RedactedField is the constant value for redacted fields
const RedactedField string = "***redacted***"

// ResourceType indicates the OCS type of the resource
type ResourceType int

Expand Down Expand Up @@ -323,8 +326,8 @@ func PublicShare2ShareData(share *link.PublicShare, r *http.Request, publicURL s
}

if share.PasswordProtected {
sd.ShareWith = "***redacted***"
sd.ShareWithDisplayname = "***redacted***"
sd.ShareWith = RedactedField
sd.ShareWithDisplayname = RedactedField
}

return sd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (h *Handler) createPublicLinkShare(w http.ResponseWriter, r *http.Request)
return
}
h.addDisplaynames(ctx, c, s)
h.mapUserIds(ctx, c, s)

response.WriteOCSSuccess(w, r, s)
}
Expand Down Expand Up @@ -208,6 +209,7 @@ func (h *Handler) listPublicShares(r *http.Request, filters []*link.ListPublicSh
continue
}
h.addDisplaynames(ctx, c, sData)
h.mapUserIds(ctx, c, sData)

log.Debug().Interface("share", share).Interface("info", statResponse.Info).Interface("shareData", share).Msg("mapped")

Expand Down Expand Up @@ -432,6 +434,7 @@ func (h *Handler) updatePublicShare(w http.ResponseWriter, r *http.Request, shar
return
}
h.addDisplaynames(r.Context(), gwC, s)
h.mapUserIds(r.Context(), gwC, s)

response.WriteOCSSuccess(w, r, s)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,9 @@ func (h *Handler) addDisplaynames(ctx context.Context, c gateway.GatewayAPIClien
func (h *Handler) mapUserIds(ctx context.Context, c gateway.GatewayAPIClient, s *conversions.ShareData) {
s.UIDOwner = h.getUsername(ctx, c, s.UIDOwner)
s.UIDFileOwner = h.getUsername(ctx, c, s.UIDFileOwner)
s.ShareWith = h.getUsername(ctx, c, s.ShareWith)
if s.ShareWith != conversions.RedactedField {
s.ShareWith = h.getUsername(ctx, c, s.ShareWith)
}
}

func parseTimestamp(timestampString string) (*types.Timestamp, error) {
Expand Down

0 comments on commit a00412f

Please sign in to comment.