Compare commits

...

10 Commits

Author SHA1 Message Date
Liujian 85971447e1 update i18n 2024-10-29 14:19:36 +08:00
Liujian 087e598be0 update remark 2024-10-28 18:39:55 +08:00
Liujian d3d05ef539 Merge remote-tracking branch 'github-pro/main' into feature/permission
# Conflicts:
#	resources/access/access.yaml
2024-10-28 18:33:42 +08:00
Liujian 7949748951 update permission 2024-10-28 18:27:37 +08:00
Maggie 0d737bad57 Merge pull request #111 from APIParkLab/feature/v1.2
Feature/v1.2
2024-10-28 16:22:58 +08:00
maggieyyy e5d85bb3df fix: Modify access fields 2024-10-28 16:15:38 +08:00
maggieyyy 0f0204b647 fix: cosumer list bug 2024-10-28 16:00:15 +08:00
maggieyyy 44f0b70461 fix: Consumer list bugs 2024-10-28 15:44:10 +08:00
Dot.L 588cf839e3 Merge pull request #110 from APIParkLab/feature/translate
Feature/translate
2024-10-28 15:07:35 +08:00
Dot.L b0b9affbe7 Merge pull request #1 from Dot-Liu/feature/translate
Feature/translate
2024-10-28 10:01:46 +08:00
18 changed files with 186 additions and 155 deletions
-1
View File
@@ -3,4 +3,3 @@
/config.yml
/build/
/apipark
/aoplatform
@@ -296,12 +296,12 @@ export const PERMISSION_DEFINITION = [
},
"team.service.service_intro.add": {
"granted": {
"anyOf": [{ "backend": [" team.service.service_intro.manager"] }]
"anyOf": [{ "backend": ["team.service.service_intro.manager"] }]
}
},
"team.service.service_intro.edit": {
"granted": {
"anyOf": [{ "backend": [" team.service.service_intro.manager"] }]
"anyOf": [{ "backend": ["team.service.service_intro.manager"] }]
}
},
"team.service.api_doc.import": {
@@ -58,7 +58,6 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
const {code,data,msg} = response
if(code === STATUS_CODE.SUCCESS){
setLlmList(data.llms)
console.log(data)
form.setFieldsValue({
id:data.provider.defaultLlm,
config:data.llms.find(x=>x.id===data.provider.defaultLlm)?.config})
@@ -37,13 +37,14 @@ export default function ServiceHubManagement() {
const [tableListDataSource, setTableListDataSource] = useState<ServiceHubAppListItem[]>([]);
const [tableSearchWord, setTableSearchWord] = useState<string>('')
const getServiceList = ()=>{
const getServiceList = (dataType?:'block'|'list')=>{
dataType = dataType ?? dataShowType
if(!accessInit){
getGlobalAccessData()?.then?.(()=>{getServiceList()})
getGlobalAccessData()?.then?.(()=>{getServiceList(dataType)})
return Promise.resolve({data:[], success:false})
}
if(dataShowType === 'list' && !tableHttpReload){
if(dataType === 'list' && !tableHttpReload){
setTableHttpReload(true)
return Promise.resolve({
data: tableListDataSource,
@@ -52,7 +53,7 @@ const getServiceList = ()=>{
}
setServiceLoading(true)
return fetchData<BasicResponse<{apps:ServiceHubAppListItem}>>(!checkPermission('system.workspace.application.view_all') ? 'my_apps':'apps',{method:'GET',eoParams:{ team:teamId,keyword:tableSearchWord},eoTransformKeys:['api_num','subscribe_num','subscribe_verify_num','auth_num']}).then(response=>{
return fetchData<BasicResponse<{apps:ServiceHubAppListItem}>>(!checkPermission('system.workspace.application.view_all') ? 'my_apps':'apps',{method:'GET',eoParams:{ team: dataType === 'list' ? undefined : teamId,keyword:tableSearchWord},eoTransformKeys:['api_num','subscribe_num','subscribe_verify_num','auth_num']}).then(response=>{
const {code,data,msg} = response
if(code === STATUS_CODE.SUCCESS){
setServiceList([...data.apps,{type:'addNewItem'}])
@@ -75,28 +76,69 @@ const getServiceList = ()=>{
};
const getTeamsList = ()=>{
if(!accessInit){
setTimeout(()=>{
getGlobalAccessData()?.then?.(()=>{getTeamsList()})
},200)
return
}
setPageLoading(true)
fetchData<BasicResponse<{ teams: SimpleTeamItem[] }>>(!checkPermission('system.workspace.team.view_all') ?'simple/teams/mine' :'simple/teams',{method:'GET',eoTransformKeys:['app_num','subscribe_num']}).then(response=>{
const {code,data,msg} = response
if(code === STATUS_CODE.SUCCESS){
setTeamList(data.teams.map((x:SimpleTeamItem)=>({label:<div className="flex items-center justify-between "><span className="w-[calc(100%-42px)] truncate" title={x.name}>{x.name}</span><span className="bg-[#fff] rounded-[5px] h-[20px] w-[30px] flex items-center justify-center">{x.appNum || 0}</span></div>, key:x.id})))
if(!teamId && data.teams?.[0]?.id){
navigateTo(data.teams[0].id)
const getTeamsList = () => {
setPageLoading(true);
const fetchTeams = () => {
fetchData<BasicResponse<{ teams: SimpleTeamItem[] }>>(
!checkPermission('system.workspace.team.view_all')
? 'simple/teams/mine'
: 'simple/teams',
{
method: 'GET',
eoTransformKeys: ['app_num', 'subscribe_num'],
}
}else{
message.error(msg || $t(RESPONSE_TIPS.error))
}
}).finally(()=>{
setPageLoading(false)
})
}
)
.then(response => {
const { code, data, msg } = response;
if (code === STATUS_CODE.SUCCESS) {
setTeamList(
data.teams.map((x: SimpleTeamItem) => ({
label: (
<div className="flex items-center justify-between">
<span className="w-[calc(100%-42px)] truncate" title={x.name}>
{x.name}
</span>
<span className="bg-[#fff] rounded-[5px] h-[20px] w-[30px] flex items-center justify-center">
{x.appNum || 0}
</span>
</div>
),
key: x.id,
}))
);
if (!teamId && data.teams?.[0]?.id) {
navigateTo(data.teams[0].id);
}
} else {
message.error(msg || $t(RESPONSE_TIPS.error));
}
})
.finally(() => {
setPageLoading(false);
});
};
if (!accessInit) {
const checkAccessData = () => {
const accessInitd = getGlobalAccessData();
if (!accessInitd) {
setTimeout(checkAccessData, 100);
return;
}
if (typeof accessInitd.then === 'function') {
accessInitd.then(fetchTeams);
} else {
fetchTeams();
}
};
checkAccessData();
} else {
fetchTeams();
}
};
const openModal = async (type:'add'|'edit'|'delete')=>{
@@ -169,7 +211,6 @@ useEffect(() => {
)
getTeamsList()
setAppName('')
console.log()
}, []);
@@ -244,13 +285,13 @@ useEffect(() => {
customBtn={
<Radio.Group
options={dataShowTypeOptions}
onChange={(e)=>setDataShowType(e.target.value)}
onChange={(e)=>{setDataShowType(e.target.value); setTableHttpReload(true); if(e.target.value === 'block'){getServiceList(e.target.value)}}}
value={dataShowType}
optionType="button"
buttonStyle="solid"
/>}
>{
dataShowType === 'block' ? <BlockArea /> : <TableArea language={state.language} getServiceList={getServiceList} addNewApp={()=>openModal('add')} setTableHttpReload={setTableHttpReload} setTableSearchWord={setTableSearchWord} editApp={(row:ServiceHubAppListItem)=>{setAppName(row.name);navigateTo(`/consumer/${row.team.id}/inside/${row.id}/service`)}}/>
dataShowType === 'block' ? <BlockArea /> : <TableArea language={state.language} getServiceList={()=>getServiceList('list')} addNewApp={()=>openModal('add')} setTableHttpReload={setTableHttpReload} setTableSearchWord={setTableSearchWord} editApp={(row:ServiceHubAppListItem)=>{setAppName(row.name);navigateTo(`/consumer/${row.team.id}/inside/${row.id}/service`)}}/>
}
</InsidePage> :
<Empty className="mt-[100px]" image={Empty.PRESENTED_IMAGE_SIMPLE} />
+1
View File
@@ -1,5 +1,6 @@
package main
// init module
import (
_ "github.com/APIParkLab/APIPark/frontend"
_ "github.com/APIParkLab/APIPark/gateway/apinto"
-1
View File
@@ -9,5 +9,4 @@ import (
)
func doCheck() {
}
+14 -14
View File
@@ -6,6 +6,11 @@ import (
"bytes"
"encoding/csv"
"fmt"
"os"
"sort"
"strings"
"time"
_ "github.com/APIParkLab/APIPark/resources/access"
_ "github.com/APIParkLab/APIPark/resources/permit"
_ "github.com/APIParkLab/APIPark/resources/plugin"
@@ -14,19 +19,15 @@ import (
"github.com/eolinker/go-common/permit"
"github.com/eolinker/go-common/pm3"
"github.com/eolinker/go-common/utils"
"os"
"sort"
"strings"
"time"
)
const unsetValue = "-"
func doCheck() {
accessConf, unset := loadAccess()
drivers := pm3.List()
newAccess := 0
for _, p := range drivers {
if ac, ok := p.(pm3.AccessConfig); ok {
@@ -39,9 +40,9 @@ func doCheck() {
}
}
}
}
}
for asKey := range permit.All() {
key := strings.ToLower(asKey)
@@ -53,12 +54,11 @@ func doCheck() {
if newAccess > 0 || unset > 0 {
f := accessFile()
fmt.Printf("%d access need set, see : %s and %s", newAccess+unset, saveTemplate(accessConf, f), saveCsv(accessConf, f))
}
os.Exit(0)
}
func accessFile() string {
if version == "" {
return time.Now().Format("20060102-150405")
}
@@ -84,7 +84,7 @@ func saveCsv(as map[string]*Access, key string) string {
err = os.WriteFile(filePath, buf.Bytes(), 0666)
if err != nil {
log.Fatal(err)
}
return filePath
}
@@ -111,9 +111,9 @@ func (ls AccessListSort) Swap(i, j int) {
func saveTemplate(as map[string]*Access, key string) string {
out := make(map[string][]access.Access)
for _, a := range as {
out[a.Group] = append(out[a.Group], access.Access{
Name: a.Name,
CName: a.Cname,
@@ -130,7 +130,7 @@ func saveTemplate(as map[string]*Access, key string) string {
err = os.WriteFile(filePath, buf.Bytes(), 0666)
if err != nil {
log.Fatal(err)
}
return filePath
}
+3 -3
View File
@@ -3,13 +3,14 @@ package main
import (
"flag"
"fmt"
"net"
"net/http"
"github.com/eolinker/eosc/log"
"github.com/eolinker/go-common/autowire"
"github.com/eolinker/go-common/cftool"
"github.com/eolinker/go-common/permit"
"github.com/eolinker/go-common/server"
"net"
"net/http"
)
var (
@@ -54,7 +55,6 @@ func main() {
for access, paths := range srv.Permits() {
permit.AddPermitRule(access, paths...)
}
err = http.Serve(ln, srv)
if err != nil {
log.Fatal(err)
+5 -10
View File
@@ -3,7 +3,7 @@ package permit_middleware
import (
"net/http"
"reflect"
permit_identity "github.com/APIParkLab/APIPark/middleware/permit/identity"
"github.com/eolinker/eosc/log"
"github.com/eolinker/go-common/autowire"
@@ -42,11 +42,11 @@ func (p *PermitMiddleware) Sort() int {
func (p *PermitMiddleware) Check(method string, path string) (bool, []gin.HandlerFunc) {
// 当前路径是否有配置权限
accessRules, has := permit.GetPathRule(method, path)
if !has || len(accessRules) == 0 {
return false, nil
}
return true, []gin.HandlerFunc{
func(ginCtx *gin.Context) {
userId := utils.UserId(ginCtx)
@@ -56,19 +56,14 @@ func (p *PermitMiddleware) Check(method string, path string) (bool, []gin.Handle
ginCtx.Abort()
return
}
//if userId == "admin" {
// // 超级管理员不校验
// return
//}
for _, group := range checkSort {
accessList, has := accessRules[group]
if !has {
// 当前分组没有配置权限
continue
}
domainHandler, has := permit.SelectDomain(group)
if !has {
// 当前分组没有配置身份handler
+1
View File
@@ -9,6 +9,7 @@ type Kind int
func (k *Kind) UnmarshalJSON(bytes []byte) error {
str := ""
err := json.Unmarshal(bytes, &str)
if err != nil {
return err
+4 -11
View File
@@ -348,20 +348,13 @@ func (i *imlProviderModule) UpdateProviderDefaultLLM(ctx context.Context, id str
})
}
func (i *imlProviderModule) getAiProviders(ctx context.Context, clusterId string) ([]*gateway.DynamicRelease, error) {
list, err := i.providerService.List(ctx, clusterId)
if err != nil {
return nil, err
}
func (i *imlProviderModule) getAiProviders(ctx context.Context) ([]*gateway.DynamicRelease, error) {
list, err := i.providerService.List(ctx)
if err != nil {
return nil, err
}
providers := make([]*gateway.DynamicRelease, 0, len(list))
for _, p := range list {
if !p.Status {
// 关闭
continue
}
cfg := make(map[string]interface{})
err = json.Unmarshal([]byte(p.Config), &cfg)
if err != nil {
@@ -384,7 +377,7 @@ func (i *imlProviderModule) getAiProviders(ctx context.Context, clusterId string
return providers, nil
}
func (i *imlProviderModule) initGateway(ctx context.Context, clusterId string, clientDriver gateway.IClientDriver) error {
providers, err := i.getAiProviders(ctx, clusterId)
providers, err := i.getAiProviders(ctx)
if err != nil {
return err
}
@@ -401,7 +394,7 @@ func (i *imlProviderModule) initGateway(ctx context.Context, clusterId string, c
if err != nil {
return err
}
err = client.Online(ctx, providers...)
err = client.Online(ctx, p)
if err != nil {
return err
}
+5 -11
View File
@@ -145,7 +145,7 @@ system:
- "DELETE:/api/v1/certificate"
dependents:
- system.settings.ssl_certificate.view
- name: Data Source
- name: data source
value: 'data_source'
children:
- name: view
@@ -264,7 +264,7 @@ team:
- "DELETE:/api/v1/service/release"
dependents:
- team.service.release.view
- name: subscription management
- name: subscription review
value: 'subscription'
children:
- name: view
@@ -296,13 +296,12 @@ team:
- name: consumer
value: 'consumer'
children:
- name: subscription Service
- name: subscription service
cname: 订阅服务
value: 'subscription'
children:
- name: subscribe
- name: allow subscribe service
value: 'subscribe'
- name: view subscribed services
value: 'view_subscribed_service'
guest_allow: true
@@ -371,20 +370,15 @@ team:
value: 'manager'
dependents:
- team.team.member.view
- name: team
- name: team settings
value: 'team'
children:
- name: view
value: 'view'
guest_allow: true
apis:
- "GET:/api/v1/manager/teams"
- "GET:/api/v1/manager/team"
- name: manager
value: 'manager'
apis:
- "POST:/api/v1/manager/team"
- "PUT:/api/v1/manager/team"
- "DELETE:/api/v1/manager/team"
dependents:
- team.team.team.view
+22 -20
View File
@@ -1,44 +1,46 @@
{
"account": "Account",
"ai provider": "AI Provider",
"api market": "API Portal",
"analysis": "Analysis Report",
"api": "API",
"api doc": "API Documentation",
"application": "Application",
"application admin": "Application Administrator",
"application developer": "Application Developer",
"authorization": "Authorization",
"cluster": "Cluster",
"dashboard": "Dashboard",
"api gateway": "API Gateway",
"api portal": "API Portal",
"authorization": "Access Authorization",
"consumer": "Consumer",
"consumer admin": "Consumer Admin",
"consumer developer": "Consumer Developer",
"create": "Create",
"data source": "Data Source",
"devops": "DevOps",
"devops admin": "DevOps Administrator",
"devops admin": "DevOps Admin",
"general": "General Settings",
"general member": "General Member",
"guest": "Guest",
"log configuration": "Log Configuration",
"manager": "Manager",
"manager all consumer": "Manage All Consumers",
"manager subscribed services": "Manage Subscribed Services",
"member": "Member",
"organization": "Organization Management",
"release": "Release",
"role": "Role",
"router": "Router",
"run view": "Run View",
"service": "Service",
"service admin": "Service Administrator",
"service classification": "Service Directory",
"service admin": "Service Admin",
"service developer": "Service Developer",
"service intro": "Service Documentation",
"ssl certificate": "SSL Certificate",
"subscription management": "Subscription Management",
"allow subscribe service": "Allow Subscribe Service",
"subscription review": "Subscription Review",
"subscription service": "Subscription Service",
"super admin": "Super Administrator",
"super admin": "Super Admin",
"system settings": "System Settings",
"team": "Team",
"team admin": "Team Administrator",
"team settings": "Team Settings",
"team admin": "Team Admin",
"upstream": "Upstream",
"view": "View",
"view all application": "View All Applications",
"view all consumer": "View All Consumers",
"view all service": "View All Services",
"view all team": "View All Teams",
"view system role": "View System Roles",
"view team role": "View Team Roles",
"view subscribed services": "View Subscribed Services",
"workspace": "Workspace"
}
+19 -17
View File
@@ -1,44 +1,46 @@
{
"account": "アカウント",
"ai provider": "AIプロバイダー",
"api market": "APIマーケット",
"analysis": "分析レポート",
"api": "API",
"api doc": "APIドキュメント",
"application": "アプリケーション",
"application admin": "アプリケーション管理者",
"application developer": "アプリケーション開発者",
"authorization": "認証",
"cluster": "クラスター",
"dashboard": "ダッシュボード",
"api gateway": "APIゲートウェイ",
"api portal": "APIポータル",
"authorization": "アクセス許可",
"consumer": "消費者",
"consumer admin": "消費者管理者",
"consumer developer": "消費者開発者",
"create": "作成",
"data source": "データソース",
"devops": "DevOps",
"devops admin": "DevOps管理者",
"general": "一般設定",
"general member": "一般メンバー",
"guest": "ゲスト",
"log configuration": "ログ設定",
"manager": "管理者",
"manager all consumer": "すべての消費者を管理",
"manager subscribed services": "購読したサービスを管理",
"member": "メンバー",
"organization": "組織管理",
"release": "リリース",
"role": "役割",
"router": "ルーター",
"run view": "実行ビュー",
"service": "サービス",
"service admin": "サービス管理者",
"service classification": "サービスディレクトリ",
"service developer": "サービス開発者",
"service intro": "サービスドキュメント",
"ssl certificate": "SSL証明書",
"subscription management": "サブスクリプション管理",
"subscription service": "サブスクリプションサービス",
"allow subscribe service": "サービスの購読を許可",
"subscription review": "購読レビュー",
"subscription service": "購読サービス",
"super admin": "スーパ管理者",
"system settings": "システム設定",
"team": "チーム",
"team settings": "チーム設定",
"team admin": "チーム管理者",
"upstream": "アップストリーム",
"view": "表示",
"view all application": "すべてのアプリケーションを表示",
"view all consumer": "すべての消費者を表示",
"view all service": "すべてのサービスを表示",
"view all team": "すべてのチームを表示",
"view system role": "システム役割を表示",
"view team role": "チーム役割を表示",
"view subscribed services": "購読したサービスを表示",
"workspace": "ワークスペース"
}
+20 -18
View File
@@ -1,44 +1,46 @@
{
"ai provider": "AI供应商",
"api market": "API门户",
"account": "账号",
"ai provider": "AI模型供应商",
"analysis": "分析报告",
"api": "API",
"api doc": "API文档",
"application": "应用",
"application admin": "应用管理员",
"application developer": "应用开发者",
"authorization": "鉴权",
"cluster": "集群",
"dashboard": "仪表盘",
"api gateway": "API网关",
"api portal": "API门户",
"authorization": "访问授权",
"consumer": "消费者",
"consumer admin": "消费者管理员",
"consumer developer": "消费者开发者",
"create": "创建",
"data source": "数据源",
"devops": "运维",
"devops admin": "运维管理员",
"general": "常规设置",
"general member": "普通成员",
"guest": "访客",
"log configuration": "日志配置",
"manager": "管理",
"manager all consumer": "管理所有消费者",
"manager subscribed services": "管理已订阅的服务",
"member": "成员",
"organization": "组织管理",
"release": "发布",
"role": "角色",
"router": "路由",
"run view": "运行视图",
"service": "服务",
"service admin": "服务管理员",
"service classification": "服务目录",
"service developer": "服务开发者",
"service intro": "服务文档",
"ssl certificate": "SSL证书",
"subscription management": "订阅方管理",
"allow subscribe service": "允许订阅服务",
"subscription review": "订阅审核",
"subscription service": "订阅服务",
"super admin": "超级管理员",
"system settings": "系统设置",
"team": "团队",
"team settings": "团队设置",
"team admin": "团队管理员",
"upstream": "上游",
"view": "查看",
"view all application": "查看所有应用",
"view all consumer": "查看所有消费者",
"view all service": "查看所有服务",
"view all team": "查看所有团队",
"view system role": "查看系统角色",
"view team role": "查看团队角色",
"view subscribed services": "查看已经订阅的服务",
"workspace": "工作空间"
}
}
+19 -17
View File
@@ -1,44 +1,46 @@
{
"ai provider": "AI供應商",
"api market": "API市場",
"account": "帳號",
"ai provider": "AI模型供應商",
"analysis": "分析報告",
"api": "API",
"api doc": "API文檔",
"application": "應用",
"application admin": "應用管理員",
"application developer": "應用開發者",
"authorization": "授權",
"cluster": "集群",
"dashboard": "儀表盤",
"api gateway": "API網關",
"api portal": "API門戶",
"authorization": "訪問授權",
"consumer": "消費者",
"consumer admin": "消費者管理員",
"consumer developer": "消費者開發者",
"create": "創建",
"data source": "數據源",
"devops": "運維",
"devops admin": "運維管理員",
"general": "常規設置",
"general member": "普通成員",
"guest": "訪客",
"log configuration": "日誌配置",
"manager": "管理",
"manager all consumer": "管理所有消費者",
"manager subscribed services": "管理已訂閱的服務",
"member": "成員",
"organization": "組織管理",
"release": "發布",
"role": "角色",
"router": "路由",
"run view": "運行視圖",
"service": "服務",
"service admin": "服務管理員",
"service classification": "服務目錄",
"service developer": "服務開發者",
"service intro": "服務文檔",
"ssl certificate": "SSL證書",
"subscription management": "訂閱方管理",
"allow subscribe service": "允許訂閱服務",
"subscription review": "訂閱審核",
"subscription service": "訂閱服務",
"super admin": "超級管理員",
"system settings": "系統設置",
"team": "團隊",
"team settings": "團隊設置",
"team admin": "團隊管理員",
"upstream": "上游",
"view": "查看",
"view all application": "查看所有應用",
"view all consumer": "查看所有消費者",
"view all service": "查看所有服務",
"view all team": "查看所有團隊",
"view system role": "查看系統角色",
"view team role": "查看團隊角色",
"view subscribed services": "查看已訂閱的服務",
"workspace": "工作空間"
}
+1 -1
View File
@@ -1,4 +1,4 @@
# 名称:apinto通用镜像
# 名称:apipark通用镜像
# 创建时间:2022-10-25
FROM centos:7.9.2009
MAINTAINER liujian
Executable → Regular
+1
View File
@@ -25,6 +25,7 @@ cd "./eosc" && git pull
# =========================================================================
echo "更新 aoaccount"
cd "${BASEPATH}/"
if [ ! -d "./aoaccount" ]; then
git clone http://gitlab.eolink.com/apinto/aoaccount.git
fi