@ -411,8 +411,8 @@ func (sys *IAMSys) doIAMConfigMigration(ctx context.Context) error {
// Loads IAM users and policies in background, any un-handled
// Loads IAM users and policies in background, any un-handled
// error means this code can potentially crash the server
// error means this code can potentially crash the server
// in such a situation manual intervention is necessary.
// in such a situation manual intervention is necessary.
func startBackgroundIAMLoad ( ctx context . Context ) {
func startBackgroundIAMLoad ( ctx context . Context , objAPI ObjectLayer ) {
go globalIAMSys . Init ( ctx , newObjectLayerWithoutSafeModeFn ( ) )
go globalIAMSys . Init ( ctx , objAPI )
}
}
// Init - initializes config system by reading entries from config/iam
// Init - initializes config system by reading entries from config/iam
@ -514,7 +514,7 @@ func (sys *IAMSys) Init(ctx context.Context, objAPI ObjectLayer) {
// DeletePolicy - deletes a canned policy from backend or etcd.
// DeletePolicy - deletes a canned policy from backend or etcd.
func ( sys * IAMSys ) DeletePolicy ( policyName string ) error {
func ( sys * IAMSys ) DeletePolicy ( policyName string ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -567,7 +567,7 @@ func (sys *IAMSys) DeletePolicy(policyName string) error {
// InfoPolicy - expands the canned policy into its JSON structure.
// InfoPolicy - expands the canned policy into its JSON structure.
func ( sys * IAMSys ) InfoPolicy ( policyName string ) ( iampolicy . Policy , error ) {
func ( sys * IAMSys ) InfoPolicy ( policyName string ) ( iampolicy . Policy , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return iampolicy . Policy { } , errServerNotInitialized
return iampolicy . Policy { } , errServerNotInitialized
}
}
@ -585,7 +585,7 @@ func (sys *IAMSys) InfoPolicy(policyName string) (iampolicy.Policy, error) {
// ListPolicies - lists all canned policies.
// ListPolicies - lists all canned policies.
func ( sys * IAMSys ) ListPolicies ( ) ( map [ string ] iampolicy . Policy , error ) {
func ( sys * IAMSys ) ListPolicies ( ) ( map [ string ] iampolicy . Policy , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return nil , errServerNotInitialized
return nil , errServerNotInitialized
}
}
@ -607,7 +607,7 @@ func (sys *IAMSys) ListPolicies() (map[string]iampolicy.Policy, error) {
// SetPolicy - sets a new name policy.
// SetPolicy - sets a new name policy.
func ( sys * IAMSys ) SetPolicy ( policyName string , p iampolicy . Policy ) error {
func ( sys * IAMSys ) SetPolicy ( policyName string , p iampolicy . Policy ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -629,7 +629,7 @@ func (sys *IAMSys) SetPolicy(policyName string, p iampolicy.Policy) error {
// DeleteUser - delete user (only for long-term users not STS users).
// DeleteUser - delete user (only for long-term users not STS users).
func ( sys * IAMSys ) DeleteUser ( accessKey string ) error {
func ( sys * IAMSys ) DeleteUser ( accessKey string ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -699,7 +699,7 @@ func (sys *IAMSys) currentPolicies(policyName string) string {
// SetTempUser - set temporary user credentials, these credentials have an expiry.
// SetTempUser - set temporary user credentials, these credentials have an expiry.
func ( sys * IAMSys ) SetTempUser ( accessKey string , cred auth . Credentials , policyName string ) error {
func ( sys * IAMSys ) SetTempUser ( accessKey string , cred auth . Credentials , policyName string ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -749,7 +749,7 @@ func (sys *IAMSys) SetTempUser(accessKey string, cred auth.Credentials, policyNa
// ListUsers - list all users.
// ListUsers - list all users.
func ( sys * IAMSys ) ListUsers ( ) ( map [ string ] madmin . UserInfo , error ) {
func ( sys * IAMSys ) ListUsers ( ) ( map [ string ] madmin . UserInfo , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return nil , errServerNotInitialized
return nil , errServerNotInitialized
}
}
@ -786,7 +786,7 @@ func (sys *IAMSys) ListUsers() (map[string]madmin.UserInfo, error) {
// IsTempUser - returns if given key is a temporary user.
// IsTempUser - returns if given key is a temporary user.
func ( sys * IAMSys ) IsTempUser ( name string ) ( bool , error ) {
func ( sys * IAMSys ) IsTempUser ( name string ) ( bool , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return false , errServerNotInitialized
return false , errServerNotInitialized
}
}
@ -804,7 +804,7 @@ func (sys *IAMSys) IsTempUser(name string) (bool, error) {
// IsServiceAccount - returns if given key is a service account
// IsServiceAccount - returns if given key is a service account
func ( sys * IAMSys ) IsServiceAccount ( name string ) ( bool , string , error ) {
func ( sys * IAMSys ) IsServiceAccount ( name string ) ( bool , string , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return false , "" , errServerNotInitialized
return false , "" , errServerNotInitialized
}
}
@ -826,7 +826,7 @@ func (sys *IAMSys) IsServiceAccount(name string) (bool, string, error) {
// GetUserInfo - get info on a user.
// GetUserInfo - get info on a user.
func ( sys * IAMSys ) GetUserInfo ( name string ) ( u madmin . UserInfo , err error ) {
func ( sys * IAMSys ) GetUserInfo ( name string ) ( u madmin . UserInfo , err error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return u , errServerNotInitialized
return u , errServerNotInitialized
}
}
@ -872,7 +872,7 @@ func (sys *IAMSys) GetUserInfo(name string) (u madmin.UserInfo, err error) {
// SetUserStatus - sets current user status, supports disabled or enabled.
// SetUserStatus - sets current user status, supports disabled or enabled.
func ( sys * IAMSys ) SetUserStatus ( accessKey string , status madmin . AccountStatus ) error {
func ( sys * IAMSys ) SetUserStatus ( accessKey string , status madmin . AccountStatus ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -918,7 +918,7 @@ func (sys *IAMSys) SetUserStatus(accessKey string, status madmin.AccountStatus)
// NewServiceAccount - create a new service account
// NewServiceAccount - create a new service account
func ( sys * IAMSys ) NewServiceAccount ( ctx context . Context , parentUser string , sessionPolicy * iampolicy . Policy ) ( auth . Credentials , error ) {
func ( sys * IAMSys ) NewServiceAccount ( ctx context . Context , parentUser string , sessionPolicy * iampolicy . Policy ) ( auth . Credentials , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return auth . Credentials { } , errServerNotInitialized
return auth . Credentials { } , errServerNotInitialized
}
}
@ -985,7 +985,7 @@ func (sys *IAMSys) NewServiceAccount(ctx context.Context, parentUser string, ses
// ListServiceAccounts - lists all services accounts associated to a specific user
// ListServiceAccounts - lists all services accounts associated to a specific user
func ( sys * IAMSys ) ListServiceAccounts ( ctx context . Context , accessKey string ) ( [ ] string , error ) {
func ( sys * IAMSys ) ListServiceAccounts ( ctx context . Context , accessKey string ) ( [ ] string , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return nil , errServerNotInitialized
return nil , errServerNotInitialized
}
}
@ -1010,7 +1010,7 @@ func (sys *IAMSys) ListServiceAccounts(ctx context.Context, accessKey string) ([
// GetServiceAccountParent - gets information about a service account
// GetServiceAccountParent - gets information about a service account
func ( sys * IAMSys ) GetServiceAccountParent ( ctx context . Context , accessKey string ) ( string , error ) {
func ( sys * IAMSys ) GetServiceAccountParent ( ctx context . Context , accessKey string ) ( string , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return "" , errServerNotInitialized
return "" , errServerNotInitialized
}
}
@ -1027,7 +1027,7 @@ func (sys *IAMSys) GetServiceAccountParent(ctx context.Context, accessKey string
// DeleteServiceAccount - delete a service account
// DeleteServiceAccount - delete a service account
func ( sys * IAMSys ) DeleteServiceAccount ( ctx context . Context , accessKey string ) error {
func ( sys * IAMSys ) DeleteServiceAccount ( ctx context . Context , accessKey string ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -1056,7 +1056,7 @@ func (sys *IAMSys) DeleteServiceAccount(ctx context.Context, accessKey string) e
// SetUser - set user credentials and policy.
// SetUser - set user credentials and policy.
func ( sys * IAMSys ) SetUser ( accessKey string , uinfo madmin . UserInfo ) error {
func ( sys * IAMSys ) SetUser ( accessKey string , uinfo madmin . UserInfo ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -1094,7 +1094,7 @@ func (sys *IAMSys) SetUser(accessKey string, uinfo madmin.UserInfo) error {
// SetUserSecretKey - sets user secret key
// SetUserSecretKey - sets user secret key
func ( sys * IAMSys ) SetUserSecretKey ( accessKey string , secretKey string ) error {
func ( sys * IAMSys ) SetUserSecretKey ( accessKey string , secretKey string ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -1123,7 +1123,7 @@ func (sys *IAMSys) SetUserSecretKey(accessKey string, secretKey string) error {
// GetUser - get user credentials
// GetUser - get user credentials
func ( sys * IAMSys ) GetUser ( accessKey string ) ( cred auth . Credentials , ok bool ) {
func ( sys * IAMSys ) GetUser ( accessKey string ) ( cred auth . Credentials , ok bool ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return cred , false
return cred , false
}
}
@ -1187,7 +1187,7 @@ func (sys *IAMSys) GetUser(accessKey string) (cred auth.Credentials, ok bool) {
// AddUsersToGroup - adds users to a group, creating the group if
// AddUsersToGroup - adds users to a group, creating the group if
// needed. No error if user(s) already are in the group.
// needed. No error if user(s) already are in the group.
func ( sys * IAMSys ) AddUsersToGroup ( group string , members [ ] string ) error {
func ( sys * IAMSys ) AddUsersToGroup ( group string , members [ ] string ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -1248,7 +1248,7 @@ func (sys *IAMSys) AddUsersToGroup(group string, members []string) error {
// RemoveUsersFromGroup - remove users from group. If no users are
// RemoveUsersFromGroup - remove users from group. If no users are
// given, and the group is empty, deletes the group as well.
// given, and the group is empty, deletes the group as well.
func ( sys * IAMSys ) RemoveUsersFromGroup ( group string , members [ ] string ) error {
func ( sys * IAMSys ) RemoveUsersFromGroup ( group string , members [ ] string ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -1329,7 +1329,7 @@ func (sys *IAMSys) RemoveUsersFromGroup(group string, members []string) error {
// SetGroupStatus - enable/disabled a group
// SetGroupStatus - enable/disabled a group
func ( sys * IAMSys ) SetGroupStatus ( group string , enabled bool ) error {
func ( sys * IAMSys ) SetGroupStatus ( group string , enabled bool ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -1365,7 +1365,7 @@ func (sys *IAMSys) SetGroupStatus(group string, enabled bool) error {
// GetGroupDescription - builds up group description
// GetGroupDescription - builds up group description
func ( sys * IAMSys ) GetGroupDescription ( group string ) ( gd madmin . GroupDesc , err error ) {
func ( sys * IAMSys ) GetGroupDescription ( group string ) ( gd madmin . GroupDesc , err error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return gd , errServerNotInitialized
return gd , errServerNotInitialized
}
}
@ -1406,7 +1406,7 @@ func (sys *IAMSys) GetGroupDescription(group string) (gd madmin.GroupDesc, err e
// ListGroups - lists groups.
// ListGroups - lists groups.
func ( sys * IAMSys ) ListGroups ( ) ( r [ ] string , err error ) {
func ( sys * IAMSys ) ListGroups ( ) ( r [ ] string , err error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return r , errServerNotInitialized
return r , errServerNotInitialized
}
}
@ -1430,7 +1430,7 @@ func (sys *IAMSys) ListGroups() (r []string, err error) {
// PolicyDBSet - sets a policy for a user or group in the PolicyDB.
// PolicyDBSet - sets a policy for a user or group in the PolicyDB.
func ( sys * IAMSys ) PolicyDBSet ( name , policy string , isGroup bool ) error {
func ( sys * IAMSys ) PolicyDBSet ( name , policy string , isGroup bool ) error {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return errServerNotInitialized
return errServerNotInitialized
}
}
@ -1497,7 +1497,7 @@ func (sys *IAMSys) policyDBSet(name, policyName string, userType IAMUserType, is
// be a member of multiple groups, this function returns an array of
// be a member of multiple groups, this function returns an array of
// applicable policies (each group is mapped to at most one policy).
// applicable policies (each group is mapped to at most one policy).
func ( sys * IAMSys ) PolicyDBGet ( name string , isGroup bool ) ( [ ] string , error ) {
func ( sys * IAMSys ) PolicyDBGet ( name string , isGroup bool ) ( [ ] string , error ) {
objectAPI := newObjectLayerWithoutSafeMode Fn ( )
objectAPI := newObjectLayerFn ( )
if objectAPI == nil || sys == nil || sys . store == nil {
if objectAPI == nil || sys == nil || sys . store == nil {
return nil , errServerNotInitialized
return nil , errServerNotInitialized
}
}