Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
use on_premises_sam_account_name property of accounts and groups
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Jul 9, 2020
1 parent 503e7c5 commit 19716c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/user-and-group-name-mapping
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Change: mint on_premises_sam_account_name property of accounts and groups in the reva token

An accounts username is now taken from the on_premises_sam_account_name property instead of the preferred_name.
Furthermore the group name (also from on_premises_sam_account_name property) is now minted into the token as well.

https://github.com/owncloud/ocis-proxy/pull/62
19 changes: 13 additions & 6 deletions pkg/middleware/account_uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ func createAccount(l log.Logger, claims *oidc.StandardClaims, ac acc.AccountsSer
// TODO check if fields are missing.
req := &acc.CreateAccountRequest{
Account: &acc.Account{
DisplayName: claims.DisplayName,
PreferredName: claims.PreferredUsername,
Mail: claims.Email,
CreationType: "LocalAccount",
DisplayName: claims.DisplayName,
PreferredName: claims.PreferredUsername,
OnPremisesSamAccountName: claims.PreferredUsername,
Mail: claims.Email,
CreationType: "LocalAccount",
},
}
created, err := ac.CreateAccount(context.Background(), req)
Expand Down Expand Up @@ -125,16 +126,22 @@ func AccountUUID(opts ...Option) func(next http.Handler) http.Handler {
return
}

groups := make([]string, len(account.MemberOf))
for i := range account.MemberOf {
// reva needs the unix group name
groups[i] = account.MemberOf[i].OnPremisesSamAccountName
}

l.Debug().Interface("claims", claims).Interface("account", account).Msgf("Associated claims with uuid")
token, err := tokenManager.MintToken(r.Context(), &revauser.User{
Id: &revauser.UserId{
OpaqueId: account.Id,
},
Username: account.PreferredName,
Username: account.OnPremisesSamAccountName,
DisplayName: account.DisplayName,
Mail: account.Mail,
MailVerified: account.ExternalUserState == "" || account.ExternalUserState == "Accepted",
// TODO groups
Groups: groups,
})

if err != nil {
Expand Down

0 comments on commit 19716c3

Please sign in to comment.