Skip to content

Commit

Permalink
Use email as displayname for external users opening WOPI apps
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Jun 20, 2022
1 parent 1ace372 commit feac68e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/wopi-ext-users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: use email as display name for external users opening WOPI apps

We use now the email claim for external/federated accounts as the
`username` that is then passed to the wopiserver and used as
`displayName` in the WOPI context.

https://github.com/cs3org/reva/pull/2986
18 changes: 11 additions & 7 deletions pkg/app/provider/wopi/wopi.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,24 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc

u, ok := ctxpkg.ContextGetUser(ctx)
if ok { // else defaults to "Guest xyz"
if u.Id.Type == userpb.UserType_USER_TYPE_LIGHTWEIGHT || u.Id.Type == userpb.UserType_USER_TYPE_FEDERATED {
q.Add("userid", resource.Owner.OpaqueId+"@"+resource.Owner.Idp)
} else {
q.Add("userid", u.Id.OpaqueId+"@"+u.Id.Idp)
}
var isPublicShare bool
if u.Opaque != nil {
if _, ok := u.Opaque.Map["public-share-role"]; ok {
isPublicShare = true
}
}

if !isPublicShare {
q.Add("username", u.Username)
if u.Id.Type == userpb.UserType_USER_TYPE_LIGHTWEIGHT || u.Id.Type == userpb.UserType_USER_TYPE_FEDERATED {
q.Add("userid", resource.Owner.OpaqueId+"@"+resource.Owner.Idp)
if !isPublicShare {
// for visual display, federated/external accounts are shown with their email but act on behalf of the owner
q.Add("username", u.Mail)
}
} else {
q.Add("userid", u.Id.OpaqueId+"@"+u.Id.Idp)
if !isPublicShare {
q.Add("username", u.Username)
}
}
}

Expand Down

0 comments on commit feac68e

Please sign in to comment.