| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | // Copyright (c) 2015-2021 MinIO, Inc.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This file is part of MinIO Object Storage stack
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This program is free software: you can redistribute it and/or modify
 | 
					
						
							|  |  |  | // it under the terms of the GNU Affero General Public License as published by
 | 
					
						
							|  |  |  | // the Free Software Foundation, either version 3 of the License, or
 | 
					
						
							|  |  |  | // (at your option) any later version.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					
						
							|  |  |  | // GNU Affero General Public License for more details.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU Affero General Public License
 | 
					
						
							|  |  |  | // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package cmd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"context" | 
					
						
							|  |  |  | 	"sync" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type iamDummyStore struct { | 
					
						
							|  |  |  | 	sync.RWMutex | 
					
						
							| 
									
										
										
										
											2021-11-04 10:47:49 +08:00
										 |  |  | 	*iamCache | 
					
						
							|  |  |  | 	usersSysType UsersSysType | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-04 10:47:49 +08:00
										 |  |  | func newIAMDummyStore(usersSysType UsersSysType) *iamDummyStore { | 
					
						
							|  |  |  | 	return &iamDummyStore{ | 
					
						
							|  |  |  | 		iamCache:     newIamCache(), | 
					
						
							|  |  |  | 		usersSysType: usersSysType, | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-11-02 12:58:07 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-04 10:47:49 +08:00
										 |  |  | func (ids *iamDummyStore) rlock() *iamCache { | 
					
						
							| 
									
										
										
										
											2021-11-03 04:51:42 +08:00
										 |  |  | 	ids.RLock() | 
					
						
							| 
									
										
										
										
											2021-11-04 10:47:49 +08:00
										 |  |  | 	return ids.iamCache | 
					
						
							| 
									
										
										
										
											2021-11-03 04:51:42 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) runlock() { | 
					
						
							|  |  |  | 	ids.RUnlock() | 
					
						
							| 
									
										
										
										
											2021-11-02 12:58:07 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-04 10:47:49 +08:00
										 |  |  | func (ids *iamDummyStore) lock() *iamCache { | 
					
						
							|  |  |  | 	ids.Lock() | 
					
						
							|  |  |  | 	return ids.iamCache | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) unlock() { | 
					
						
							|  |  |  | 	ids.Unlock() | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) getUsersSysType() UsersSysType { | 
					
						
							|  |  |  | 	return ids.usersSysType | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | func (ids *iamDummyStore) migrateBackendFormat(context.Context) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-12 01:03:39 +08:00
										 |  |  | func (ids *iamDummyStore) loadPolicyDoc(ctx context.Context, policy string, m map[string]PolicyDoc) error { | 
					
						
							| 
									
										
										
										
											2021-11-19 15:47:02 +08:00
										 |  |  | 	v, ok := ids.iamPolicyDocsMap[policy] | 
					
						
							|  |  |  | 	if !ok { | 
					
						
							|  |  |  | 		return errNoSuchPolicy | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	m[policy] = v | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-12 01:03:39 +08:00
										 |  |  | func (ids *iamDummyStore) loadPolicyDocs(ctx context.Context, m map[string]PolicyDoc) error { | 
					
						
							| 
									
										
										
										
											2021-11-19 15:47:02 +08:00
										 |  |  | 	for k, v := range ids.iamPolicyDocsMap { | 
					
						
							|  |  |  | 		m[k] = v | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-02 04:19:13 +08:00
										 |  |  | func (ids *iamDummyStore) loadUser(ctx context.Context, user string, userType IAMUserType, m map[string]UserIdentity) error { | 
					
						
							| 
									
										
										
										
											2021-11-19 15:47:02 +08:00
										 |  |  | 	u, ok := ids.iamUsersMap[user] | 
					
						
							|  |  |  | 	if !ok { | 
					
						
							|  |  |  | 		return errNoSuchUser | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ids.iamUsersMap[user] = u | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-02 04:19:13 +08:00
										 |  |  | func (ids *iamDummyStore) loadUsers(ctx context.Context, userType IAMUserType, m map[string]UserIdentity) error { | 
					
						
							| 
									
										
										
										
											2021-11-19 15:47:02 +08:00
										 |  |  | 	for k, v := range ids.iamUsersMap { | 
					
						
							|  |  |  | 		m[k] = v | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) loadGroup(ctx context.Context, group string, m map[string]GroupInfo) error { | 
					
						
							| 
									
										
										
										
											2021-11-19 15:47:02 +08:00
										 |  |  | 	g, ok := ids.iamGroupsMap[group] | 
					
						
							|  |  |  | 	if !ok { | 
					
						
							|  |  |  | 		return errNoSuchGroup | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	m[group] = g | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) loadGroups(ctx context.Context, m map[string]GroupInfo) error { | 
					
						
							| 
									
										
										
										
											2021-11-19 15:47:02 +08:00
										 |  |  | 	for k, v := range ids.iamGroupsMap { | 
					
						
							|  |  |  | 		m[k] = v | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) loadMappedPolicy(ctx context.Context, name string, userType IAMUserType, isGroup bool, m map[string]MappedPolicy) error { | 
					
						
							| 
									
										
										
										
											2021-11-19 15:47:02 +08:00
										 |  |  | 	if isGroup { | 
					
						
							|  |  |  | 		g, ok := ids.iamGroupPolicyMap[name] | 
					
						
							|  |  |  | 		if !ok { | 
					
						
							|  |  |  | 			return errNoSuchPolicy | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		m[name] = g | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		u, ok := ids.iamUserPolicyMap[name] | 
					
						
							|  |  |  | 		if !ok { | 
					
						
							|  |  |  | 			return errNoSuchPolicy | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		m[name] = u | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) loadMappedPolicies(ctx context.Context, userType IAMUserType, isGroup bool, m map[string]MappedPolicy) error { | 
					
						
							| 
									
										
										
										
											2021-11-19 15:47:02 +08:00
										 |  |  | 	if !isGroup { | 
					
						
							|  |  |  | 		for k, v := range ids.iamUserPolicyMap { | 
					
						
							|  |  |  | 			m[k] = v | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		for k, v := range ids.iamGroupPolicyMap { | 
					
						
							|  |  |  | 			m[k] = v | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) saveIAMConfig(ctx context.Context, item interface{}, path string, opts ...options) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) loadIAMConfig(ctx context.Context, item interface{}, path string) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) deleteIAMConfig(ctx context.Context, path string) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-12 01:03:39 +08:00
										 |  |  | func (ids *iamDummyStore) savePolicyDoc(ctx context.Context, policyName string, p PolicyDoc) error { | 
					
						
							| 
									
										
										
										
											2021-07-10 23:32:52 +08:00
										 |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) saveMappedPolicy(ctx context.Context, name string, userType IAMUserType, isGroup bool, mp MappedPolicy, opts ...options) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) saveUserIdentity(ctx context.Context, name string, userType IAMUserType, u UserIdentity, opts ...options) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) saveGroupInfo(ctx context.Context, group string, gi GroupInfo) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) deletePolicyDoc(ctx context.Context, policyName string) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) deleteMappedPolicy(ctx context.Context, name string, userType IAMUserType, isGroup bool) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) deleteUserIdentity(ctx context.Context, name string, userType IAMUserType) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (ids *iamDummyStore) deleteGroupInfo(ctx context.Context, name string) error { | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } |