diff --git a/docker/.env.example b/docker/.env.example index da50af93c..0e8bde012 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -31,11 +31,6 @@ WREN_BOOTSTRAP_VERSION=0.1.4 AI_SERVICE_ENABLE_TIMER= AI_SERVICE_LOGGING_LEVEL=INFO -# SQL Protocol -PG_USERNAME=wren-user-placeholder -# PG_PASSWORD will be replaced with random string by launcher -PG_PASSWORD=wren-pg-password-placeholder - # user id (uuid v4) USER_UUID= diff --git a/docker/bootstrap/init.sh b/docker/bootstrap/init.sh index b03c2b7ad..7c882ed9d 100644 --- a/docker/bootstrap/init.sh +++ b/docker/bootstrap/init.sh @@ -1,18 +1,6 @@ #!/bin/sh # declare a variable from the environment variable: DATA_PATH data_path=${DATA_PATH:-"./"} -# get default password from environment variable, if not exists, then throw error -if [ -z "$PG_PASSWORD" ]; then - echo "PG_PASSWORD is not set" - exit 1 -fi -pg_password=$PG_PASSWORD -# get default username from environment variable, if not exists, then throw error -if [ -z "$PG_USERNAME" ]; then - echo "PG_USERNAME is not set" - exit 1 -fi -pg_username=$PG_USERNAME # touch a empty config.properties if not exists # put a content into config.properties if not exists @@ -40,11 +28,3 @@ if [ ! -f ${data_path}/mdl/sample.json ]; then echo "init mdl/sample.json" echo "{\"catalog\": \"test_catalog\", \"schema\": \"test_schema\", \"models\": []}" > ${data_path}/mdl/sample.json fi - -# put a accounts file in data_path if not exists -# accounts is a file contains the authentication information -# the format is like: `username password` per line -if [ ! -f ${data_path}/accounts ]; then - echo "init accounts file" - echo "${pg_username} ${pg_password}" > ${data_path}/accounts -fi diff --git a/docker/docker-compose-dev.yaml b/docker/docker-compose-dev.yaml index 0086dcd14..a1e87c1cc 100644 --- a/docker/docker-compose-dev.yaml +++ b/docker/docker-compose-dev.yaml @@ -14,8 +14,6 @@ services: platform: ${PLATFORM} environment: DATA_PATH: /app/data - PG_USERNAME: ${PG_USERNAME} - PG_PASSWORD: ${PG_PASSWORD} volumes: - data:/app/data command: /bin/sh /app/init.sh diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 35f2b2eaf..f174644a7 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -14,8 +14,6 @@ services: platform: ${PLATFORM} environment: DATA_PATH: /app/data - PG_USERNAME: ${PG_USERNAME} - PG_PASSWORD: ${PG_PASSWORD} volumes: - data:/app/data command: /bin/sh /app/init.sh @@ -97,8 +95,6 @@ services: EMBEDDING_MODEL: ${EMBEDDING_MODEL} EMBEDDING_MODEL_DIMENSION: ${EMBEDDING_MODEL_DIMENSION} GENERATION_MODEL: ${GENERATION_MODEL} - PG_USERNAME: ${PG_USERNAME} - PG_PASSWORD: ${PG_PASSWORD} # telemetry WREN_ENGINE_PORT: ${WREN_ENGINE_PORT} WREN_AI_SERVICE_VERSION: ${WREN_AI_SERVICE_VERSION} diff --git a/wren-ai-service/tools/dev/.env.example b/wren-ai-service/tools/dev/.env.example index dac8fea55..56568537b 100644 --- a/wren-ai-service/tools/dev/.env.example +++ b/wren-ai-service/tools/dev/.env.example @@ -17,10 +17,6 @@ WREN_UI_VERSION=latest IBIS_SERVER_VERSION=latest WREN_BOOTSTRAP_VERSION=latest -# SQL Protocol -PG_USERNAME=wren-user-placeholder -# PG_PASSWORD will be replaced with random string by launcher -PG_PASSWORD=wren-pg-password-placeholder LAUNCH_CLI_PATH=./launch-cli.sh # user id (uuid v4) diff --git a/wren-launcher/go.mod b/wren-launcher/go.mod index 5b5dccf6e..f3b4e9ea2 100644 --- a/wren-launcher/go.mod +++ b/wren-launcher/go.mod @@ -187,7 +187,6 @@ require ( github.com/opencontainers/image-spec v1.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pterm/pterm v0.12.79 - github.com/sethvargo/go-password v0.2.0 github.com/sirupsen/logrus v1.9.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect diff --git a/wren-launcher/go.sum b/wren-launcher/go.sum index 42a05f9dd..378041498 100644 --- a/wren-launcher/go.sum +++ b/wren-launcher/go.sum @@ -484,8 +484,6 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b h1:h+3JX2VoWTFuyQEo87pStk/a99dzIO1mM9KxIyLPGTU= github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b/go.mod h1:/yeG0My1xr/u+HZrFQ1tOQQQQrOawfyMUH13ai5brBc= -github.com/sethvargo/go-password v0.2.0 h1:BTDl4CC/gjf/axHMaDQtw507ogrXLci6XRiLc7i/UHI= -github.com/sethvargo/go-password v0.2.0/go.mod h1:Ym4Mr9JXLBycr02MFuVQ/0JHidNetSgbzutTr3zsYXE= github.com/shibumi/go-pathspec v1.3.0 h1:QUyMZhFo0Md5B8zV8x2tesohbb5kfbpTi9rBnKh5dkI= github.com/shibumi/go-pathspec v1.3.0/go.mod h1:Xutfslp817l2I1cZvgcfeMQJG5QnU2lh5tVaaMCl3jE= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= diff --git a/wren-launcher/utils/docker.go b/wren-launcher/utils/docker.go index 896b86857..c83074436 100644 --- a/wren-launcher/utils/docker.go +++ b/wren-launcher/utils/docker.go @@ -18,8 +18,6 @@ import ( "github.com/docker/docker/api/types/container" "github.com/google/uuid" "github.com/pterm/pterm" - - "github.com/sethvargo/go-password/password" ) const ( @@ -28,12 +26,9 @@ const ( DOCKER_COMPOSE_YAML_URL string = "https://raw.githubusercontent.com/Canner/WrenAI/" + WREN_PRODUCT_VERSION + "/docker/docker-compose.yaml" DOCKER_COMPOSE_LLM_YAML_URL string = "https://raw.githubusercontent.com/Canner/WrenAI/" + WREN_PRODUCT_VERSION + "/docker/docker-compose.llm.yaml" DOCKER_COMPOSE_ENV_URL string = "https://raw.githubusercontent.com/Canner/WrenAI/" + WREN_PRODUCT_VERSION + "/docker/.env.example" - - // pg user - PG_USERNAME string = "wren-user" ) -func replaceEnvFileContent(content string, projectDir string, openaiApiKey string, openAIGenerationModel string, hostPort int, aiPort int, pg_password string, userUUID string, telemetryEnabled bool) string { +func replaceEnvFileContent(content string, projectDir string, openaiApiKey string, openAIGenerationModel string, hostPort int, aiPort int, userUUID string, telemetryEnabled bool) string { // rplace PROJECT_DIR reg := regexp.MustCompile(`PROJECT_DIR=(.*)`) str := reg.ReplaceAllString(content, "PROJECT_DIR="+projectDir) @@ -65,14 +60,6 @@ func replaceEnvFileContent(content string, projectDir string, openaiApiKey strin reg = regexp.MustCompile(`AI_SERVICE_FORWARD_PORT=(.*)`) str = reg.ReplaceAllString(str, "AI_SERVICE_FORWARD_PORT="+fmt.Sprintf("%d", aiPort)) - // replace PG_PASSWORD - reg = regexp.MustCompile(`PG_PASSWORD=(.*)`) - str = reg.ReplaceAllString(str, "PG_PASSWORD="+pg_password) - - // replace PG_USERNAME - reg = regexp.MustCompile(`PG_USERNAME=(.*)`) - str = reg.ReplaceAllString(str, "PG_USERNAME="+PG_USERNAME) - // replace TELEMETRY_ENABLED reg = regexp.MustCompile(`TELEMETRY_ENABLED=(.*)`) str = reg.ReplaceAllString(str, "TELEMETRY_ENABLED="+fmt.Sprintf("%t", telemetryEnabled)) @@ -101,35 +88,6 @@ func downloadFile(filepath string, url string) error { return err } -func getPGPassword(w WrenRC) (string, error) { - pgPwdKey := "pg_password" - // get the password from rc file if exists - // if not exists, generate a new password - pgPwd, err := w.Read(pgPwdKey) - if err != nil { - return "", err - } - - if pgPwd == "" { - genPwd, err := password.Generate(10, 2, 0, false, false) - if err != nil { - return "", err - } - - // set the password to rc file - err = w.Set(pgPwdKey, genPwd, false) - if err != nil { - return "", err - } - - // return the generated password - return genPwd, nil - } - - // return the password from rc file - return pgPwd, nil -} - func CheckDockerDaemonRunning() (bool, error) { ctx := context.Background() dockerCli, err := command.NewDockerCli() @@ -182,11 +140,6 @@ func PrepareDockerFiles(openaiApiKey string, openaiGenerationModel string, hostP return err } - pg_pwd, err := getPGPassword(WrenRC{projectDir}) - if err != nil { - return err - } - userUUID, err := prepareUserUUID(projectDir) if err != nil { return err @@ -214,7 +167,6 @@ func PrepareDockerFiles(openaiApiKey string, openaiGenerationModel string, hostP openaiGenerationModel, hostPort, aiPort, - pg_pwd, userUUID, telemetryEnabled, ) diff --git a/wren-ui/src/apollo/client/graphql/__types__.ts b/wren-ui/src/apollo/client/graphql/__types__.ts index 9310c0d43..ec70f179c 100644 --- a/wren-ui/src/apollo/client/graphql/__types__.ts +++ b/wren-ui/src/apollo/client/graphql/__types__.ts @@ -62,15 +62,6 @@ export type CompactTable = { properties?: Maybe; }; -export type ConnectionInfo = { - __typename?: 'ConnectionInfo'; - database: Scalars['String']; - password?: Maybe; - port: Scalars['Int']; - schema: Scalars['String']; - username?: Maybe; -}; - export type CreateCalculatedFieldInput = { expression: ExpressionName; lineage: Array; @@ -642,7 +633,6 @@ export type Query = { __typename?: 'Query'; askingTask: AskingTask; autoGenerateRelation: Array; - connectionInfo: ConnectionInfo; diagram: Diagram; getMDL: GetMdlResult; listDataSourceTables: Array; diff --git a/wren-ui/src/apollo/client/graphql/deploy.generated.ts b/wren-ui/src/apollo/client/graphql/deploy.generated.ts index 5c62afbcc..83d2456a1 100644 --- a/wren-ui/src/apollo/client/graphql/deploy.generated.ts +++ b/wren-ui/src/apollo/client/graphql/deploy.generated.ts @@ -13,11 +13,6 @@ export type DeployStatusQueryVariables = Types.Exact<{ [key: string]: never; }>; export type DeployStatusQuery = { __typename?: 'Query', modelSync: { __typename?: 'ModelSyncResponse', status: Types.SyncStatus } }; -export type ConnectionInfoQueryVariables = Types.Exact<{ [key: string]: never; }>; - - -export type ConnectionInfoQuery = { __typename?: 'Query', connectionInfo: { __typename?: 'ConnectionInfo', database: string, schema: string, port: number, username?: string | null, password?: string | null } }; - export const DeployDocument = gql` mutation Deploy { @@ -82,42 +77,4 @@ export function useDeployStatusLazyQuery(baseOptions?: Apollo.LazyQueryHookOptio } export type DeployStatusQueryHookResult = ReturnType; export type DeployStatusLazyQueryHookResult = ReturnType; -export type DeployStatusQueryResult = Apollo.QueryResult; -export const ConnectionInfoDocument = gql` - query ConnectionInfo { - connectionInfo { - database - schema - port - username - password - } -} - `; - -/** - * __useConnectionInfoQuery__ - * - * To run a query within a React component, call `useConnectionInfoQuery` and pass it any options that fit your needs. - * When your component renders, `useConnectionInfoQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useConnectionInfoQuery({ - * variables: { - * }, - * }); - */ -export function useConnectionInfoQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ConnectionInfoDocument, options); - } -export function useConnectionInfoLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ConnectionInfoDocument, options); - } -export type ConnectionInfoQueryHookResult = ReturnType; -export type ConnectionInfoLazyQueryHookResult = ReturnType; -export type ConnectionInfoQueryResult = Apollo.QueryResult; \ No newline at end of file +export type DeployStatusQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/wren-ui/src/apollo/client/graphql/deploy.ts b/wren-ui/src/apollo/client/graphql/deploy.ts index 2b428c8ac..75fe308d2 100644 --- a/wren-ui/src/apollo/client/graphql/deploy.ts +++ b/wren-ui/src/apollo/client/graphql/deploy.ts @@ -13,15 +13,3 @@ export const GET_DEPLOY_STATUS = gql` } } `; - -export const CONNECTION_INFO = gql` - query ConnectionInfo { - connectionInfo { - database - schema - port - username - password - } - } -`; diff --git a/wren-ui/src/apollo/server/config.ts b/wren-ui/src/apollo/server/config.ts index 68492a01f..38ee277e8 100644 --- a/wren-ui/src/apollo/server/config.ts +++ b/wren-ui/src/apollo/server/config.ts @@ -28,10 +28,6 @@ export interface IConfig { encryptionPassword: string; encryptionSalt: string; - // username and password - pgUsername?: string; - pgPassword?: string; - // telemetry telemetryEnabled?: boolean; posthogApiKey?: string; @@ -111,10 +107,6 @@ const config = { encryptionPassword: process.env.ENCRYPTION_PASSWORD, encryptionSalt: process.env.ENCRYPTION_SALT, - // username and password - pgUsername: process.env.PG_USERNAME, - pgPassword: process.env.PG_PASSWORD, - // telemetry telemetryEnabled: process.env.TELEMETRY_ENABLED && diff --git a/wren-ui/src/apollo/server/resolvers.ts b/wren-ui/src/apollo/server/resolvers.ts index b5b20d278..743941557 100644 --- a/wren-ui/src/apollo/server/resolvers.ts +++ b/wren-ui/src/apollo/server/resolvers.ts @@ -3,13 +3,11 @@ import { ProjectResolver } from './resolvers/projectResolver'; import { ModelResolver } from './resolvers/modelResolver'; import { AskingResolver } from './resolvers/askingResolver'; import { DiagramResolver } from './resolvers/diagramResolver'; -import { ConnectionInfoResolver } from './resolvers/connectionInfoResolver'; const projectResolver = new ProjectResolver(); const modelResolver = new ModelResolver(); const askingResolver = new AskingResolver(); const diagramResolver = new DiagramResolver(); -const connectionInfoResolver = new ConnectionInfoResolver(); const resolvers = { JSON: GraphQLJSON, @@ -37,9 +35,6 @@ const resolvers = { listViews: modelResolver.listViews, view: modelResolver.getView, - // Connection Info - connectionInfo: connectionInfoResolver.connectionInfo, - // Settings settings: projectResolver.getSettings, getMDL: modelResolver.getMDL, diff --git a/wren-ui/src/apollo/server/resolvers/connectionInfoResolver.ts b/wren-ui/src/apollo/server/resolvers/connectionInfoResolver.ts deleted file mode 100644 index 1cbec2443..000000000 --- a/wren-ui/src/apollo/server/resolvers/connectionInfoResolver.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { IContext } from '../types'; -import { getConfig } from '../config'; - -const config = getConfig(); - -export interface ConnectionInfo { - port: number; - database: string; - schema: string; - username: string; - password: string; -} - -export class ConnectionInfoResolver { - constructor() { - this.connectionInfo = this.connectionInfo.bind(this); - } - - public async connectionInfo( - _root: any, - _args: any, - ctx: IContext, - ): Promise { - const project = await ctx.projectService.getCurrentProject(); - - return { - port: 7432, - database: project.catalog, - schema: project.schema, - username: config.pgUsername, - password: config.pgPassword, - }; - } -} diff --git a/wren-ui/src/apollo/server/schema.ts b/wren-ui/src/apollo/server/schema.ts index 193f2c777..f42fc5f46 100644 --- a/wren-ui/src/apollo/server/schema.ts +++ b/wren-ui/src/apollo/server/schema.ts @@ -588,15 +588,6 @@ export const typeDefs = gql` questions: [SuggestedQuestion]! } - # SQL protocol connection information - type ConnectionInfo { - port: Int! - database: String! - schema: String! - username: String - password: String - } - # Settings input UpdateDataSourceInput { properties: JSON! @@ -682,9 +673,6 @@ export const typeDefs = gql` threadResponse(responseId: Int!): ThreadResponse! nativeSql(responseId: Int!): String! - # Connection Info - connectionInfo: ConnectionInfo! - # Settings settings: Settings! diff --git a/wren-ui/src/components/SharePopover.tsx b/wren-ui/src/components/SharePopover.tsx deleted file mode 100644 index e37ed3895..000000000 --- a/wren-ui/src/components/SharePopover.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { Button, Input, Popover, Space, Typography } from 'antd'; -import styled from 'styled-components'; -import { ShareIcon } from '@/utils/icons'; -import { useConnectionInfoQuery } from '@/apollo/client/graphql/deploy.generated'; - -const { Title, Text } = Typography; - -const Content = styled.div` - width: 423px; - padding: 4px 0; - .adm-share-title { - font-size: 14px; - margin-bottom: 16px; - } - .adm-share-subtitle { - margin-bottom: 8px; - } -`; - -const StyledInput = styled(Input)` - display: block; - color: var(--gray-10); - .ant-input { - background-color: var(--gray-4); - } - - .ant-typography-copy { - color: var(--gray-8); - } - - .ant-typography-copy-success:focus { - color: var(--green-6); - } -`; - -export default function SharePopover() { - const { data } = useConnectionInfoQuery(); - const connections = data?.connectionInfo; - - const sources = [ - { title: 'Database', type: 'text', value: connections?.database }, - { title: 'Port', type: 'text', value: String(connections?.port || '') }, - { title: 'Username', type: 'text', value: connections?.username }, - { title: 'Password', type: 'password', value: connections?.password }, - ]; - - const content = ( - - - <Space> - <ShareIcon /> - Share - </Space> - -
- You can connect applications via our protocol. -
- - - {sources.map(({ title, type, value }) => ( -
-
{title}
- - } - /> -
- ))} -
-
- ); - - return ( - - - - ); -} diff --git a/wren-ui/src/styles/components/button.less b/wren-ui/src/styles/components/button.less index 3c5b386d0..d460576ae 100644 --- a/wren-ui/src/styles/components/button.less +++ b/wren-ui/src/styles/components/button.less @@ -1,20 +1,3 @@ -.adm-btn { - &-gray { - .button-color(@gray-9; @gray-6; @gray-6); - - &:hover, - &:focus { - .button-color(@gray-9; @gray-5; @gray-5); - } - - &:active { - .button-color(@gray-9; @gray-7; @gray-7); - } - - .button-disabled(); - } -} - .adm-btn-no-style { cursor: pointer; background: transparent;