Skip to content

Commit

Permalink
cernbox: fix shares to external accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Sep 17, 2024
1 parent 122da0b commit 0a5f6d9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/cbox/utils/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package utils

import (
"database/sql"
"fmt"
"strings"
"time"

Expand Down Expand Up @@ -165,6 +166,14 @@ func IntToShareState(g int) collaboration.ShareState {

// FormatUserID formats a CS3API user ID to a string.
func FormatUserID(u *userpb.UserId) string {
if u.Type == userpb.UserType_USER_TYPE_LIGHTWEIGHT || u.Type == userpb.UserType_USER_TYPE_FEDERATED &&
!strings.Contains(u.OpaqueId, "guest:") && !strings.Contains(u.OpaqueId, "@") {
// in this case we have an external user, whose username does not contain some Idp identifier:
// this may happen for a SSO (e.g. the CERN SSO) that allows to register external accounts via email
// and generates regular usernames, but leaving uid = null. here we decorate those usernames
// so that ExtractUserID below can do the reverse identification:
return fmt.Sprintf("%s@localidp", u.OpaqueId)
}
return u.OpaqueId
}

Expand Down

0 comments on commit 0a5f6d9

Please sign in to comment.