github.com/polarismesh/polaris@v1.17.8/store/auth_api.go (about) 1 /** 2 * Tencent is pleased to support the open source community by making Polaris available. 3 * 4 * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 * 6 * Licensed under the BSD 3-Clause License (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * https://opensource.org/licenses/BSD-3-Clause 11 * 12 * Unless required by applicable law or agreed to in writing, software distributed 13 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 * specific language governing permissions and limitations under the License. 16 */ 17 18 package store 19 20 import ( 21 "time" 22 23 "github.com/polarismesh/polaris/common/model" 24 ) 25 26 // UserStore User-related operation interface 27 type UserStore interface { 28 // AddUser Create a user 29 AddUser(user *model.User) error 30 // UpdateUser Update user 31 UpdateUser(user *model.User) error 32 // DeleteUser delete users 33 DeleteUser(user *model.User) error 34 // GetSubCount Number of getting a child account 35 GetSubCount(user *model.User) (uint32, error) 36 // GetUser Obtain user 37 GetUser(id string) (*model.User, error) 38 // GetUserByName Get a unique user according to Name + Owner 39 GetUserByName(name, ownerId string) (*model.User, error) 40 // GetUserByIDS Get users according to USER IDS batch 41 GetUserByIds(ids []string) ([]*model.User, error) 42 // GetUsers Query user list 43 GetUsers(filters map[string]string, offset uint32, limit uint32) (uint32, []*model.User, error) 44 // GetUsersForCache Used to refresh user cache 45 // 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳 46 GetUsersForCache(mtime time.Time, firstUpdate bool) ([]*model.User, error) 47 } 48 49 // GroupStore User group storage operation interface 50 type GroupStore interface { 51 52 // AddGroup Add a user group 53 AddGroup(group *model.UserGroupDetail) error 54 55 // UpdateGroup Update user group 56 UpdateGroup(group *model.ModifyUserGroup) error 57 58 // DeleteGroup Delete user group 59 DeleteGroup(group *model.UserGroupDetail) error 60 61 // GetGroup Get user group details 62 GetGroup(id string) (*model.UserGroupDetail, error) 63 64 // GetGroupByName Get user groups according to Name and Owner 65 GetGroupByName(name, owner string) (*model.UserGroup, error) 66 67 // GetGroups Get a list of user groups 68 GetGroups(filters map[string]string, offset uint32, limit uint32) (uint32, []*model.UserGroup, error) 69 70 // GetUserGroupsForCache Refresh of getting user groups for cache 71 // 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳 72 GetGroupsForCache(mtime time.Time, firstUpdate bool) ([]*model.UserGroupDetail, error) 73 } 74 75 // StrategyStore Authentication policy related storage operation interface 76 type StrategyStore interface { 77 78 // AddStrategy Create authentication strategy 79 AddStrategy(strategy *model.StrategyDetail) error 80 81 // UpdateStrategy Update authentication strategy 82 UpdateStrategy(strategy *model.ModifyStrategyDetail) error 83 84 // DeleteStrategy Delete authentication strategy 85 DeleteStrategy(id string) error 86 87 // LooseAddStrategyResources Song requires the resources of the authentication strategy, 88 // allowing the issue of ignoring the primary key conflict 89 LooseAddStrategyResources(resources []model.StrategyResource) error 90 91 // RemoveStrategyResources Clean all the strategies associated with corresponding resources 92 RemoveStrategyResources(resources []model.StrategyResource) error 93 94 // GetStrategyResources Gets a Principal's corresponding resource ID data information 95 GetStrategyResources(principalId string, principalRole model.PrincipalType) ([]model.StrategyResource, error) 96 97 // GetDefaultStrategyDetailByPrincipal Get a default policy for a Principal 98 GetDefaultStrategyDetailByPrincipal(principalId string, 99 principalType model.PrincipalType) (*model.StrategyDetail, error) 100 101 // GetStrategyDetail Get strategy details 102 GetStrategyDetail(id string) (*model.StrategyDetail, error) 103 104 // GetStrategies Get a list of strategies 105 GetStrategies(filters map[string]string, offset uint32, limit uint32) (uint32, 106 []*model.StrategyDetail, error) 107 108 // GetStrategyDetailsForCache Used to refresh policy cache 109 // 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳 110 GetStrategyDetailsForCache(mtime time.Time, firstUpdate bool) ([]*model.StrategyDetail, error) 111 }