This is page 1 of 9. Use http://codebase.md/higress-group/himarket?lines=true&page={x} to view the full context. # Directory Structure ``` ├── .cursor │ └── rules │ ├── api-style.mdc │ └── project-architecture.mdc ├── .gitignore ├── build.sh ├── deploy │ ├── docker │ │ ├── docker-compose.yml │ │ └── Docker部署说明.md │ └── helm │ ├── Chart.yaml │ ├── Helm部署说明.md │ ├── templates │ │ ├── _helpers.tpl │ │ ├── himarket-admin-cm.yaml │ │ ├── himarket-admin-deployment.yaml │ │ ├── himarket-admin-service.yaml │ │ ├── himarket-frontend-cm.yaml │ │ ├── himarket-frontend-deployment.yaml │ │ ├── himarket-frontend-service.yaml │ │ ├── himarket-server-cm.yaml │ │ ├── himarket-server-deployment.yaml │ │ ├── himarket-server-service.yaml │ │ ├── mysql.yaml │ │ └── serviceaccount.yaml │ └── values.yaml ├── LICENSE ├── NOTICE ├── pom.xml ├── portal-bootstrap │ ├── Dockerfile │ ├── pom.xml │ └── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── apiopenplatform │ │ │ ├── config │ │ │ │ ├── AsyncConfig.java │ │ │ │ ├── FilterConfig.java │ │ │ │ ├── PageConfig.java │ │ │ │ ├── RestTemplateConfig.java │ │ │ │ ├── SecurityConfig.java │ │ │ │ └── SwaggerConfig.java │ │ │ ├── filter │ │ │ │ └── PortalResolvingFilter.java │ │ │ └── PortalApplication.java │ │ └── resources │ │ └── application.yaml │ └── test │ └── java │ └── com │ └── alibaba │ └── apiopenplatform │ └── integration │ └── AdministratorAuthIntegrationTest.java ├── portal-dal │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── alibaba │ └── apiopenplatform │ ├── converter │ │ ├── AdpAIGatewayConfigConverter.java │ │ ├── APIGConfigConverter.java │ │ ├── APIGRefConfigConverter.java │ │ ├── ApiKeyConfigConverter.java │ │ ├── ConsumerAuthConfigConverter.java │ │ ├── GatewayConfigConverter.java │ │ ├── HigressConfigConverter.java │ │ ├── HigressRefConfigConverter.java │ │ ├── HmacConfigConverter.java │ │ ├── JsonConverter.java │ │ ├── JwtConfigConverter.java │ │ ├── NacosRefConfigConverter.java │ │ ├── PortalSettingConfigConverter.java │ │ ├── PortalUiConfigConverter.java │ │ └── ProductIconConverter.java │ ├── entity │ │ ├── Administrator.java │ │ ├── BaseEntity.java │ │ ├── Consumer.java │ │ ├── ConsumerCredential.java │ │ ├── ConsumerRef.java │ │ ├── Developer.java │ │ ├── DeveloperExternalIdentity.java │ │ ├── Gateway.java │ │ ├── NacosInstance.java │ │ ├── Portal.java │ │ ├── PortalDomain.java │ │ ├── Product.java │ │ ├── ProductPublication.java │ │ ├── ProductRef.java │ │ └── ProductSubscription.java │ ├── repository │ │ ├── AdministratorRepository.java │ │ ├── BaseRepository.java │ │ ├── ConsumerCredentialRepository.java │ │ ├── ConsumerRefRepository.java │ │ ├── ConsumerRepository.java │ │ ├── DeveloperExternalIdentityRepository.java │ │ ├── DeveloperRepository.java │ │ ├── GatewayRepository.java │ │ ├── NacosInstanceRepository.java │ │ ├── PortalDomainRepository.java │ │ ├── PortalRepository.java │ │ ├── ProductPublicationRepository.java │ │ ├── ProductRefRepository.java │ │ ├── ProductRepository.java │ │ └── SubscriptionRepository.java │ └── support │ ├── common │ │ ├── Encrypted.java │ │ ├── Encryptor.java │ │ └── User.java │ ├── consumer │ │ ├── AdpAIAuthConfig.java │ │ ├── APIGAuthConfig.java │ │ ├── ApiKeyConfig.java │ │ ├── ConsumerAuthConfig.java │ │ ├── HigressAuthConfig.java │ │ ├── HmacConfig.java │ │ └── JwtConfig.java │ ├── enums │ │ ├── APIGAPIType.java │ │ ├── ConsumerAuthType.java │ │ ├── ConsumerStatus.java │ │ ├── CredentialMode.java │ │ ├── DeveloperAuthType.java │ │ ├── DeveloperStatus.java │ │ ├── DomainType.java │ │ ├── GatewayType.java │ │ ├── GrantType.java │ │ ├── HigressAPIType.java │ │ ├── JwtAlgorithm.java │ │ ├── ProductIconType.java │ │ ├── ProductStatus.java │ │ ├── ProductType.java │ │ ├── ProtocolType.java │ │ ├── PublicKeyFormat.java │ │ ├── SourceType.java │ │ ├── SubscriptionStatus.java │ │ └── UserType.java │ ├── gateway │ │ ├── AdpAIGatewayConfig.java │ │ ├── APIGConfig.java │ │ ├── GatewayConfig.java │ │ └── HigressConfig.java │ ├── portal │ │ ├── AuthCodeConfig.java │ │ ├── IdentityMapping.java │ │ ├── JwtBearerConfig.java │ │ ├── OAuth2Config.java │ │ ├── OidcConfig.java │ │ ├── PortalSettingConfig.java │ │ ├── PortalUiConfig.java │ │ └── PublicKeyConfig.java │ └── product │ ├── APIGRefConfig.java │ ├── HigressRefConfig.java │ ├── NacosRefConfig.java │ └── ProductIcon.java ├── portal-server │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── alibaba │ └── apiopenplatform │ ├── controller │ │ ├── AdministratorController.java │ │ ├── ConsumerController.java │ │ ├── DeveloperController.java │ │ ├── GatewayController.java │ │ ├── NacosController.java │ │ ├── OAuth2Controller.java │ │ ├── OidcController.java │ │ ├── PortalController.java │ │ └── ProductController.java │ ├── core │ │ ├── advice │ │ │ ├── ExceptionAdvice.java │ │ │ └── ResponseAdvice.java │ │ ├── annotation │ │ │ ├── AdminAuth.java │ │ │ ├── AdminOrDeveloperAuth.java │ │ │ └── DeveloperAuth.java │ │ ├── constant │ │ │ ├── CommonConstants.java │ │ │ ├── IdpConstants.java │ │ │ ├── JwtConstants.java │ │ │ └── Resources.java │ │ ├── event │ │ │ ├── DeveloperDeletingEvent.java │ │ │ ├── PortalDeletingEvent.java │ │ │ └── ProductDeletingEvent.java │ │ ├── exception │ │ │ ├── BusinessException.java │ │ │ └── ErrorCode.java │ │ ├── response │ │ │ └── Response.java │ │ ├── security │ │ │ ├── ContextHolder.java │ │ │ ├── DeveloperAuthenticationProvider.java │ │ │ └── JwtAuthenticationFilter.java │ │ └── utils │ │ ├── IdGenerator.java │ │ ├── PasswordHasher.java │ │ └── TokenUtil.java │ ├── dto │ │ ├── converter │ │ │ ├── InputConverter.java │ │ │ ├── NacosToGatewayToolsConverter.java │ │ │ └── OutputConverter.java │ │ ├── params │ │ │ ├── admin │ │ │ │ ├── AdminCreateParam.java │ │ │ │ ├── AdminLoginParam.java │ │ │ │ └── ResetPasswordParam.java │ │ │ ├── consumer │ │ │ │ ├── CreateConsumerParam.java │ │ │ │ ├── CreateCredentialParam.java │ │ │ │ ├── CreateSubscriptionParam.java │ │ │ │ ├── QueryConsumerParam.java │ │ │ │ ├── QuerySubscriptionParam.java │ │ │ │ └── UpdateCredentialParam.java │ │ │ ├── developer │ │ │ │ ├── CreateDeveloperParam.java │ │ │ │ ├── CreateExternalDeveloperParam.java │ │ │ │ ├── DeveloperLoginParam.java │ │ │ │ ├── QueryDeveloperParam.java │ │ │ │ ├── UnbindExternalIdentityParam.java │ │ │ │ ├── UpdateDeveloperParam.java │ │ │ │ └── UpdateDeveloperStatusParam.java │ │ │ ├── gateway │ │ │ │ ├── ImportGatewayParam.java │ │ │ │ ├── QueryAdpAIGatewayParam.java │ │ │ │ ├── QueryAPIGParam.java │ │ │ │ └── QueryGatewayParam.java │ │ │ ├── nacos │ │ │ │ ├── CreateNacosParam.java │ │ │ │ ├── QueryNacosNamespaceParam.java │ │ │ │ ├── QueryNacosParam.java │ │ │ │ └── UpdateNacosParam.java │ │ │ ├── portal │ │ │ │ ├── BindDomainParam.java │ │ │ │ ├── CreatePortalParam.java │ │ │ │ └── UpdatePortalParam.java │ │ │ └── product │ │ │ ├── CreateProductParam.java │ │ │ ├── CreateProductRefParam.java │ │ │ ├── PublishProductParam.java │ │ │ ├── QueryProductParam.java │ │ │ ├── QueryProductSubscriptionParam.java │ │ │ ├── UnPublishProductParam.java │ │ │ └── UpdateProductParam.java │ │ └── result │ │ ├── AdminResult.java │ │ ├── AdpGatewayInstanceResult.java │ │ ├── AdpMcpServerListResult.java │ │ ├── AdpMCPServerResult.java │ │ ├── APIConfigResult.java │ │ ├── APIGMCPServerResult.java │ │ ├── APIResult.java │ │ ├── AuthResult.java │ │ ├── ConsumerCredentialResult.java │ │ ├── ConsumerResult.java │ │ ├── DeveloperResult.java │ │ ├── GatewayMCPServerResult.java │ │ ├── GatewayResult.java │ │ ├── HigressMCPServerResult.java │ │ ├── IdpResult.java │ │ ├── IdpState.java │ │ ├── IdpTokenResult.java │ │ ├── MCPConfigResult.java │ │ ├── MCPServerResult.java │ │ ├── MseNacosResult.java │ │ ├── NacosMCPServerResult.java │ │ ├── NacosNamespaceResult.java │ │ ├── NacosResult.java │ │ ├── PageResult.java │ │ ├── PortalResult.java │ │ ├── ProductPublicationResult.java │ │ ├── ProductRefResult.java │ │ ├── ProductResult.java │ │ └── SubscriptionResult.java │ └── service │ ├── AdministratorService.java │ ├── AdpAIGatewayService.java │ ├── ConsumerService.java │ ├── DeveloperService.java │ ├── gateway │ │ ├── AdpAIGatewayOperator.java │ │ ├── AIGatewayOperator.java │ │ ├── APIGOperator.java │ │ ├── client │ │ │ ├── AdpAIGatewayClient.java │ │ │ ├── APIGClient.java │ │ │ ├── GatewayClient.java │ │ │ ├── HigressClient.java │ │ │ ├── PopGatewayClient.java │ │ │ └── SLSClient.java │ │ ├── factory │ │ │ └── HTTPClientFactory.java │ │ ├── GatewayOperator.java │ │ └── HigressOperator.java │ ├── GatewayService.java │ ├── IdpService.java │ ├── impl │ │ ├── AdministratorServiceImpl.java │ │ ├── ConsumerServiceImpl.java │ │ ├── DeveloperServiceImpl.java │ │ ├── GatewayServiceImpl.java │ │ ├── IdpServiceImpl.java │ │ ├── NacosServiceImpl.java │ │ ├── OAuth2ServiceImpl.java │ │ ├── OidcServiceImpl.java │ │ ├── PortalServiceImpl.java │ │ └── ProductServiceImpl.java │ ├── NacosService.java │ ├── OAuth2Service.java │ ├── OidcService.java │ ├── PortalService.java │ └── ProductService.java ├── portal-web │ ├── api-portal-admin │ │ ├── .env │ │ ├── .gitignore │ │ ├── bin │ │ │ ├── replace_var.py │ │ │ └── start.sh │ │ ├── Dockerfile │ │ ├── eslint.config.js │ │ ├── index.html │ │ ├── nginx.conf │ │ ├── package.json │ │ ├── postcss.config.js │ │ ├── proxy.conf │ │ ├── public │ │ │ ├── logo.png │ │ │ └── vite.svg │ │ ├── README.md │ │ ├── src │ │ │ ├── aliyunThemeToken.ts │ │ │ ├── App.css │ │ │ ├── App.tsx │ │ │ ├── assets │ │ │ │ └── react.svg │ │ │ ├── components │ │ │ │ ├── api-product │ │ │ │ │ ├── ApiProductApiDocs.tsx │ │ │ │ │ ├── ApiProductDashboard.tsx │ │ │ │ │ ├── ApiProductFormModal.tsx │ │ │ │ │ ├── ApiProductLinkApi.tsx │ │ │ │ │ ├── ApiProductOverview.tsx │ │ │ │ │ ├── ApiProductPolicy.tsx │ │ │ │ │ ├── ApiProductPortal.tsx │ │ │ │ │ ├── ApiProductUsageGuide.tsx │ │ │ │ │ ├── SwaggerUIWrapper.css │ │ │ │ │ └── SwaggerUIWrapper.tsx │ │ │ │ ├── common │ │ │ │ │ ├── AdvancedSearch.tsx │ │ │ │ │ └── index.ts │ │ │ │ ├── console │ │ │ │ │ ├── GatewayTypeSelector.tsx │ │ │ │ │ ├── ImportGatewayModal.tsx │ │ │ │ │ ├── ImportHigressModal.tsx │ │ │ │ │ ├── ImportMseNacosModal.tsx │ │ │ │ │ └── NacosTypeSelector.tsx │ │ │ │ ├── icons │ │ │ │ │ └── McpServerIcon.tsx │ │ │ │ ├── Layout.tsx │ │ │ │ ├── LayoutWrapper.tsx │ │ │ │ ├── portal │ │ │ │ │ ├── PortalConsumers.tsx │ │ │ │ │ ├── PortalDashboard.tsx │ │ │ │ │ ├── PortalDevelopers.tsx │ │ │ │ │ ├── PortalDomain.tsx │ │ │ │ │ ├── PortalFormModal.tsx │ │ │ │ │ ├── PortalOverview.tsx │ │ │ │ │ ├── PortalPublishedApis.tsx │ │ │ │ │ ├── PortalSecurity.tsx │ │ │ │ │ ├── PortalSettings.tsx │ │ │ │ │ ├── PublicKeyManager.tsx │ │ │ │ │ └── ThirdPartyAuthManager.tsx │ │ │ │ └── subscription │ │ │ │ └── SubscriptionListModal.tsx │ │ │ ├── contexts │ │ │ │ └── LoadingContext.tsx │ │ │ ├── index.css │ │ │ ├── lib │ │ │ │ ├── api.ts │ │ │ │ ├── constant.ts │ │ │ │ └── utils.ts │ │ │ ├── main.tsx │ │ │ ├── pages │ │ │ │ ├── ApiProductDetail.tsx │ │ │ │ ├── ApiProducts.tsx │ │ │ │ ├── Dashboard.tsx │ │ │ │ ├── GatewayConsoles.tsx │ │ │ │ ├── Login.tsx │ │ │ │ ├── NacosConsoles.tsx │ │ │ │ ├── PortalDetail.tsx │ │ │ │ ├── Portals.tsx │ │ │ │ └── Register.tsx │ │ │ ├── routes │ │ │ │ └── index.tsx │ │ │ ├── types │ │ │ │ ├── api-product.ts │ │ │ │ ├── consumer.ts │ │ │ │ ├── gateway.ts │ │ │ │ ├── index.ts │ │ │ │ ├── portal.ts │ │ │ │ ├── shims-js-yaml.d.ts │ │ │ │ └── subscription.ts │ │ │ └── vite-env.d.ts │ │ ├── tailwind.config.js │ │ ├── tsconfig.json │ │ ├── tsconfig.node.json │ │ └── vite.config.ts │ └── api-portal-frontend │ ├── .env │ ├── .gitignore │ ├── .husky │ │ └── pre-commit │ ├── bin │ │ ├── replace_var.py │ │ └── start.sh │ ├── Dockerfile │ ├── eslint.config.js │ ├── index.html │ ├── nginx.conf │ ├── package.json │ ├── postcss.config.js │ ├── proxy.conf │ ├── public │ │ ├── favicon.ico │ │ ├── logo.png │ │ ├── logo.svg │ │ ├── MCP.png │ │ ├── MCP.svg │ │ └── vite.svg │ ├── README.md │ ├── src │ │ ├── aliyunThemeToken.ts │ │ ├── App.css │ │ ├── App.tsx │ │ ├── assets │ │ │ ├── aliyun.png │ │ │ ├── github.png │ │ │ ├── google.png │ │ │ └── react.svg │ │ ├── components │ │ │ ├── consumer │ │ │ │ ├── ConsumerBasicInfo.tsx │ │ │ │ ├── CredentialManager.tsx │ │ │ │ ├── index.ts │ │ │ │ └── SubscriptionManager.tsx │ │ │ ├── Layout.tsx │ │ │ ├── Navigation.tsx │ │ │ ├── ProductHeader.tsx │ │ │ ├── SwaggerUIWrapper.css │ │ │ ├── SwaggerUIWrapper.tsx │ │ │ └── UserInfo.tsx │ │ ├── index.css │ │ ├── lib │ │ │ ├── api.ts │ │ │ ├── statusUtils.ts │ │ │ └── utils.ts │ │ ├── main.tsx │ │ ├── pages │ │ │ ├── ApiDetail.tsx │ │ │ ├── Apis.tsx │ │ │ ├── Callback.tsx │ │ │ ├── ConsumerDetail.tsx │ │ │ ├── Consumers.tsx │ │ │ ├── GettingStarted.tsx │ │ │ ├── Home.tsx │ │ │ ├── Login.tsx │ │ │ ├── Mcp.tsx │ │ │ ├── McpDetail.tsx │ │ │ ├── OidcCallback.tsx │ │ │ ├── Profile.tsx │ │ │ ├── Register.tsx │ │ │ └── Test.css │ │ ├── router.tsx │ │ ├── types │ │ │ ├── consumer.ts │ │ │ └── index.ts │ │ └── vite-env.d.ts │ ├── tailwind.config.js │ ├── tsconfig.app.json │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts └── README.md ``` # Files -------------------------------------------------------------------------------- /portal-web/api-portal-admin/.env: -------------------------------------------------------------------------------- ``` 1 | VITE_API_BASE_URL=/api/v1 ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/.env: -------------------------------------------------------------------------------- ``` 1 | VITE_API_BASE_URL=/api/v1 ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/.gitignore: -------------------------------------------------------------------------------- ``` 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | image-push.sh ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/.gitignore: -------------------------------------------------------------------------------- ``` 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | image-push.sh ``` -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- ``` 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea 8 | *.iws 9 | *.iml 10 | *.ipr 11 | 12 | ### Eclipse ### 13 | .apt_generated 14 | .classpath 15 | .factorypath 16 | .project 17 | .settings 18 | .springBeans 19 | .sts4-cache 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ 27 | build/ 28 | !**/src/main/**/build/ 29 | !**/src/test/**/build/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | 34 | ### Mac OS ### 35 | .DS_Store 36 | 37 | /front-auth-app 38 | 39 | package-lock.json ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/vite-env.d.ts: -------------------------------------------------------------------------------- ```typescript 1 | /// <reference types="vite/client" /> ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/src/vite-env.d.ts: -------------------------------------------------------------------------------- ```typescript 1 | /// <reference types="vite/client" /> 2 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/postcss.config.js: -------------------------------------------------------------------------------- ```javascript 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/postcss.config.js: -------------------------------------------------------------------------------- ```javascript 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/types/shims-js-yaml.d.ts: -------------------------------------------------------------------------------- ```typescript 1 | declare module 'js-yaml' { 2 | export function load(str: string, opts?: unknown): unknown; 3 | } 4 | 5 | 6 | ``` -------------------------------------------------------------------------------- /deploy/helm/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- ```yaml 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: {{ include "himarket.serviceAccountName" . }} ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/components/common/index.ts: -------------------------------------------------------------------------------- ```typescript 1 | export { AdvancedSearch } from './AdvancedSearch'; 2 | export type { SearchParam } from './AdvancedSearch'; 3 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/PublicKeyFormat.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.enums; 2 | 3 | public enum PublicKeyFormat { 4 | PEM, 5 | 6 | JWK, 7 | 8 | ; 9 | } 10 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/tsconfig.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/ProductIconType.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.enums; 2 | 3 | /** 4 | * @author zh 5 | */ 6 | public enum ProductIconType { 7 | 8 | URL, 9 | 10 | BASE64, 11 | 12 | ; 13 | } 14 | ``` -------------------------------------------------------------------------------- /deploy/helm/templates/himarket-admin-cm.yaml: -------------------------------------------------------------------------------- ```yaml 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | labels: 5 | app: himarket-admin 6 | name: himarket-admin 7 | data: 8 | HIMARKET_SERVER: "http://himarket-server" ``` -------------------------------------------------------------------------------- /deploy/helm/templates/himarket-frontend-cm.yaml: -------------------------------------------------------------------------------- ```yaml 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | labels: 5 | app: himarket-frontend 6 | name: himarket-frontend 7 | data: 8 | HIMARKET_SERVER: "http://himarket-server" ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/src/components/consumer/index.ts: -------------------------------------------------------------------------------- ```typescript 1 | export { ConsumerBasicInfo } from './ConsumerBasicInfo'; 2 | export { CredentialManager } from './CredentialManager'; 3 | export { SubscriptionManager } from './SubscriptionManager'; ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/JwtAlgorithm.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.enums; 2 | 3 | /** 4 | * @author zh 5 | */ 6 | public enum JwtAlgorithm { 7 | 8 | RS256, 9 | 10 | RS384, 11 | 12 | RS512, 13 | 14 | ES256, 15 | 16 | ES384, 17 | 18 | ES512, 19 | 20 | ; 21 | } 22 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/tailwind.config.js: -------------------------------------------------------------------------------- ```javascript 1 | /** @type {import('tailwindcss').Config} */ 2 | export default { 3 | content: [ 4 | "./index.html", 5 | "./src/**/*.{js,ts,jsx,tsx}", 6 | ], 7 | theme: { 8 | extend: {}, 9 | }, 10 | plugins: [], 11 | } 12 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/src/main.tsx: -------------------------------------------------------------------------------- ```typescript 1 | import { createRoot } from 'react-dom/client' 2 | import 'antd/dist/reset.css' 3 | import './index.css' 4 | import App from './App.tsx' 5 | 6 | createRoot(document.getElementById('root')!).render( 7 | <App /> 8 | ) 9 | ``` -------------------------------------------------------------------------------- /portal-bootstrap/Dockerfile: -------------------------------------------------------------------------------- ```dockerfile 1 | FROM docker.m.daocloud.io/openjdk:8-jdk-slim 2 | 3 | WORKDIR /app 4 | 5 | COPY target/*.jar app.jar 6 | 7 | EXPOSE 8080 8 | 9 | ENTRYPOINT ["java", "-jar", "app.jar", "--logging.file.name=/app/logs/himarket-server.log"] ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/tsconfig.node.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/Dockerfile: -------------------------------------------------------------------------------- ```dockerfile 1 | FROM docker.m.daocloud.io/nginx:1.24-alpine 2 | 3 | COPY nginx.conf /etc/nginx/nginx.conf 4 | COPY proxy.conf /etc/nginx/default.d/proxy.conf 5 | COPY bin /home/admin/bin 6 | 7 | WORKDIR /app 8 | 9 | COPY dist/ /app 10 | 11 | CMD ["/bin/sh", "/home/admin/bin/start.sh"] ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/Dockerfile: -------------------------------------------------------------------------------- ```dockerfile 1 | FROM docker.m.daocloud.io/nginx:1.24-alpine 2 | 3 | COPY nginx.conf /etc/nginx/nginx.conf 4 | COPY proxy.conf /etc/nginx/default.d/proxy.conf 5 | COPY bin /home/admin/bin 6 | 7 | 8 | WORKDIR /app 9 | 10 | COPY dist/ /app 11 | 12 | CMD ["/bin/sh", "/home/admin/bin/start.sh"] ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/portal/JwtBearerConfig.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.portal; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author zh 9 | */ 10 | @Data 11 | public class JwtBearerConfig { 12 | 13 | /** 14 | * JWT公钥 15 | */ 16 | private List<PublicKeyConfig> publicKeys; 17 | } 18 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/consumer/HigressAuthConfig.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.consumer; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zh 8 | */ 9 | @Data 10 | @Builder 11 | public class HigressAuthConfig { 12 | 13 | private String resourceType; 14 | 15 | private String resourceName; 16 | } 17 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/consumer/APIGAuthConfig.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.consumer; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author zh 10 | */ 11 | @Data 12 | @Builder 13 | public class APIGAuthConfig { 14 | 15 | private List<String> authorizationRuleIds; 16 | } 17 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/gateway/QueryGatewayParam.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.dto.params.gateway; 2 | 3 | import com.alibaba.apiopenplatform.support.enums.GatewayType; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zh 8 | */ 9 | @Data 10 | public class QueryGatewayParam { 11 | 12 | private GatewayType gatewayType; 13 | } 14 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/product/ProductIcon.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.product; 2 | 3 | import com.alibaba.apiopenplatform.support.enums.ProductIconType; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zh 8 | */ 9 | @Data 10 | public class ProductIcon { 11 | 12 | private ProductIconType type; 13 | 14 | private String value; 15 | } 16 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/bin/start.sh: -------------------------------------------------------------------------------- ```bash 1 | #!/bin/sh 2 | 3 | if [ -z "$HIMARKET_SERVER" ]; then 4 | echo "HIMARKET_SERVER not set" 5 | exit 1 6 | fi 7 | sed -i "s|{{ HIMARKET_SERVER }}|${HIMARKET_SERVER}|g" /etc/nginx/default.d/proxy.conf 8 | 9 | nginx 10 | echo "HiMarket Admin started successfully" 11 | tail -f /var/log/nginx/access.log ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/bin/start.sh: -------------------------------------------------------------------------------- ```bash 1 | #!/bin/sh 2 | 3 | if [ -z "$HIMARKET_SERVER" ]; then 4 | echo "HIMARKET_SERVER not set" 5 | exit 1 6 | fi 7 | sed -i "s|{{ HIMARKET_SERVER }}|${HIMARKET_SERVER}|g" /etc/nginx/default.d/proxy.conf 8 | 9 | nginx 10 | echo "HiMarket Frontend started successfully" 11 | tail -f /var/log/nginx/access.log ``` -------------------------------------------------------------------------------- /deploy/helm/templates/himarket-admin-service.yaml: -------------------------------------------------------------------------------- ```yaml 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: himarket-admin 5 | labels: 6 | app: himarket-admin 7 | spec: 8 | type: {{ .Values.admin.service.type }} 9 | ports: 10 | - port: {{ .Values.admin.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | selector: 15 | app: himarket-admin 16 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/product/QueryProductSubscriptionParam.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.dto.params.product; 2 | 3 | import com.alibaba.apiopenplatform.support.enums.SubscriptionStatus; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zh 8 | */ 9 | @Data 10 | public class QueryProductSubscriptionParam { 11 | 12 | private SubscriptionStatus status; 13 | 14 | private String consumerName; 15 | } 16 | ``` -------------------------------------------------------------------------------- /deploy/helm/templates/himarket-server-service.yaml: -------------------------------------------------------------------------------- ```yaml 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: himarket-server 5 | labels: 6 | app: himarket-server 7 | spec: 8 | type: {{ .Values.server.service.type }} 9 | ports: 10 | - port: {{ .Values.server.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | selector: 15 | app: himarket-server 16 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/DeveloperAuthType.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.enums; 2 | 3 | /** 4 | * @author zh 5 | */ 6 | public enum DeveloperAuthType { 7 | 8 | @Deprecated 9 | LOCAL, 10 | 11 | BUILTIN, 12 | 13 | @Deprecated 14 | EXTERNAL, 15 | 16 | OIDC, 17 | 18 | OAUTH2, 19 | 20 | ; 21 | 22 | public boolean isBuiltIn() { 23 | return this == BUILTIN || this == LOCAL; 24 | } 25 | } 26 | ``` -------------------------------------------------------------------------------- /deploy/helm/templates/himarket-frontend-service.yaml: -------------------------------------------------------------------------------- ```yaml 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: himarket-frontend 5 | labels: 6 | app: himarket-frontend 7 | spec: 8 | type: {{ .Values.frontend.service.type }} 9 | ports: 10 | - port: {{ .Values.frontend.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | selector: 15 | app: himarket-frontend 16 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/service/OAuth2Service.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.service; 2 | 3 | import com.alibaba.apiopenplatform.dto.result.AuthResult; 4 | 5 | /** 6 | * @author zh 7 | */ 8 | public interface OAuth2Service { 9 | 10 | /** 11 | * JWT Bearer认证 12 | * 13 | * @param grantType 14 | * @param jwtToken 15 | * @return 16 | */ 17 | AuthResult authenticate(String grantType, String jwtToken); 18 | 19 | } 20 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/ProductIconConverter.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.converter; 2 | 3 | import com.alibaba.apiopenplatform.support.product.ProductIcon; 4 | 5 | import javax.persistence.Converter; 6 | 7 | /** 8 | * @author zh 9 | */ 10 | @Converter(autoApply = true) 11 | public class ProductIconConverter extends JsonConverter<ProductIcon> { 12 | 13 | protected ProductIconConverter() { 14 | super(ProductIcon.class); 15 | } 16 | } 17 | 18 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/index.html: -------------------------------------------------------------------------------- ```html 1 | <!doctype html> 2 | <html lang="en"> 3 | <head> 4 | <meta charset="UTF-8" /> 5 | <link rel="icon" type="image/svg+xml" href="/logo.png" /> 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 7 | <title>HiMarket</title> 8 | </head> 9 | <body> 10 | <div id="root"></div> 11 | <script type="module" src="/src/main.tsx"></script> 12 | </body> 13 | </html> 14 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/index.html: -------------------------------------------------------------------------------- ```html 1 | <!doctype html> 2 | <html lang="en"> 3 | <head> 4 | <meta charset="UTF-8" /> 5 | <link rel="icon" type="image/svg+xml" href="/logo.png" /> 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 7 | <title>HiMarket</title> 8 | </head> 9 | <body> 10 | <div id="root"></div> 11 | <script type="module" src="/src/main.tsx"></script> 12 | </body> 13 | </html> 14 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/AdpAIGatewayConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.converter; 2 | 3 | import com.alibaba.apiopenplatform.support.gateway.AdpAIGatewayConfig; 4 | 5 | import javax.persistence.Converter; 6 | 7 | @Converter(autoApply = true) 8 | public class AdpAIGatewayConfigConverter extends JsonConverter<AdpAIGatewayConfig> { 9 | 10 | public AdpAIGatewayConfigConverter() { 11 | super(AdpAIGatewayConfig.class); 12 | } 13 | } 14 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/main.tsx: -------------------------------------------------------------------------------- ```typescript 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | // import { RouterProvider } from 'react-router-dom' 4 | import App from './App.tsx' 5 | import './index.css' 6 | 7 | const rootElement = document.getElementById('root') 8 | if (!rootElement) throw new Error('Failed to find the root element') 9 | 10 | ReactDOM.createRoot(rootElement).render( 11 | <React.StrictMode> 12 | <App /> 13 | </React.StrictMode>, 14 | ) 15 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/proxy.conf: -------------------------------------------------------------------------------- ``` 1 | location ^~ /api/v1 { 2 | proxy_http_version 1.1; 3 | proxy_set_header Connection ""; 4 | rewrite ^/api/v1/(.*)$ /$1 break; 5 | proxy_pass {{ HIMARKET_SERVER }}; 6 | } 7 | 8 | location ~ .*\.(js|css|gif|jpg|jpeg|png|svg|json|otf|ico)$ { 9 | root /app; 10 | } 11 | 12 | location / { 13 | try_files $uri $uri/ /index.html; 14 | root /app; 15 | index index.html index.htm; 16 | } 17 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/GrantType.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * @author zh 7 | */ 8 | @Getter 9 | public enum GrantType { 10 | 11 | /** 12 | * 授权码模式 13 | */ 14 | AUTHORIZATION_CODE("authorization_code"), 15 | 16 | 17 | /** 18 | * JWT断言,OAuth2.0标准拓展 19 | */ 20 | JWT_BEARER("urn:ietf:params:oauth:grant-type:jwt-bearer"), 21 | 22 | ; 23 | 24 | private final String type; 25 | 26 | GrantType(String type) { 27 | this.type = type; 28 | } 29 | } 30 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/service/AdpAIGatewayService.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.service; 2 | 3 | import com.alibaba.apiopenplatform.dto.params.gateway.QueryAdpAIGatewayParam; 4 | import com.alibaba.apiopenplatform.dto.result.GatewayResult; 5 | import com.alibaba.apiopenplatform.dto.result.PageResult; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | public interface AdpAIGatewayService { 9 | PageResult<GatewayResult> fetchGateways(QueryAdpAIGatewayParam param, int page, int size); 10 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/types/subscription.ts: -------------------------------------------------------------------------------- ```typescript 1 | export interface Subscription { 2 | subscriptionId: string; 3 | consumerId: string; 4 | productId: string; 5 | status: 'PENDING' | 'APPROVED'; 6 | createAt: string; 7 | updatedAt: string; 8 | productName: string; 9 | productType: string; 10 | } 11 | 12 | export interface Product { 13 | productId: string; 14 | name: string; 15 | description?: string; 16 | type: string; 17 | } 18 | 19 | export interface SubscriptionModalProps { 20 | visible: boolean; 21 | consumerId: string; 22 | consumerName: string; 23 | onCancel: () => void; 24 | } 25 | 26 | 27 | 28 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/src/App.tsx: -------------------------------------------------------------------------------- ```typescript 1 | import { BrowserRouter } from "react-router-dom"; 2 | import { Router } from "./router"; 3 | import { ConfigProvider } from 'antd'; 4 | import zhCN from 'antd/locale/zh_CN'; 5 | import './App.css' 6 | import aliyunThemeToken from './aliyunThemeToken.ts'; 7 | 8 | function App() { 9 | return ( 10 | <ConfigProvider 11 | locale={zhCN} 12 | theme={{ 13 | token: aliyunThemeToken 14 | }} 15 | > 16 | <BrowserRouter> 17 | <Router /> 18 | </BrowserRouter> 19 | </ConfigProvider> 20 | ); 21 | } 22 | 23 | export default App; 24 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/tailwind.config.js: -------------------------------------------------------------------------------- ```javascript 1 | /** @type {import('tailwindcss').Config} */ 2 | export default { 3 | content: [ 4 | "./index.html", 5 | "./src/**/*.{js,ts,jsx,tsx}", 6 | ], 7 | theme: { 8 | extend: { 9 | colors: { 10 | gray: { 11 | 50: '#f9fafb', 12 | 100: '#f3f4f6', 13 | 200: '#e5e7eb', 14 | 300: '#d1d5db', 15 | 400: '#9ca3af', 16 | 500: '#6b7280', 17 | 600: '#4b5563', 18 | 700: '#374151', 19 | 800: '#1f2937', 20 | 900: '#111827', 21 | } 22 | } 23 | }, 24 | }, 25 | plugins: [], 26 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/src/components/consumer/ConsumerBasicInfo.tsx: -------------------------------------------------------------------------------- ```typescript 1 | import { Card, Descriptions } from "antd"; 2 | import type { Consumer } from "../../types/consumer"; 3 | 4 | interface ConsumerBasicInfoProps { 5 | consumer: Consumer; 6 | } 7 | 8 | export function ConsumerBasicInfo({ consumer }: ConsumerBasicInfoProps) { 9 | return ( 10 | <Card title="基本信息"> 11 | <Descriptions column={2}> 12 | <Descriptions.Item label="名称">{consumer.name}</Descriptions.Item> 13 | <Descriptions.Item label="描述">{consumer.description || '-'}</Descriptions.Item> 14 | </Descriptions> 15 | </Card> 16 | ); 17 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/App.css: -------------------------------------------------------------------------------- ```css 1 | #root { 2 | 3 | } 4 | 5 | .logo { 6 | height: 6em; 7 | padding: 1.5em; 8 | will-change: filter; 9 | transition: filter 300ms; 10 | } 11 | .logo:hover { 12 | filter: drop-shadow(0 0 2em #646cffaa); 13 | } 14 | .logo.react:hover { 15 | filter: drop-shadow(0 0 2em #61dafbaa); 16 | } 17 | 18 | @keyframes logo-spin { 19 | from { 20 | transform: rotate(0deg); 21 | } 22 | to { 23 | transform: rotate(360deg); 24 | } 25 | } 26 | 27 | @media (prefers-reduced-motion: no-preference) { 28 | a:nth-of-type(2) .logo { 29 | animation: logo-spin infinite 20s linear; 30 | } 31 | } 32 | 33 | .card { 34 | padding: 2em; 35 | } 36 | 37 | .read-the-docs { 38 | color: #888; 39 | } 40 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/App.tsx: -------------------------------------------------------------------------------- ```typescript 1 | import { RouterProvider } from 'react-router-dom' 2 | import { ConfigProvider } from 'antd' 3 | import zhCN from 'antd/locale/zh_CN' 4 | import { router } from './routes' 5 | import aliyunThemeToken from './aliyunThemeToken' 6 | import { LoadingProvider } from './contexts/LoadingContext' 7 | import './App.css' 8 | 9 | function App() { 10 | return ( 11 | <LoadingProvider> 12 | <ConfigProvider 13 | locale={zhCN} 14 | theme={{ 15 | token: aliyunThemeToken, 16 | }} 17 | > 18 | <RouterProvider router={router} /> 19 | </ConfigProvider> 20 | </LoadingProvider> 21 | ) 22 | } 23 | 24 | export default App 25 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/developer/CreateExternalDeveloperParam.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.dto.params.developer; 2 | 3 | import com.alibaba.apiopenplatform.dto.converter.InputConverter; 4 | import com.alibaba.apiopenplatform.entity.DeveloperExternalIdentity; 5 | import com.alibaba.apiopenplatform.support.enums.DeveloperAuthType; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | 9 | /** 10 | * @author zh 11 | */ 12 | @Data 13 | @Builder 14 | public class CreateExternalDeveloperParam implements InputConverter<DeveloperExternalIdentity> { 15 | 16 | private String provider; 17 | 18 | private String subject; 19 | 20 | private String displayName; 21 | 22 | private String email; 23 | 24 | private DeveloperAuthType authType; 25 | } 26 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/portal/OAuth2Config.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.portal; 2 | 3 | import com.alibaba.apiopenplatform.support.enums.GrantType; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zh 8 | */ 9 | @Data 10 | public class OAuth2Config { 11 | 12 | /** 13 | * 提供商 14 | */ 15 | private String provider; 16 | 17 | /** 18 | * 名称 19 | */ 20 | private String name; 21 | 22 | /** 23 | * 是否启用 24 | */ 25 | private boolean enabled = true; 26 | 27 | /** 28 | * 授权模式 29 | */ 30 | private GrantType grantType; 31 | 32 | /** 33 | * JWT断言配置 34 | */ 35 | private JwtBearerConfig jwtBearerConfig; 36 | 37 | /** 38 | * 身份映射 39 | */ 40 | private IdentityMapping identityMapping = new IdentityMapping(); 41 | 42 | } 43 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/eslint.config.js: -------------------------------------------------------------------------------- ```javascript 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import tseslint from 'typescript-eslint' 6 | import { globalIgnores } from 'eslint/config' 7 | 8 | export default tseslint.config([ 9 | globalIgnores(['dist']), 10 | { 11 | files: ['**/*.{ts,tsx}'], 12 | extends: [ 13 | js.configs.recommended, 14 | tseslint.configs.recommended, 15 | reactHooks.configs['recommended-latest'], 16 | reactRefresh.configs.vite, 17 | ], 18 | languageOptions: { 19 | ecmaVersion: 2020, 20 | globals: globals.browser, 21 | }, 22 | }, 23 | ]) 24 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/tsconfig.node.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 4 | "target": "ES2023", 5 | "lib": ["ES2023"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "verbatimModuleSyntax": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "erasableSyntaxOnly": true, 21 | "noFallthroughCasesInSwitch": true, 22 | "noUncheckedSideEffectImports": true 23 | }, 24 | "include": ["vite.config.ts"] 25 | } 26 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/portal/AuthCodeConfig.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.support.portal; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author zh 7 | */ 8 | @Data 9 | public class AuthCodeConfig { 10 | 11 | /** 12 | * 凭证 13 | */ 14 | private String clientId; 15 | private String clientSecret; 16 | 17 | /** 18 | * 访问范围 19 | */ 20 | private String scopes; 21 | 22 | /** 23 | * Issuer 24 | */ 25 | private String issuer; 26 | 27 | /** 28 | * 授权端点 29 | */ 30 | private String authorizationEndpoint; 31 | 32 | /** 33 | * 令牌端点 34 | */ 35 | private String tokenEndpoint; 36 | 37 | /** 38 | * 用户信息端点 39 | */ 40 | private String userInfoEndpoint; 41 | 42 | /** 43 | * JWK Set URI 44 | */ 45 | private String jwkSetUri; 46 | 47 | /** 48 | * 重定向URI 49 | */ 50 | private String redirectUri; 51 | } 52 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/tsconfig.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true, 22 | 23 | /* Path mapping */ 24 | "baseUrl": ".", 25 | "paths": { 26 | "@/*": ["./src/*"] 27 | } 28 | }, 29 | "include": ["src"], 30 | "references": [{ "path": "./tsconfig.node.json" }] 31 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/types/gateway.ts: -------------------------------------------------------------------------------- ```typescript 1 | export interface Gateway { 2 | gatewayId: string 3 | gatewayName: string 4 | gatewayType: 'APIG_API' | 'HIGRESS' | 'APIG_AI' | 'ADP_AI_GATEWAY' 5 | createAt: string 6 | apigConfig?: ApigConfig 7 | higressConfig?: HigressConfig 8 | } 9 | 10 | export interface ApigConfig { 11 | region: string 12 | accessKey: string 13 | secretKey: string 14 | } 15 | 16 | export interface HigressConfig { 17 | username: string 18 | address: string 19 | password: string 20 | } 21 | 22 | export interface NacosInstance { 23 | nacosId: string 24 | nacosName: string 25 | serverUrl: string 26 | username: string 27 | password?: string 28 | accessKey?: string 29 | secretKey?: string 30 | description: string 31 | adminId: string 32 | createAt?: string | number 33 | } 34 | 35 | export type GatewayType = 'APIG_API' | 'APIG_AI' | 'HIGRESS' | 'ADP_AI_GATEWAY' 36 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/tsconfig.app.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 4 | "target": "ES2022", 5 | "useDefineForClassFields": true, 6 | "lib": ["ES2022", "DOM", "DOM.Iterable"], 7 | "module": "ESNext", 8 | "skipLibCheck": true, 9 | 10 | /* Bundler mode */ 11 | "moduleResolution": "bundler", 12 | "allowImportingTsExtensions": true, 13 | "verbatimModuleSyntax": true, 14 | "moduleDetection": "force", 15 | "noEmit": true, 16 | "jsx": "react-jsx", 17 | 18 | /* Linting */ 19 | "strict": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "erasableSyntaxOnly": true, 23 | "noFallthroughCasesInSwitch": true, 24 | "noUncheckedSideEffectImports": true, 25 | "allowSyntheticDefaultImports": true 26 | }, 27 | "include": ["src"] 28 | } 29 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/vite.config.ts: -------------------------------------------------------------------------------- ```typescript 1 | import { defineConfig, loadEnv } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vite.dev/config/ 5 | const env = loadEnv(process.env.NODE_ENV || 'development', process.cwd(), '') 6 | const apiPrefix = env.VITE_API_BASE_URL 7 | 8 | export default defineConfig({ 9 | plugins: [react()], 10 | server: { 11 | host: '0.0.0.0', 12 | allowedHosts: true, 13 | port: 5173, 14 | proxy: { 15 | [apiPrefix]: { 16 | target: 'http://localhost:8080', 17 | changeOrigin: true, 18 | rewrite: (p) => p.replace(new RegExp(`^${apiPrefix}`), ''), 19 | }, 20 | }, 21 | }, 22 | optimizeDeps: { 23 | include: ['monaco-editor/esm/vs/editor/editor.api'] 24 | }, 25 | build: { 26 | rollupOptions: { 27 | external: ['monaco-editor'] 28 | } 29 | }, 30 | define: { 31 | 'process.env': {} 32 | } 33 | }) 34 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/eslint.config.js: -------------------------------------------------------------------------------- ```javascript 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import { defineConfig, globalIgnores } from 'eslint/config' 6 | 7 | export default defineConfig([ 8 | globalIgnores(['dist']), 9 | { 10 | files: ['**/*.{js,jsx}'], 11 | extends: [ 12 | js.configs.recommended, 13 | reactHooks.configs['recommended-latest'], 14 | reactRefresh.configs.vite, 15 | ], 16 | languageOptions: { 17 | ecmaVersion: 2020, 18 | globals: globals.browser, 19 | parserOptions: { 20 | ecmaVersion: 'latest', 21 | ecmaFeatures: { jsx: true }, 22 | sourceType: 'module', 23 | }, 24 | }, 25 | rules: { 26 | 'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }], 27 | }, 28 | }, 29 | ]) 30 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/service/IdpService.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.service; 2 | 3 | import com.alibaba.apiopenplatform.support.enums.PublicKeyFormat; 4 | import com.alibaba.apiopenplatform.support.portal.OAuth2Config; 5 | import com.alibaba.apiopenplatform.support.portal.OidcConfig; 6 | 7 | import java.security.PublicKey; 8 | import java.util.List; 9 | 10 | /** 11 | * @author zh 12 | */ 13 | public interface IdpService { 14 | 15 | /** 16 | * 验证OIDC配置 17 | * 18 | * @param oidcConfigs 19 | */ 20 | void validateOidcConfigs(List<OidcConfig> oidcConfigs); 21 | 22 | /** 23 | * 验证OAuth2配置 24 | * 25 | * @param oauth2Configs 26 | */ 27 | void validateOAuth2Configs(List<OAuth2Config> oauth2Configs); 28 | 29 | /** 30 | * 加载JWT公钥 31 | * 32 | * @param format 33 | * @param publicKey 34 | * @return 35 | */ 36 | PublicKey loadPublicKey(PublicKeyFormat format, String publicKey); 37 | } 38 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/contexts/LoadingContext.tsx: -------------------------------------------------------------------------------- ```typescript 1 | import React, { createContext, useContext, useState, ReactNode } from 'react'; 2 | 3 | interface LoadingContextType { 4 | loading: boolean; 5 | setLoading: (loading: boolean) => void; 6 | } 7 | 8 | const LoadingContext = createContext<LoadingContextType | undefined>(undefined); 9 | 10 | export const useLoading = () => { 11 | const context = useContext(LoadingContext); 12 | if (context === undefined) { 13 | throw new Error('useLoading must be used within a LoadingProvider'); 14 | } 15 | return context; 16 | }; 17 | 18 | interface LoadingProviderProps { 19 | children: ReactNode; 20 | } 21 | 22 | export const LoadingProvider: React.FC<LoadingProviderProps> = ({ children }) => { 23 | const [loading, setLoading] = useState(false); 24 | 25 | return ( 26 | <LoadingContext.Provider value={{ loading, setLoading }}> 27 | {children} 28 | </LoadingContext.Provider> 29 | ); 30 | }; 31 | ``` -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- ```bash 1 | #!/bin/bash 2 | 3 | VERSION=1.0.0 4 | 5 | set -e 6 | 7 | # 构建 server 8 | echo "=== Building backend server ===" 9 | echo "Building with Maven..." 10 | mvn clean package -DskipTests 11 | 12 | cd portal-bootstrap 13 | echo "Building backend Docker image..." 14 | docker buildx build \ 15 | --platform linux/amd64 \ 16 | -t himarket-server:$VERSION \ 17 | --load . 18 | echo "Backend server build completed" 19 | cd .. 20 | 21 | # 构建 frontend 22 | cd portal-web/api-portal-frontend 23 | echo "=== Building frontend ===" 24 | rm -rf ./dist 25 | npm install --force 26 | npm run build 27 | docker buildx build \ 28 | -t himarket-frontend:$VERSION \ 29 | --platform linux/amd64 \ 30 | --load . 31 | 32 | # 构建 admin 33 | cd ../api-portal-admin 34 | echo "=== Building admin ===" 35 | rm -rf ./dist 36 | npm install --force 37 | npm run build 38 | docker buildx build \ 39 | -t himarket-admin:$VERSION \ 40 | --platform linux/amd64 \ 41 | --load . 42 | 43 | echo "All images have been built successfully!" 44 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/public/MCP.svg: -------------------------------------------------------------------------------- ``` 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> 3 | <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="200px" height="200px" viewBox="0 0 200 200" preserveAspectRatio="xMidYMid meet"> 4 | <g fill="#000000"> 5 | <path d="M97.7 185.2 l-8.7 -8.7 40.5 -40.5 c22.3 -22.3 40.5 -40.9 40.5 -41.5 0 -0.6 -6.8 -7.8 -15 -16 l-15 -15 -32.8 32.8 -32.7 32.7 -4.3 -4.2 -4.2 -4.3 32.7 -32.7 32.8 -32.8 -15.5 -15.5 -15.5 -15.5 -41 41 -41.1 41 -3.9 -4 -4 -4 45.3 -45.3 45.2 -45.2 43.2 43.2 43.3 43.3 -41 41 -41 41 5 5 4.9 5 -3.9 4 c-2.1 2.2 -4.2 4 -4.5 4 -0.3 0 -4.5 -3.9 -9.3 -8.8z"/> 6 | <path d="M53.7 141.2 l-23.7 -23.7 35.3 -35.3 35.3 -35.2 3.9 4 3.9 4 -30.9 31 -31 31 15.5 15.5 15.5 15.5 31 -31 31 -31 4.3 4.3 4.2 4.2 -35.3 35.3 -35.2 35.2 -23.8 -23.8z"/> 7 | </g> 8 | </svg> ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/controller/OAuth2Controller.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.controller; 2 | 3 | import com.alibaba.apiopenplatform.dto.result.AuthResult; 4 | import com.alibaba.apiopenplatform.service.OAuth2Service; 5 | import lombok.RequiredArgsConstructor; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * @author zh 13 | */ 14 | @RestController 15 | @RequiredArgsConstructor 16 | @RequestMapping("/developers/oauth2") 17 | public class OAuth2Controller { 18 | 19 | private final OAuth2Service oAuth2Service; 20 | 21 | @PostMapping("/token") 22 | public AuthResult authenticate(@RequestParam("grant_type") String grantType, 23 | @RequestParam("assertion") String assertion) { 24 | return oAuth2Service.authenticate(grantType, assertion); 25 | } 26 | } 27 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/consumer/JwtConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.consumer; 21 | 22 | import lombok.Data; 23 | 24 | @Data 25 | public class JwtConfig { 26 | 27 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/ProtocolType.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum ProtocolType { 23 | 24 | HTTP, 25 | 26 | HTTPS, 27 | 28 | ; 29 | } 30 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/DomainType.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum DomainType { 23 | 24 | DEFAULT, 25 | 26 | CUSTOM, 27 | 28 | ; 29 | } 30 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/CredentialMode.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum CredentialMode { 23 | 24 | SYSTEM, 25 | 26 | CUSTOM, 27 | 28 | ; 29 | } 30 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/ProductType.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum ProductType { 23 | 24 | REST_API, 25 | 26 | HTTP_API, 27 | 28 | MCP_SERVER, 29 | } 30 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/ConsumerAuthType.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum ConsumerAuthType { 23 | 24 | KEY_AUTH, 25 | 26 | HMAC, 27 | 28 | JWT, 29 | 30 | ; 31 | } 32 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/service/OidcService.java: -------------------------------------------------------------------------------- ```java 1 | package com.alibaba.apiopenplatform.service; 2 | 3 | import com.alibaba.apiopenplatform.dto.result.AuthResult; 4 | import com.alibaba.apiopenplatform.dto.result.IdpResult; 5 | import com.alibaba.apiopenplatform.support.portal.OidcConfig; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | import java.util.List; 10 | 11 | public interface OidcService { 12 | 13 | /** 14 | * 重定向到授权服务器 15 | * 16 | * @param provider 17 | * @param apiPrefix 18 | * @param request 19 | * @return 20 | */ 21 | String buildAuthorizationUrl(String provider, String apiPrefix, HttpServletRequest request); 22 | 23 | /** 24 | * 授权服务器回调 25 | * 26 | * @param code 27 | * @param state 28 | * @param request 29 | * @param response 30 | * @return 31 | */ 32 | AuthResult handleCallback(String code, String state, HttpServletRequest request, HttpServletResponse response); 33 | 34 | /** 35 | * 可用的OIDC认证列表 36 | * 37 | * @return 38 | */ 39 | List<IdpResult> getAvailableProviders(); 40 | 41 | } 42 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/portal/PortalUiConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.portal; 21 | 22 | import lombok.Data; 23 | 24 | @Data 25 | public class PortalUiConfig { 26 | 27 | private String logo; 28 | 29 | private String icon; 30 | } 31 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/UserType.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum UserType { 23 | /** 24 | * 管理员用户 25 | */ 26 | ADMIN, 27 | 28 | /** 29 | * 开发者用户 30 | */ 31 | DEVELOPER, 32 | 33 | ; 34 | } 35 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/DeveloperStatus.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum DeveloperStatus { 23 | 24 | /** 25 | * 已激活 26 | */ 27 | APPROVED, 28 | 29 | /** 30 | * 待审核 31 | */ 32 | PENDING, 33 | 34 | ; 35 | } 36 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/vite.config.ts: -------------------------------------------------------------------------------- ```typescript 1 | import { defineConfig, loadEnv } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | import path from 'path' 4 | import { fileURLToPath } from 'url' 5 | 6 | const __dirname = path.dirname(fileURLToPath(import.meta.url)) 7 | const env = loadEnv(process.env.NODE_ENV || 'development', process.cwd(), '') 8 | const apiPrefix = env.VITE_API_BASE_URL || '/api/v1' 9 | // https://vite.dev/config/ 10 | export default defineConfig({ 11 | plugins: [react()], 12 | server: { 13 | host: '0.0.0.0', 14 | port: 5174, 15 | proxy: { 16 | [apiPrefix]: { 17 | target: 'http://localhost:8080', 18 | changeOrigin: true, 19 | rewrite: (path) => path.replace(new RegExp(`^${apiPrefix}`), ''), 20 | }, 21 | }, 22 | }, 23 | resolve: { 24 | alias: { 25 | '@': path.resolve(__dirname, './src'), 26 | }, 27 | }, 28 | build: { 29 | rollupOptions: { 30 | output: { 31 | entryFileNames: 'index.js', 32 | chunkFileNames: 'chunk-[name].js', 33 | assetFileNames: 'assets/[name].[ext]' 34 | } 35 | } 36 | }, 37 | define: { 38 | 'process.env': {} 39 | } 40 | }) ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/product/HigressRefConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.product; 21 | 22 | import lombok.Data; 23 | 24 | @Data 25 | public class HigressRefConfig { 26 | 27 | private String routeName; 28 | 29 | private String mcpServerName; 30 | } 31 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/SubscriptionStatus.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum SubscriptionStatus { 23 | /** 24 | * Pending approval 25 | */ 26 | PENDING, 27 | 28 | /** 29 | * Approved and active 30 | */ 31 | APPROVED, 32 | 33 | ; 34 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/admin/ResetPasswordParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.admin; 21 | 22 | import lombok.Data; 23 | 24 | /** 25 | * 修改密码参数 26 | * 27 | */ 28 | @Data 29 | public class ResetPasswordParam { 30 | 31 | private String oldPassword; 32 | 33 | private String newPassword; 34 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/consumer/QueryConsumerParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.consumer; 21 | 22 | import lombok.Data; 23 | 24 | @Data 25 | public class QueryConsumerParam { 26 | 27 | private String portalId; 28 | 29 | private String developerId; 30 | 31 | private String name; 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/product/NacosRefConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.product; 21 | 22 | import lombok.Data; 23 | 24 | /** 25 | * Nacos MCP Server 配置 26 | */ 27 | @Data 28 | public class NacosRefConfig { 29 | 30 | private String mcpServerName; 31 | 32 | private String namespaceId; 33 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/ConsumerStatus.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum ConsumerStatus { 23 | 24 | /** 25 | * 待审核 26 | */ 27 | PENDING, 28 | 29 | /** 30 | * 已审核 31 | */ 32 | APPROVED, 33 | 34 | /** 35 | * 不可用,对应的网关资源已删除 36 | */ 37 | DISABLED, 38 | 39 | ; 40 | } 41 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/product/UnPublishProductParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.product; 21 | 22 | import lombok.Data; 23 | 24 | import javax.validation.constraints.NotBlank; 25 | 26 | @Data 27 | public class UnPublishProductParam { 28 | 29 | @NotBlank(message = "门户ID不能为空") 30 | private String portalId; 31 | } 32 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/ProductStatus.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | public enum ProductStatus { 23 | 24 | /** 25 | * 未配置API和MCP Server 26 | */ 27 | PENDING, 28 | 29 | /** 30 | * 已配置API或MCP Server 31 | */ 32 | READY, 33 | 34 | /** 35 | * 已发布 36 | */ 37 | PUBLISHED, 38 | 39 | ; 40 | } 41 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/common/User.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.common; 21 | 22 | import com.alibaba.apiopenplatform.support.enums.UserType; 23 | import lombok.Builder; 24 | import lombok.Data; 25 | 26 | @Data 27 | @Builder 28 | public class User { 29 | 30 | private UserType userType; 31 | 32 | private String userId; 33 | } 34 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/HigressAPIType.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | import lombok.Getter; 23 | import lombok.RequiredArgsConstructor; 24 | 25 | @RequiredArgsConstructor 26 | @Getter 27 | public enum HigressAPIType { 28 | 29 | ROUTE("Route"), 30 | 31 | MCP("MCP"), 32 | 33 | ; 34 | 35 | private final String type; 36 | } 37 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/developer/UnbindExternalIdentityParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.developer; 21 | 22 | import lombok.Data; 23 | 24 | /** 25 | * 解绑外部身份参数 26 | * 27 | */ 28 | @Data 29 | public class UnbindExternalIdentityParam { 30 | 31 | private String providerName; 32 | 33 | private String providerSubject; 34 | 35 | private String portalId; 36 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/developer/UpdateDeveloperStatusParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.developer; 21 | 22 | import com.alibaba.apiopenplatform.support.enums.DeveloperStatus; 23 | import lombok.Data; 24 | 25 | @Data 26 | public class UpdateDeveloperStatusParam { 27 | 28 | private String portalId; 29 | 30 | private DeveloperStatus status; 31 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/consumer/QuerySubscriptionParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.consumer; 21 | 22 | import com.alibaba.apiopenplatform.support.enums.SubscriptionStatus; 23 | import lombok.Data; 24 | 25 | @Data 26 | public class QuerySubscriptionParam { 27 | 28 | private SubscriptionStatus status; 29 | 30 | private String productName; 31 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/APIGAPIType.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | import lombok.Getter; 23 | import lombok.RequiredArgsConstructor; 24 | 25 | @Getter 26 | @RequiredArgsConstructor 27 | public enum APIGAPIType { 28 | 29 | REST("Rest"), 30 | 31 | HTTP("Http"), 32 | 33 | MCP("MCP"), 34 | 35 | ; 36 | 37 | private final String type; 38 | } 39 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/components/icons/McpServerIcon.tsx: -------------------------------------------------------------------------------- ```typescript 1 | import React from 'react'; 2 | import Icon from '@ant-design/icons'; 3 | import type { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon'; 4 | 5 | // 基于真实的 MCP.svg 文件的图标组件 6 | const McpSvg = () => ( 7 | <svg 8 | width="1em" 9 | height="1em" 10 | viewBox="0 0 200 200" 11 | fill="currentColor" 12 | xmlns="http://www.w3.org/2000/svg" 13 | > 14 | <g fill="currentColor"> 15 | <path d="M97.7 185.2 l-8.7 -8.7 40.5 -40.5 c22.3 -22.3 40.5 -40.9 40.5 -41.5 0 -0.6 -6.8 -7.8 -15 -16 l-15 -15 -32.8 32.8 -32.7 32.7 -4.3 -4.2 -4.2 -4.3 32.7 -32.7 32.8 -32.8 -15.5 -15.5 -15.5 -15.5 -41 41 -41.1 41 -3.9 -4 -4 -4 45.3 -45.3 45.2 -45.2 43.2 43.2 43.3 43.3 -41 41 -41 41 5 5 4.9 5 -3.9 4 c-2.1 2.2 -4.2 4 -4.5 4 -0.3 0 -4.5 -3.9 -9.3 -8.8z"/> 16 | <path d="M53.7 141.2 l-23.7 -23.7 35.3 -35.3 35.3 -35.2 3.9 4 3.9 4 -30.9 31 -31 31 15.5 15.5 15.5 15.5 31 -31 31 -31 4.3 4.3 4.2 4.2 -35.3 35.3 -35.2 35.2 -23.8 -23.8z"/> 17 | </g> 18 | </svg> 19 | ); 20 | 21 | const McpServerIcon: React.FC<Partial<CustomIconComponentProps>> = (props) => ( 22 | <Icon component={McpSvg} {...props} /> 23 | ); 24 | 25 | export default McpServerIcon; 26 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/developer/QueryDeveloperParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.developer; 21 | 22 | import com.alibaba.apiopenplatform.support.enums.DeveloperStatus; 23 | import lombok.Data; 24 | 25 | @Data 26 | public class QueryDeveloperParam { 27 | 28 | private String portalId; 29 | 30 | private String username; 31 | 32 | private DeveloperStatus status; 33 | } 34 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/nacos/QueryNacosNamespaceParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.nacos; 21 | 22 | import lombok.Data; 23 | 24 | /** 25 | * 查询Nacos命名空间参数 26 | * 27 | */ 28 | @Data 29 | public class QueryNacosNamespaceParam extends CreateNacosParam { 30 | /** 31 | * runtime namespace to query on remote Nacos (not stored on instance) 32 | */ 33 | private String namespace; 34 | } 35 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/product/APIGRefConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.product; 21 | 22 | import lombok.Data; 23 | 24 | @Data 25 | public class APIGRefConfig { 26 | 27 | private String apiId; 28 | 29 | private String apiName; 30 | 31 | /** 32 | * MCP标识信息 33 | */ 34 | private String mcpServerId; 35 | private String mcpRouteId; 36 | private String mcpServerName; 37 | 38 | } 39 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/common/Encrypted.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.common; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.FIELD) 29 | public @interface Encrypted { 30 | } 31 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/JwtConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.consumer.JwtConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class JwtConfigConverter extends JsonConverter<JwtConfig> { 28 | 29 | protected JwtConfigConverter() { 30 | super(JwtConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/NacosRefConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.product.NacosRefConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter 27 | public class NacosRefConfigConverter extends JsonConverter<NacosRefConfig> { 28 | 29 | public NacosRefConfigConverter() { 30 | super(NacosRefConfig.class); 31 | } 32 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/APIGConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.gateway.APIGConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class APIGConfigConverter extends JsonConverter<APIGConfig> { 28 | 29 | protected APIGConfigConverter() { 30 | super(APIGConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/HmacConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.consumer.HmacConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class HmacConfigConverter extends JsonConverter<HmacConfig> { 28 | 29 | protected HmacConfigConverter() { 30 | super(HmacConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/developer/DeveloperLoginParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.developer; 21 | 22 | import lombok.Data; 23 | import javax.validation.constraints.NotBlank; 24 | import lombok.NoArgsConstructor; 25 | 26 | @Data 27 | public class DeveloperLoginParam { 28 | 29 | @NotBlank(message = "用户名不能为空") 30 | private String username; 31 | 32 | @NotBlank(message = "密码不能为空") 33 | private String password; 34 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/src/App.css: -------------------------------------------------------------------------------- ```css 1 | #root { 2 | 3 | } 4 | 5 | .logo { 6 | height: 6em; 7 | padding: 1.5em; 8 | will-change: filter; 9 | transition: filter 300ms; 10 | } 11 | .logo:hover { 12 | filter: drop-shadow(0 0 2em #646cffaa); 13 | } 14 | .logo.react:hover { 15 | filter: drop-shadow(0 0 2em #61dafbaa); 16 | } 17 | 18 | @keyframes logo-spin { 19 | from { 20 | transform: rotate(0deg); 21 | } 22 | to { 23 | transform: rotate(360deg); 24 | } 25 | } 26 | 27 | @media (prefers-reduced-motion: no-preference) { 28 | a:nth-of-type(2) .logo { 29 | animation: logo-spin infinite 20s linear; 30 | } 31 | } 32 | 33 | .card { 34 | padding: 2em; 35 | } 36 | 37 | .read-the-docs { 38 | color: #888; 39 | } 40 | 41 | /* 用户下拉菜单样式 */ 42 | .user-dropdown .ant-dropdown-menu { 43 | border-radius: 8px; 44 | box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); 45 | border: 1px solid #f0f0f0; 46 | min-width: 200px; 47 | } 48 | 49 | .user-dropdown .ant-dropdown-menu-item { 50 | padding: 8px 12px; 51 | font-size: 14px; 52 | } 53 | 54 | .user-dropdown .ant-dropdown-menu-item:hover { 55 | background-color: #f5f5f5; 56 | } 57 | 58 | .user-dropdown .ant-dropdown-menu-item-disabled { 59 | cursor: default; 60 | color: inherit; 61 | background-color: transparent; 62 | } 63 | 64 | .user-dropdown .ant-dropdown-menu-item-disabled:hover { 65 | background-color: transparent; 66 | } 67 | 68 | .user-dropdown .ant-dropdown-menu-divider { 69 | margin: 4px 0; 70 | } 71 | ``` -------------------------------------------------------------------------------- /deploy/helm/Chart.yaml: -------------------------------------------------------------------------------- ```yaml 1 | apiVersion: v2 2 | name: himarket 3 | description: HiMarket AI 开放平台 Helm Chart 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.1.0 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | # It is recommended to use it with quotes. 24 | appVersion: "1.16.0" 25 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/ApiKeyConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.consumer.ApiKeyConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class ApiKeyConfigConverter extends JsonConverter<ApiKeyConfig> { 28 | 29 | protected ApiKeyConfigConverter() { 30 | super(ApiKeyConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/GatewayConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.gateway.GatewayConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class GatewayConfigConverter extends JsonConverter<GatewayConfig> { 28 | 29 | public GatewayConfigConverter() { 30 | super(GatewayConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/APIGRefConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.product.APIGRefConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class APIGRefConfigConverter extends JsonConverter<APIGRefConfig> { 28 | 29 | protected APIGRefConfigConverter() { 30 | super(APIGRefConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/HigressConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.gateway.HigressConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class HigressConfigConverter extends JsonConverter<HigressConfig> { 28 | 29 | protected HigressConfigConverter() { 30 | super(HigressConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/PortalUiConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.portal.PortalUiConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class PortalUiConfigConverter extends JsonConverter<PortalUiConfig> { 28 | 29 | public PortalUiConfigConverter() { 30 | super(PortalUiConfig.class); 31 | } 32 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/core/event/PortalDeletingEvent.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.core.event; 21 | 22 | import lombok.Getter; 23 | import org.springframework.context.ApplicationEvent; 24 | 25 | @Getter 26 | public class PortalDeletingEvent extends ApplicationEvent { 27 | 28 | private final String portalId; 29 | 30 | public PortalDeletingEvent(String portalId) { 31 | super(portalId); 32 | this.portalId = portalId; 33 | } 34 | } 35 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/admin/AdminLoginParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.admin; 21 | 22 | import lombok.Data; 23 | import javax.validation.constraints.NotBlank; 24 | import lombok.NoArgsConstructor; 25 | 26 | /** 27 | * 管理员登录参数DTO 28 | * 29 | */ 30 | @Data 31 | public class AdminLoginParam { 32 | @NotBlank(message = "用户名不能为空") 33 | private String username; 34 | 35 | @NotBlank(message = "密码不能为空") 36 | private String password; 37 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/enums/SourceType.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.enums; 21 | 22 | /** 23 | * 数据来源类型枚举 24 | * 25 | */ 26 | public enum SourceType { 27 | 28 | /** 29 | * 来自Gateway (Higress, APIG等) 30 | */ 31 | GATEWAY, 32 | 33 | /** 34 | * 来自Nacos注册中心 35 | */ 36 | NACOS; 37 | 38 | public boolean isGateway() { 39 | return this == GATEWAY; 40 | } 41 | 42 | public boolean isNacos() { 43 | return this == NACOS; 44 | } 45 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/core/event/ProductDeletingEvent.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.core.event; 21 | 22 | import lombok.Getter; 23 | import org.springframework.context.ApplicationEvent; 24 | 25 | @Getter 26 | public class ProductDeletingEvent extends ApplicationEvent { 27 | 28 | private final String productId; 29 | 30 | public ProductDeletingEvent(String productId) { 31 | super(productId); 32 | this.productId = productId; 33 | } 34 | } 35 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/HigressRefConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.product.HigressRefConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class HigressRefConfigConverter extends JsonConverter<HigressRefConfig> { 28 | 29 | protected HigressRefConfigConverter() { 30 | super(HigressRefConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/repository/ConsumerCredentialRepository.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.repository; 21 | 22 | import com.alibaba.apiopenplatform.entity.ConsumerCredential; 23 | 24 | import java.util.Optional; 25 | 26 | public interface ConsumerCredentialRepository extends BaseRepository<ConsumerCredential, Long> { 27 | 28 | Optional<ConsumerCredential> findByConsumerId(String consumerId); 29 | 30 | void deleteAllByConsumerId(String consumerId); 31 | } 32 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/ConsumerAuthConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.consumer.ConsumerAuthConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class ConsumerAuthConfigConverter extends JsonConverter<ConsumerAuthConfig> { 28 | 29 | public ConsumerAuthConfigConverter() { 30 | super(ConsumerAuthConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/consumer/AdpAIAuthConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.consumer; 21 | 22 | import lombok.Builder; 23 | import lombok.Data; 24 | 25 | /** 26 | * ADP AI网关授权配置 27 | */ 28 | @Data 29 | @Builder 30 | public class AdpAIAuthConfig { 31 | 32 | /** 33 | * MCP Server名称 34 | */ 35 | private String mcpServerName; 36 | 37 | /** 38 | * 消费者ID 39 | */ 40 | private String consumerId; 41 | 42 | /** 43 | * 网关实例ID 44 | */ 45 | private String gwInstanceId; 46 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/converter/PortalSettingConfigConverter.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.converter; 21 | 22 | import com.alibaba.apiopenplatform.support.portal.PortalSettingConfig; 23 | 24 | import javax.persistence.Converter; 25 | 26 | @Converter(autoApply = true) 27 | public class PortalSettingConfigConverter extends JsonConverter<PortalSettingConfig> { 28 | 29 | public PortalSettingConfigConverter() { 30 | super(PortalSettingConfig.class); 31 | } 32 | } 33 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/core/event/DeveloperDeletingEvent.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.core.event; 21 | 22 | import lombok.Getter; 23 | import org.springframework.context.ApplicationEvent; 24 | 25 | @Getter 26 | public class DeveloperDeletingEvent extends ApplicationEvent { 27 | 28 | private final String developerId; 29 | 30 | public DeveloperDeletingEvent(String developerId) { 31 | super(developerId); 32 | this.developerId = developerId; 33 | } 34 | } 35 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/gateway/HigressConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.gateway; 21 | 22 | import com.alibaba.apiopenplatform.support.common.Encrypted; 23 | import lombok.Data; 24 | 25 | @Data 26 | public class HigressConfig { 27 | 28 | private String address; 29 | 30 | private String username; 31 | 32 | @Encrypted 33 | private String password; 34 | 35 | public String buildUniqueKey() { 36 | return String.format("%s:%s:%s", address, username, password); 37 | } 38 | } 39 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/consumer/HmacConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.consumer; 21 | 22 | import com.alibaba.apiopenplatform.support.enums.CredentialMode; 23 | import lombok.Data; 24 | 25 | import java.util.List; 26 | 27 | @Data 28 | public class HmacConfig { 29 | 30 | private List<HmacCredential> credentials; 31 | 32 | @Data 33 | public static class HmacCredential { 34 | private String ak; 35 | private String sk; 36 | 37 | private CredentialMode mode; 38 | } 39 | } 40 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/product/QueryProductParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.product; 21 | 22 | import com.alibaba.apiopenplatform.support.enums.ProductStatus; 23 | import com.alibaba.apiopenplatform.support.enums.ProductType; 24 | import lombok.Data; 25 | 26 | @Data 27 | public class QueryProductParam { 28 | 29 | private String portalId; 30 | 31 | private ProductType type; 32 | 33 | private String name; 34 | 35 | private String category; 36 | 37 | private ProductStatus status; 38 | } 39 | ``` -------------------------------------------------------------------------------- /portal-web/api-portal-frontend/proxy.conf: -------------------------------------------------------------------------------- ``` 1 | location ^~ /api/v1 { 2 | proxy_http_version 1.1; 3 | proxy_set_header Connection ""; 4 | 5 | # 保留原始host header - 这是最重要的配置 6 | proxy_set_header Host $http_host; 7 | 8 | # 设置X-Forwarded-Host header 9 | proxy_set_header X-Forwarded-Host $http_host; 10 | 11 | # 设置真实的客户端IP 12 | proxy_set_header X-Real-IP $remote_addr; 13 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 14 | 15 | # 设置协议信息 16 | proxy_set_header X-Forwarded-Proto $scheme; 17 | 18 | # 设置原始请求的Origin header 19 | proxy_set_header Origin $http_origin; 20 | 21 | # 设置Referer header 22 | proxy_set_header Referer $http_referer; 23 | 24 | # 设置User-Agent 25 | proxy_set_header User-Agent $http_user_agent; 26 | 27 | # 超时设置 28 | proxy_connect_timeout 30s; 29 | proxy_send_timeout 30s; 30 | proxy_read_timeout 30s; 31 | 32 | rewrite ^/api/v1/(.*)$ /$1 break; 33 | proxy_pass {{ HIMARKET_SERVER }}; 34 | } 35 | 36 | location ~ .*\.(js|css|gif|jpg|jpeg|png|svg|json|otf|ico)$ { 37 | root /app; 38 | } 39 | 40 | location / { 41 | try_files $uri $uri/ /index.html; 42 | root /app; 43 | index index.html index.htm; 44 | } 45 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/consumer/ConsumerAuthConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.consumer; 21 | 22 | import lombok.Builder; 23 | import lombok.Data; 24 | 25 | @Data 26 | @Builder 27 | public class ConsumerAuthConfig { 28 | 29 | /** 30 | * for APIG 31 | */ 32 | private APIGAuthConfig apigAuthConfig; 33 | 34 | /** 35 | * for Higress 36 | */ 37 | private HigressAuthConfig higressAuthConfig; 38 | 39 | /** 40 | * for ADP AI Gateway 41 | */ 42 | private AdpAIAuthConfig adpAIAuthConfig; 43 | } 44 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/gateway/APIGConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.gateway; 21 | 22 | import com.alibaba.apiopenplatform.support.common.Encrypted; 23 | import lombok.Data; 24 | 25 | @Data 26 | public class APIGConfig { 27 | 28 | @Encrypted 29 | private String accessKey; 30 | 31 | @Encrypted 32 | private String secretKey; 33 | 34 | private String region; 35 | 36 | public String buildUniqueKey() { 37 | return String.format("%s:%s:%s", accessKey, secretKey, region); 38 | } 39 | } 40 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/product/PublishProductParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.product; 21 | 22 | import com.alibaba.apiopenplatform.dto.converter.InputConverter; 23 | import com.alibaba.apiopenplatform.entity.ProductPublication; 24 | import lombok.Data; 25 | 26 | import javax.validation.constraints.NotBlank; 27 | 28 | @Data 29 | public class PublishProductParam implements InputConverter<ProductPublication> { 30 | 31 | @NotBlank(message = "门户ID不能为空") 32 | private String portalId; 33 | } 34 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/result/MCPServerResult.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.result; 21 | 22 | import io.swagger.v3.oas.annotations.media.Schema; 23 | import lombok.Data; 24 | 25 | @Data 26 | @Schema( 27 | oneOf = { 28 | APIGMCPServerResult.class, 29 | HigressMCPServerResult.class, 30 | NacosMCPServerResult.class 31 | }, 32 | discriminatorProperty = "type" 33 | ) 34 | 35 | public class MCPServerResult { 36 | protected String mcpServerName; 37 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/result/GatewayMCPServerResult.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.result; 21 | 22 | import io.swagger.v3.oas.annotations.media.Schema; 23 | import lombok.Data; 24 | 25 | @Data 26 | @Schema( 27 | oneOf = { 28 | APIGMCPServerResult.class, 29 | HigressMCPServerResult.class, 30 | AdpMCPServerResult.class 31 | }, 32 | discriminatorProperty = "type" 33 | ) 34 | public class GatewayMCPServerResult { 35 | 36 | protected String mcpServerName; 37 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/consumer/CreateSubscriptionParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.consumer; 21 | 22 | import com.alibaba.apiopenplatform.dto.converter.InputConverter; 23 | import com.alibaba.apiopenplatform.entity.ProductSubscription; 24 | import lombok.Data; 25 | 26 | import javax.validation.constraints.NotBlank; 27 | 28 | @Data 29 | public class CreateSubscriptionParam implements InputConverter<ProductSubscription> { 30 | 31 | @NotBlank(message = "Product ID不能为空") 32 | private String productId; 33 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/repository/GatewayRepository.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.repository; 21 | 22 | import com.alibaba.apiopenplatform.entity.Gateway; 23 | import org.springframework.data.domain.Page; 24 | import org.springframework.data.domain.Pageable; 25 | 26 | import java.util.Optional; 27 | 28 | public interface GatewayRepository extends BaseRepository<Gateway, Long> { 29 | 30 | Optional<Gateway> findByGatewayId(String gatewayId); 31 | 32 | Page<Gateway> findByAdminId(String adminId, Pageable pageable); 33 | } 34 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/core/annotation/AdminAuth.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.core.annotation; 21 | 22 | import org.springframework.security.access.prepost.PreAuthorize; 23 | 24 | import java.lang.annotation.ElementType; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.RetentionPolicy; 27 | import java.lang.annotation.Target; 28 | 29 | @Target({ElementType.METHOD, ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @PreAuthorize("hasRole('ADMIN')") 32 | public @interface AdminAuth { 33 | } 34 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/result/APIConfigResult.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.result; 21 | 22 | import lombok.Data; 23 | 24 | @Data 25 | public class APIConfigResult { 26 | 27 | private String spec; 28 | 29 | private APIMetadata meta; 30 | 31 | @Data 32 | public static class APIMetadata { 33 | 34 | /** 35 | * 来源 36 | * API网关/Higress 37 | */ 38 | private String source; 39 | 40 | /** 41 | * 类型 42 | * API网关:HTTP/REST 43 | * Higress:Route 44 | */ 45 | private String type; 46 | } 47 | } 48 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/core/annotation/DeveloperAuth.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.core.annotation; 21 | 22 | import org.springframework.security.access.prepost.PreAuthorize; 23 | 24 | import java.lang.annotation.ElementType; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.RetentionPolicy; 27 | import java.lang.annotation.Target; 28 | 29 | @Target({ElementType.METHOD, ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @PreAuthorize("hasRole('DEVELOPER')") 32 | public @interface DeveloperAuth { 33 | } 34 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/result/ConsumerResult.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.result; 21 | 22 | import com.alibaba.apiopenplatform.dto.converter.OutputConverter; 23 | import com.alibaba.apiopenplatform.entity.Consumer; 24 | import lombok.Data; 25 | 26 | import java.time.LocalDateTime; 27 | 28 | @Data 29 | public class ConsumerResult implements OutputConverter<ConsumerResult, Consumer> { 30 | 31 | private String consumerId; 32 | 33 | private String name; 34 | 35 | private String description; 36 | 37 | private LocalDateTime createAt; 38 | } 39 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/repository/AdministratorRepository.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.repository; 21 | 22 | import com.alibaba.apiopenplatform.entity.Administrator; 23 | import org.springframework.data.jpa.repository.JpaRepository; 24 | import java.util.Optional; 25 | 26 | /** 27 | * 管理员数据访问接口,提供管理员相关的数据库操作 28 | * 29 | */ 30 | public interface AdministratorRepository extends JpaRepository<Administrator, Long> { 31 | Optional<Administrator> findByAdminId(String adminId); 32 | Optional<Administrator> findByUsername(String username); 33 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/result/AdminResult.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.result; 21 | 22 | import com.alibaba.apiopenplatform.dto.converter.OutputConverter; 23 | import com.alibaba.apiopenplatform.entity.Administrator; 24 | import lombok.Data; 25 | 26 | import java.time.LocalDateTime; 27 | 28 | @Data 29 | public class AdminResult implements OutputConverter<AdminResult, Administrator> { 30 | 31 | private String adminId; 32 | 33 | private String username; 34 | 35 | private LocalDateTime createAt; 36 | 37 | private LocalDateTime updatedAt; 38 | } ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/core/annotation/AdminOrDeveloperAuth.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.core.annotation; 21 | 22 | import org.springframework.security.access.prepost.PreAuthorize; 23 | 24 | import java.lang.annotation.ElementType; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.RetentionPolicy; 27 | import java.lang.annotation.Target; 28 | 29 | @Target({ElementType.METHOD, ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @PreAuthorize("hasRole('ADMIN') or hasRole('DEVELOPER')") 32 | public @interface AdminOrDeveloperAuth { 33 | } 34 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/core/utils/PasswordHasher.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.core.utils; 21 | 22 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 23 | 24 | public class PasswordHasher { 25 | 26 | private static final BCryptPasswordEncoder ENCODER = new BCryptPasswordEncoder(); 27 | 28 | public static String hash(String plainPassword) { 29 | return ENCODER.encode(plainPassword); 30 | } 31 | 32 | public static boolean verify(String plainPassword, String hashed) { 33 | return ENCODER.matches(plainPassword, hashed); 34 | } 35 | } ``` -------------------------------------------------------------------------------- /portal-web/api-portal-admin/src/types/consumer.ts: -------------------------------------------------------------------------------- ```typescript 1 | // Consumer 相关类型定义 2 | 3 | export interface Consumer { 4 | consumerId: string; 5 | name: string; 6 | description?: string; 7 | status?: string; 8 | createAt?: string; 9 | createdAt?: string; // 支持两种字段名 10 | enabled?: boolean; 11 | } 12 | 13 | // Portal 开发者统计信息(之前错误命名为Consumer) 14 | export interface DeveloperStats { 15 | id: string; 16 | name: string; 17 | email: string; 18 | status: string; 19 | plan: string; 20 | joinedAt: string; 21 | lastActive: string; 22 | apiCalls: number; 23 | subscriptions: number; 24 | } 25 | 26 | // 凭据相关类型 27 | export interface HMACCredential { 28 | ak?: string; 29 | sk?: string; 30 | } 31 | 32 | export interface APIKeyCredential { 33 | apiKey?: string; 34 | } 35 | 36 | export type ConsumerCredential = HMACCredential | APIKeyCredential; 37 | 38 | export interface ConsumerCredentialResult { 39 | apiKeyConfig?: { 40 | credentials?: Array<{ 41 | apiKey?: string; 42 | mode?: 'SYSTEM' | 'CUSTOM'; 43 | }>; 44 | source?: string; 45 | key?: string; 46 | }; 47 | hmacConfig?: { 48 | credentials?: Array<{ 49 | ak?: string; 50 | sk?: string; 51 | mode?: 'SYSTEM' | 'CUSTOM'; 52 | }>; 53 | source?: string; 54 | accessKeyId?: string; 55 | secretAccessKey?: string; 56 | }; 57 | } 58 | 59 | export interface Subscription { 60 | subscriptionId: string; 61 | productId: string; 62 | productName?: string; 63 | status: string; 64 | createdAt: string; 65 | } 66 | 67 | export interface CreateCredentialParam { 68 | credentialType: 'HMAC' | 'API_KEY'; 69 | apiKey?: string; 70 | } 71 | ``` -------------------------------------------------------------------------------- /portal-bootstrap/src/main/resources/application.yaml: -------------------------------------------------------------------------------- ```yaml 1 | spring: 2 | datasource: 3 | url: jdbc:mariadb://${db.host}:${db.port}/${db.name}?createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC 4 | username: ${db.username} 5 | password: ${db.password} 6 | driver-class-name: org.mariadb.jdbc.Driver 7 | jpa: 8 | hibernate: 9 | ddl-auto: update 10 | show-sql: true 11 | properties: 12 | hibernate: 13 | format_sql: true 14 | 15 | #db: 16 | # host: YourDBHost 17 | # port: 3306 18 | # name: YourDBName 19 | # username: YourDBUser 20 | # password: YourDBPassword 21 | db: 22 | host: rm-uf6pc9n1jzi2478l4eo.mysql.rds.aliyuncs.com 23 | port: 3306 24 | name: portal_db 25 | username: portal_test 26 | password: portal-Go 27 | 28 | 29 | # -Ddb.host=rm-uf6pc9n1jzi2478l4eo.mysql.rds.aliyuncs.com \ 30 | # -Ddb.port=3306 \ 31 | # -Ddb.name=portal_db \ 32 | # -Ddb.username=portal_test \ 33 | # -Ddb.password=portal-Go \ 34 | 35 | 36 | # Encryptor 37 | encryption: 38 | root-key: portalmanagement 39 | 40 | springdoc: 41 | api-docs: 42 | enabled: true 43 | path: /portal/v3/api-docs 44 | swagger-ui: 45 | path: /portal/swagger-ui.html 46 | disable-swagger-default-url: true 47 | packages-to-scan: com.alibaba.apiopenplatform.controller 48 | 49 | jwt: 50 | secret: YourJWTSecret 51 | expiration: 2h 52 | 53 | logging: 54 | pattern: 55 | console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n" 56 | level: 57 | root: INFO 58 | com.alibaba.apiopenplatform: INFO ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/result/DeveloperResult.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.result; 21 | 22 | import com.alibaba.apiopenplatform.dto.converter.OutputConverter; 23 | import com.alibaba.apiopenplatform.entity.Developer; 24 | import lombok.Data; 25 | 26 | import java.time.LocalDateTime; 27 | 28 | @Data 29 | public class DeveloperResult implements OutputConverter<DeveloperResult, Developer> { 30 | 31 | private String developerId; 32 | 33 | private String portalId; 34 | 35 | private String username; 36 | 37 | private String status; 38 | 39 | private String avatarUrl; 40 | 41 | private LocalDateTime createAt; 42 | } 43 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/gateway/GatewayConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.gateway; 21 | 22 | import com.alibaba.apiopenplatform.entity.Gateway; 23 | import com.alibaba.apiopenplatform.support.enums.GatewayType; 24 | import lombok.Builder; 25 | import lombok.Data; 26 | 27 | @Data 28 | @Builder 29 | public class GatewayConfig { 30 | 31 | private GatewayType gatewayType; 32 | 33 | private APIGConfig apigConfig; 34 | 35 | private AdpAIGatewayConfig adpAIGatewayConfig; 36 | 37 | private HigressConfig higressConfig; 38 | 39 | /** 40 | * 网关实体引用,用于获取gatewayId等信息 41 | */ 42 | private Gateway gateway; 43 | } 44 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/result/ProductPublicationResult.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.result; 21 | 22 | import com.alibaba.apiopenplatform.dto.converter.OutputConverter; 23 | import com.alibaba.apiopenplatform.entity.ProductPublication; 24 | import lombok.Data; 25 | 26 | import java.time.LocalDateTime; 27 | 28 | @Data 29 | public class ProductPublicationResult implements OutputConverter<ProductPublicationResult, ProductPublication> { 30 | 31 | private String portalId; 32 | 33 | private String portalName; 34 | 35 | private Boolean autoApproveSubscriptions = false; 36 | 37 | private LocalDateTime createAt; 38 | } 39 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/repository/NacosInstanceRepository.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.repository; 21 | 22 | import com.alibaba.apiopenplatform.entity.NacosInstance; 23 | import org.springframework.data.domain.Page; 24 | import org.springframework.data.domain.Pageable; 25 | import org.springframework.stereotype.Repository; 26 | 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | @Repository 31 | public interface NacosInstanceRepository extends BaseRepository<NacosInstance, Long> { 32 | 33 | Optional<NacosInstance> findByNacosId(String nacosId); 34 | 35 | Optional<NacosInstance> findByNacosName(String nacosName); 36 | } ``` -------------------------------------------------------------------------------- /portal-bootstrap/src/main/java/com/alibaba/apiopenplatform/config/SwaggerConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.config; 21 | 22 | import io.swagger.v3.oas.models.OpenAPI; 23 | import io.swagger.v3.oas.models.info.Info; 24 | import org.springframework.context.annotation.Bean; 25 | import org.springframework.context.annotation.Configuration; 26 | 27 | @Configuration 28 | public class SwaggerConfig { 29 | @Bean 30 | public OpenAPI openAPI() { 31 | return new OpenAPI() 32 | .info(new Info() 33 | .title("开放平台 API") 34 | .version("1.0.0") 35 | .description("API 文档描述")); 36 | } 37 | } 38 | ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/entity/ProductPublication.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.entity; 21 | 22 | import lombok.Data; 23 | import lombok.EqualsAndHashCode; 24 | 25 | import javax.persistence.*; 26 | 27 | @EqualsAndHashCode(callSuper = true) 28 | @Entity 29 | @Table(name = "publication") 30 | @Data 31 | public class ProductPublication extends BaseEntity { 32 | @Id 33 | @GeneratedValue(strategy = GenerationType.IDENTITY) 34 | private Long id; 35 | 36 | @Column(name = "portal_id", length = 64, nullable = false) 37 | private String portalId; 38 | 39 | @Column(name = "product_id", length = 64, nullable = false) 40 | private String productId; 41 | } 42 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/result/AdpMcpServerListResult.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.result; 21 | 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | import lombok.Data; 24 | 25 | import java.util.List; 26 | 27 | @Data 28 | public class AdpMcpServerListResult { 29 | 30 | private Integer code; 31 | 32 | private String message; 33 | 34 | private String msg; 35 | 36 | private AdpMcpServerListData data; 37 | 38 | @Data 39 | public static class AdpMcpServerListData { 40 | private List<AdpMCPServerResult> records; 41 | private Integer total; 42 | private Integer size; 43 | private Integer current; 44 | } 45 | } 46 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/core/exception/BusinessException.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.core.exception; 21 | 22 | import lombok.Getter; 23 | import org.springframework.http.HttpStatus; 24 | 25 | @Getter 26 | public class BusinessException extends RuntimeException { 27 | private final HttpStatus status; 28 | private final String code; 29 | private final String message; 30 | 31 | public BusinessException(ErrorCode errorCode, Object... args) { 32 | super(errorCode.getMessage(args)); 33 | this.status = errorCode.getStatus(); 34 | this.code = errorCode.name(); 35 | this.message = errorCode.getMessage(args); 36 | } 37 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/consumer/ApiKeyConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.consumer; 21 | 22 | import com.alibaba.apiopenplatform.support.enums.CredentialMode; 23 | import lombok.Data; 24 | 25 | import java.util.List; 26 | 27 | @Data 28 | public class ApiKeyConfig { 29 | 30 | private List<ApiKeyCredential> credentials; 31 | 32 | /** 33 | * apikey的位置 34 | */ 35 | private String source = "Default"; 36 | 37 | /** 38 | * apikey参数名称 39 | */ 40 | private String key = "Authorization"; 41 | 42 | @Data 43 | public static class ApiKeyCredential { 44 | 45 | private String apiKey; 46 | 47 | private CredentialMode mode = CredentialMode.SYSTEM; 48 | } 49 | } ``` -------------------------------------------------------------------------------- /portal-dal/src/main/java/com/alibaba/apiopenplatform/support/portal/PortalSettingConfig.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.support.portal; 21 | 22 | import lombok.Data; 23 | 24 | import java.util.List; 25 | 26 | @Data 27 | public class PortalSettingConfig { 28 | 29 | /** 30 | * 内置的账号密码认证,默认开启 31 | */ 32 | private Boolean builtinAuthEnabled = true; 33 | 34 | /** 35 | * OIDC配置 36 | */ 37 | private List<OidcConfig> oidcConfigs; 38 | 39 | /** 40 | * 开启自动审批开发者注册 41 | */ 42 | private Boolean autoApproveDevelopers = false; 43 | 44 | /** 45 | * 开启自动审批订阅申请 46 | */ 47 | private Boolean autoApproveSubscriptions = true; 48 | 49 | /** 50 | * OAuth2配置 51 | */ 52 | private List<OAuth2Config> oauth2Configs; 53 | } 54 | ``` -------------------------------------------------------------------------------- /portal-server/src/main/java/com/alibaba/apiopenplatform/dto/params/admin/AdminCreateParam.java: -------------------------------------------------------------------------------- ```java 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package com.alibaba.apiopenplatform.dto.params.admin; 21 | 22 | import com.alibaba.apiopenplatform.dto.converter.InputConverter; 23 | import com.alibaba.apiopenplatform.entity.Administrator; 24 | import lombok.Data; 25 | import lombok.NoArgsConstructor; 26 | import javax.validation.constraints.NotBlank; 27 | import javax.validation.constraints.Size; 28 | 29 | /** 30 | * 管理员注册/创建参数DTO 31 | * 32 | */ 33 | @Data 34 | public class AdminCreateParam implements InputConverter<Administrator> { 35 | 36 | @NotBlank(message = "用户名不能为空") 37 | private String username; 38 | 39 | @NotBlank(message = "密码不能为空") 40 | private String password; 41 | } ```