Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better display name in apps for all user types #3280

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/ext-users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: better display name in apps for all user types

This includes a `FirstName FamilyName (domain)` format for non-primary accounts,
and a sanitization of the email address claim for such non-primary accounts.

https://github.com/cs3org/reva/pull/2986
https://github.com/cs3org/reva/pull/3280
24 changes: 8 additions & 16 deletions pkg/app/provider/wopi/wopi.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,24 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc
q.Add("fileid", resource.GetId().OpaqueId)
q.Add("endpoint", resource.GetId().StorageId)
q.Add("viewmode", viewMode.String())
q.Add("appname", p.conf.AppName)

u, ok := ctxpkg.ContextGetUser(ctx)
if ok { // else defaults to "Guest xyz"
var isPublicShare bool
if u.Opaque != nil {
if _, ok := u.Opaque.Map["public-share-role"]; ok {
isPublicShare = true
}
}

if ok { // else username 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)
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)
}

q.Add("username", u.DisplayName)
if u.Opaque != nil {
if _, ok := u.Opaque.Map["public-share-role"]; ok {
q.Del("username") // on public shares default to "Guest xyz"
}
}
}

q.Add("appname", p.conf.AppName)

var viewAppURL string
if viewAppURLs, ok := p.appURLs["view"]; ok {
if viewAppURL, ok = viewAppURLs[ext]; ok {
Expand Down
4 changes: 4 additions & 0 deletions pkg/auth/manager/oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ func (am *mgr) Authenticate(ctx context.Context, clientID, clientSecret string)
if err != nil {
return nil, nil, err
}
// strip the `guest:` prefix if present in the email claim (appears to come from LDAP at CERN?)
u.Mail = strings.Replace(u.Mail, "guest: ", "", 1)
// and decorate the display name with the email domain to make it different from a primary account
u.DisplayName = u.DisplayName + " (" + strings.Split(u.Mail, "@")[1] + ")"
} else {
scopes, err = scope.AddOwnerScope(nil)
if err != nil {
Expand Down