Skip to content

Commit

Permalink
fix(autoprov): make email optional
Browse files Browse the repository at this point in the history
The mail address is not a required attrbute for our users. So we can auto-provision users without it.

Fixes: #6909
  • Loading branch information
rhafer committed Apr 24, 2024
1 parent db2c91f commit 5f61825
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 15 additions & 0 deletions changelog/unreleased/config-autoprovision-claims.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Enhancement: Introduce config for the claims to use for auto-provisioning user accounts

We introduce the new environment variables
"PROXY_AUTO_PROVISION_CLAIM_USERNAME", "PROXY_AUTO_PROVISION_CLAIM_EMAIL", and
"PROXY_AUTO_PROVISION_CLAIM_DISPLAYNAME" which can be used to configure the
OIDC claims that should be used for auto-provisioning user accounts.

The automatic fallback to use the 'email' claim value as the username when
the 'preferred_username' claim is not set, has been removed.

Also it is now possible to autoprovision users without an email address.

https://github.com/owncloud/ocis/pull/xxxx
https://github.com/owncloud/ocis/issues/8635
https://github.com/owncloud/ocis/issues/6909
9 changes: 4 additions & 5 deletions services/proxy/pkg/user/backend/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,15 @@ func (c cs3backend) libregraphUserFromClaims(ctx context.Context, claims map[str
} else {
return user, fmt.Errorf("Missing claim '%s' (displayName)", c.autoProvisionClaims.DisplayName)
}
if mail, ok := claims[c.autoProvisionClaims.Email].(string); ok {
user.SetMail(mail)
} else {
return user, fmt.Errorf("Missing claim '%s' (mail)", c.autoProvisionClaims.Email)
}
if username, ok := claims[c.autoProvisionClaims.Username].(string); ok {
user.SetOnPremisesSamAccountName(username)
} else {
return user, fmt.Errorf("Missing claim '%s' (username)", c.autoProvisionClaims.Username)
}
// Email is optional so we don't need an 'else' here
if mail, ok := claims[c.autoProvisionClaims.Email].(string); ok {
user.SetMail(mail)
}
return user, nil
}

Expand Down

0 comments on commit 5f61825

Please sign in to comment.