Bump reva to latest main
to get https://github.com/opencloud-eu/reva/pull/339
This commit is contained in:
committed by
Ralf Haferkamp
parent
a5e0c1ec4b
commit
65228f3188
+3
-3
@@ -57,7 +57,7 @@ func (m *manager) Configure(ml map[string]interface{}) error {
|
||||
|
||||
func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if user, ok := m.catalog[uid.OpaqueId]; ok {
|
||||
if uid.Idp == "" || user.Id.Idp == uid.Idp {
|
||||
if user.GetId().GetTenantId() == uid.GetTenantId() && (uid.Idp == "" || user.Id.Idp == uid.Idp) {
|
||||
u := proto.Clone(user).(*userpb.User)
|
||||
if skipFetchingGroups {
|
||||
u.Groups = nil
|
||||
@@ -68,9 +68,9 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingG
|
||||
return nil, errtypes.NotFound(uid.OpaqueId)
|
||||
}
|
||||
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value, tenantID string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
for _, u := range m.catalog {
|
||||
if userClaim, err := extractClaim(u, claim); err == nil && value == userClaim {
|
||||
if userClaim, err := extractClaim(u, claim); err == nil && value == userClaim && tenantID == u.Id.TenantId {
|
||||
user := proto.Clone(u).(*userpb.User)
|
||||
if skipFetchingGroups {
|
||||
user.Groups = nil
|
||||
|
||||
+3
-3
@@ -97,7 +97,7 @@ func (m *manager) Configure(ml map[string]interface{}) error {
|
||||
|
||||
func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
for _, u := range m.users {
|
||||
if (u.Id.GetOpaqueId() == uid.OpaqueId || u.Username == uid.OpaqueId) && (uid.Idp == "" || uid.Idp == u.Id.GetIdp()) {
|
||||
if (u.Id.GetOpaqueId() == uid.OpaqueId || u.Username == uid.OpaqueId) && (uid.Idp == "" || uid.Idp == u.Id.GetIdp()) && (uid.GetTenantId() == u.Id.GetTenantId()) {
|
||||
user := proto.Clone(u).(*userpb.User)
|
||||
if skipFetchingGroups {
|
||||
user.Groups = nil
|
||||
@@ -108,9 +108,9 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingG
|
||||
return nil, errtypes.NotFound(uid.OpaqueId)
|
||||
}
|
||||
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value, tenantID string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
for _, u := range m.users {
|
||||
if userClaim, err := extractClaim(u, claim); err == nil && value == userClaim {
|
||||
if userClaim, err := extractClaim(u, claim); err == nil && value == userClaim && tenantID == u.Id.TenantId {
|
||||
user := proto.Clone(u).(*userpb.User)
|
||||
if skipFetchingGroups {
|
||||
user.Groups = nil
|
||||
|
||||
+36
-12
@@ -34,12 +34,15 @@ import (
|
||||
"github.com/opencloud-eu/reva/v2/pkg/utils"
|
||||
ldapIdentity "github.com/opencloud-eu/reva/v2/pkg/utils/ldap"
|
||||
"github.com/pkg/errors"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("ldap", New)
|
||||
}
|
||||
|
||||
const tracerName = "pkg/user/manager/ldap"
|
||||
|
||||
type manager struct {
|
||||
c *config
|
||||
ldapClient ldap.Client
|
||||
@@ -96,15 +99,22 @@ func (m *manager) Configure(ml map[string]interface{}) error {
|
||||
|
||||
// GetUser implements the user.Manager interface. Looks up a user by Id and return the user
|
||||
func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
log := appctx.GetLogger(ctx)
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "GetUser")
|
||||
defer span.End()
|
||||
|
||||
span.SetAttributes(
|
||||
attribute.Stringer("parameter.userid", uid),
|
||||
attribute.Bool("parameter.skipFetchingGroups", skipFetchingGroups),
|
||||
)
|
||||
|
||||
log := appctx.GetLogger(ctx)
|
||||
log.Debug().Interface("id", uid).Msg("GetUser")
|
||||
// If the Idp value in the uid does not match our config, we can't answer this request
|
||||
if uid.Idp != "" && uid.Idp != m.c.Idp {
|
||||
return nil, errtypes.NotFound("idp mismatch")
|
||||
}
|
||||
|
||||
userEntry, err := m.c.LDAPIdentity.GetLDAPUserByID(log, m.ldapClient, uid.OpaqueId)
|
||||
userEntry, err := m.c.LDAPIdentity.GetLDAPUserByID(ctx, m.ldapClient, uid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -120,7 +130,7 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingG
|
||||
return u, nil
|
||||
}
|
||||
|
||||
groups, err := m.c.LDAPIdentity.GetLDAPUserGroups(log, m.ldapClient, userEntry)
|
||||
groups, err := m.c.LDAPIdentity.GetLDAPUserGroups(ctx, m.ldapClient, userEntry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -131,11 +141,18 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingG
|
||||
|
||||
// GetUserByClaim implements the user.Manager interface. Looks up a user by
|
||||
// claim ('mail', 'username', 'userid') and returns the user.
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value, tenantID string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
log := appctx.GetLogger(ctx)
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "GetUserByClaim")
|
||||
defer span.End()
|
||||
|
||||
span.SetAttributes(
|
||||
attribute.String("parameter.claim", claim),
|
||||
attribute.String("paramter.value", value),
|
||||
attribute.Bool("parameter.skipFetchingGroups", skipFetchingGroups),
|
||||
)
|
||||
log.Debug().Str("claim", claim).Str("value", value).Msg("GetUserByClaim")
|
||||
userEntry, err := m.c.LDAPIdentity.GetLDAPUserByAttribute(log, m.ldapClient, claim, value)
|
||||
userEntry, err := m.c.LDAPIdentity.GetLDAPUserByAttribute(ctx, m.ldapClient, claim, value, tenantID)
|
||||
if err != nil {
|
||||
log.Debug().Err(err).Msg("GetUserByClaim")
|
||||
return nil, err
|
||||
@@ -148,7 +165,7 @@ func (m *manager) GetUserByClaim(ctx context.Context, claim, value string, skipF
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if m.c.LDAPIdentity.IsLDAPUserInDisabledGroup(log, m.ldapClient, userEntry) {
|
||||
if m.c.LDAPIdentity.IsLDAPUserInDisabledGroup(ctx, m.ldapClient, userEntry) {
|
||||
return nil, errtypes.NotFound("user is locally disabled")
|
||||
}
|
||||
|
||||
@@ -156,7 +173,7 @@ func (m *manager) GetUserByClaim(ctx context.Context, claim, value string, skipF
|
||||
return u, nil
|
||||
}
|
||||
|
||||
groups, err := m.c.LDAPIdentity.GetLDAPUserGroups(log, m.ldapClient, userEntry)
|
||||
groups, err := m.c.LDAPIdentity.GetLDAPUserGroups(ctx, m.ldapClient, userEntry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -169,8 +186,15 @@ func (m *manager) GetUserByClaim(ctx context.Context, claim, value string, skipF
|
||||
// FindUser implements the user.Manager interface. Searches for users using a prefix-substring search on
|
||||
// the user attributes ('mail', 'username', 'displayname', 'userid') and returns the users.
|
||||
func (m *manager) FindUsers(ctx context.Context, query, tenantID string, skipFetchingGroups bool) ([]*userpb.User, error) {
|
||||
log := appctx.GetLogger(ctx)
|
||||
entries, err := m.c.LDAPIdentity.GetLDAPUsers(log, m.ldapClient, query, tenantID)
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "FindUsers")
|
||||
defer span.End()
|
||||
span.SetAttributes(
|
||||
attribute.String("parameter.query", query),
|
||||
attribute.String("parameter.tenantID", tenantID),
|
||||
attribute.Bool("parameter.skipFetchingGroups", skipFetchingGroups),
|
||||
)
|
||||
|
||||
entries, err := m.c.LDAPIdentity.GetLDAPUsers(ctx, m.ldapClient, query, tenantID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -183,7 +207,7 @@ func (m *manager) FindUsers(ctx context.Context, query, tenantID string, skipFet
|
||||
}
|
||||
|
||||
if !skipFetchingGroups {
|
||||
groups, err := m.c.LDAPIdentity.GetLDAPUserGroups(log, m.ldapClient, entry)
|
||||
groups, err := m.c.LDAPIdentity.GetLDAPUserGroups(ctx, m.ldapClient, entry)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -204,12 +228,12 @@ func (m *manager) GetUserGroups(ctx context.Context, uid *userpb.UserId) ([]stri
|
||||
log.Debug().Str("useridp", uid.Idp).Str("configured idp", m.c.Idp).Msg("IDP mismatch")
|
||||
return nil, errtypes.NotFound("idp mismatch")
|
||||
}
|
||||
userEntry, err := m.c.LDAPIdentity.GetLDAPUserByID(log, m.ldapClient, uid.OpaqueId)
|
||||
userEntry, err := m.c.LDAPIdentity.GetLDAPUserByID(ctx, m.ldapClient, uid)
|
||||
if err != nil {
|
||||
log.Debug().Err(err).Interface("userid", uid).Msg("Failed to lookup user")
|
||||
return []string{}, err
|
||||
}
|
||||
return m.c.LDAPIdentity.GetLDAPUserGroups(log, m.ldapClient, userEntry)
|
||||
return m.c.LDAPIdentity.GetLDAPUserGroups(ctx, m.ldapClient, userEntry)
|
||||
}
|
||||
|
||||
func (m *manager) ldapEntryToUser(entry *ldap.Entry) (*userpb.User, error) {
|
||||
|
||||
+8
-1
@@ -84,6 +84,9 @@ func (m *manager) Configure(ml map[string]interface{}) error {
|
||||
}
|
||||
|
||||
func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if uid.GetTenantId() != "" {
|
||||
return nil, errtypes.NotSupported("tenant filter not supported in memory user manager")
|
||||
}
|
||||
if user, ok := m.catalog[uid.OpaqueId]; ok {
|
||||
if uid.Idp == "" || user.ID.Idp == uid.Idp {
|
||||
u := *user
|
||||
@@ -106,7 +109,11 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingG
|
||||
return nil, errtypes.NotFound(uid.OpaqueId)
|
||||
}
|
||||
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value, tenantID string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if tenantID != "" {
|
||||
return nil, errtypes.NotSupported("tenant filter not supported in memory user manager")
|
||||
}
|
||||
|
||||
for _, u := range m.catalog {
|
||||
if userClaim, err := extractClaim(u, claim); err == nil && value == userClaim {
|
||||
user := &userpb.User{
|
||||
|
||||
+7
-1
@@ -151,6 +151,9 @@ func (um *Manager) Configure(ml map[string]interface{}) error {
|
||||
|
||||
// GetUser method as defined in https://github.com/cs3org/reva/blob/v1.13.0/pkg/user/user.go#L29-L35
|
||||
func (um *Manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if uid.GetTenantId() != "" {
|
||||
return nil, errtypes.NotSupported("tenant filter not supported in nextcloud user manager")
|
||||
}
|
||||
bodyStr, _ := json.Marshal(uid)
|
||||
_, respBody, err := um.do(ctx, Action{"GetUser", string(bodyStr)}, "unauthenticated")
|
||||
if err != nil {
|
||||
@@ -165,7 +168,10 @@ func (um *Manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetching
|
||||
}
|
||||
|
||||
// GetUserByClaim method as defined in https://github.com/cs3org/reva/blob/v1.13.0/pkg/user/user.go#L29-L35
|
||||
func (um *Manager) GetUserByClaim(ctx context.Context, claim, value string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
func (um *Manager) GetUserByClaim(ctx context.Context, claim, value, tenantID string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if tenantID != "" {
|
||||
return nil, errtypes.NotSupported("tenant filter not supported in nextcloud user manager")
|
||||
}
|
||||
type paramsObj struct {
|
||||
Claim string `json:"claim"`
|
||||
Value string `json:"value"`
|
||||
|
||||
Generated
Vendored
+8
-1
@@ -103,6 +103,9 @@ func parseConfig(m map[string]interface{}) (*config, error) {
|
||||
}
|
||||
|
||||
func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if uid.GetTenantId() != "" {
|
||||
return nil, errtypes.NotSupported("tenant filter not supported in opencloudsql user manager")
|
||||
}
|
||||
// search via the user_id
|
||||
a, err := m.db.GetAccountByClaim(ctx, "userid", uid.OpaqueId)
|
||||
if err == sql.ErrNoRows {
|
||||
@@ -111,7 +114,11 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingG
|
||||
return m.convertToCS3User(ctx, a, skipFetchingGroups)
|
||||
}
|
||||
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
func (m *manager) GetUserByClaim(ctx context.Context, claim, value, tenantID string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if tenantID != "" {
|
||||
return nil, errtypes.NotSupported("tenant filter not supported in opencloudsql user manager")
|
||||
}
|
||||
|
||||
a, err := m.db.GetAccountByClaim(ctx, claim, value)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, errtypes.NotFound(claim + "=" + value)
|
||||
|
||||
+9
-2
@@ -89,6 +89,9 @@ type GetUserReply struct {
|
||||
|
||||
// GetUser RPCClient GetUser method
|
||||
func (m *RPCClient) GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if uid.GetTenantId() != "" {
|
||||
return nil, errtypes.NotSupported("tenant filter not supported in rpc_user user manager")
|
||||
}
|
||||
ctxVal := appctx.GetKeyValuesFromCtx(ctx)
|
||||
args := GetUserArg{Ctx: ctxVal, UID: uid, SkipFetchingGroups: skipFetchingGroups}
|
||||
resp := GetUserReply{}
|
||||
@@ -114,7 +117,11 @@ type GetUserByClaimReply struct {
|
||||
}
|
||||
|
||||
// GetUserByClaim RPCClient GetUserByClaim method
|
||||
func (m *RPCClient) GetUserByClaim(ctx context.Context, claim, value string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
func (m *RPCClient) GetUserByClaim(ctx context.Context, claim, value, tenantID string, skipFetchingGroups bool) (*userpb.User, error) {
|
||||
if tenantID != "" {
|
||||
return nil, errtypes.NotSupported("tenant filter not supported in rpc_user user manager")
|
||||
}
|
||||
|
||||
ctxVal := appctx.GetKeyValuesFromCtx(ctx)
|
||||
args := GetUserByClaimArg{Ctx: ctxVal, Claim: claim, Value: value, SkipFetchingGroups: skipFetchingGroups}
|
||||
resp := GetUserByClaimReply{}
|
||||
@@ -200,7 +207,7 @@ func (m *RPCServer) GetUser(args GetUserArg, resp *GetUserReply) error {
|
||||
// GetUserByClaim RPCServer GetUserByClaim method
|
||||
func (m *RPCServer) GetUserByClaim(args GetUserByClaimArg, resp *GetUserByClaimReply) error {
|
||||
ctx := appctx.PutKeyValuesToCtx(args.Ctx)
|
||||
resp.User, resp.Err = m.Impl.GetUserByClaim(ctx, args.Claim, args.Value, args.SkipFetchingGroups)
|
||||
resp.User, resp.Err = m.Impl.GetUserByClaim(ctx, args.Claim, args.Value, "", args.SkipFetchingGroups)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ type Manager interface {
|
||||
// and might involve computational overhead.
|
||||
GetUser(ctx context.Context, uid *userpb.UserId, skipFetchingGroups bool) (*userpb.User, error)
|
||||
// GetUserByClaim returns the user identified by a specific value for a given claim.
|
||||
GetUserByClaim(ctx context.Context, claim, value string, skipFetchingGroups bool) (*userpb.User, error)
|
||||
GetUserByClaim(ctx context.Context, claim, value, tenantID string, skipFetchingGroups bool) (*userpb.User, error)
|
||||
// GetUserGroups returns the groups a user identified by a uid belongs to.
|
||||
GetUserGroups(ctx context.Context, uid *userpb.UserId) ([]string, error)
|
||||
// FindUsers returns all the user objects which match a query parameter.
|
||||
|
||||
Reference in New Issue
Block a user