mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-16 08:03:15 +02:00
Initial login flow
This commit is contained in:
@ -13,6 +13,16 @@ APP_PORT = 8080
|
|||||||
BLURB_LENGTH = 200 # Characters. Blurbs will be truncated at the first punctuation after this many characters.
|
BLURB_LENGTH = 200 # Characters. Blurbs will be truncated at the first punctuation after this many characters.
|
||||||
|
|
||||||
|
|
||||||
|
#####
|
||||||
|
# Web Configs
|
||||||
|
#####
|
||||||
|
# WEB_DOMAIN is used to set the redirect_uri when doing OAuth with Google
|
||||||
|
# TODO: investigate if this can be done cleaner by overwriting the redirect_uri
|
||||||
|
# on the frontend and just sending a dummy value (or completely generating the URL)
|
||||||
|
# on the frontend
|
||||||
|
WEB_DOMAIN = os.environ.get("WEB_DOMAIN", "http://localhost:3000")
|
||||||
|
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# Vector DB Configs
|
# Vector DB Configs
|
||||||
#####
|
#####
|
||||||
|
@ -9,6 +9,7 @@ from danswer.auth.users import fastapi_users
|
|||||||
from danswer.auth.users import google_oauth_client
|
from danswer.auth.users import google_oauth_client
|
||||||
from danswer.configs.app_configs import APP_HOST
|
from danswer.configs.app_configs import APP_HOST
|
||||||
from danswer.configs.app_configs import APP_PORT
|
from danswer.configs.app_configs import APP_PORT
|
||||||
|
from danswer.configs.app_configs import WEB_DOMAIN
|
||||||
from danswer.server.admin import router as admin_router
|
from danswer.server.admin import router as admin_router
|
||||||
from danswer.server.event_loading import router as event_processing_router
|
from danswer.server.event_loading import router as event_processing_router
|
||||||
from danswer.server.search_backend import router as backend_router
|
from danswer.server.search_backend import router as backend_router
|
||||||
@ -69,7 +70,9 @@ def get_application() -> FastAPI:
|
|||||||
SECRET,
|
SECRET,
|
||||||
associate_by_email=True,
|
associate_by_email=True,
|
||||||
is_verified_by_default=True,
|
is_verified_by_default=True,
|
||||||
redirect_url="http://localhost:8080/test", # TODO DAN-39 set this to frontend redirect
|
# points the user back to the login page, where we will call the
|
||||||
|
# /auth/google/callback endpoint + redirect them to the main app
|
||||||
|
redirect_url=f"{WEB_DOMAIN}/auth/google/callback",
|
||||||
),
|
),
|
||||||
prefix="/auth/google",
|
prefix="/auth/google",
|
||||||
tags=["auth"],
|
tags=["auth"],
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from danswer.configs.constants import DocumentSource
|
from danswer.configs.constants import DocumentSource
|
||||||
from danswer.connectors.models import ConnectorDescriptor
|
|
||||||
from danswer.connectors.models import InputType
|
from danswer.connectors.models import InputType
|
||||||
from danswer.connectors.slack.config import get_slack_config
|
from danswer.connectors.slack.config import get_slack_config
|
||||||
from danswer.connectors.slack.config import SlackConfig
|
from danswer.connectors.slack.config import SlackConfig
|
||||||
|
@ -2,7 +2,10 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next
|
|||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
First, run the development server:
|
Install node / npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
|
||||||
|
Install all dependencies: `npm i`
|
||||||
|
|
||||||
|
Then, run the development server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
npm run dev
|
||||||
@ -13,20 +16,3 @@ pnpm dev
|
|||||||
```
|
```
|
||||||
|
|
||||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||||
|
|
||||||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
|
|
||||||
|
|
||||||
## Learn More
|
|
||||||
|
|
||||||
To learn more about Next.js, take a look at the following resources:
|
|
||||||
|
|
||||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
||||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
||||||
|
|
||||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
|
||||||
|
|
||||||
## Deploy on Vercel
|
|
||||||
|
|
||||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
||||||
|
|
||||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
|
||||||
|
199
web/package-lock.json
generated
199
web/package-lock.json
generated
@ -16,10 +16,10 @@
|
|||||||
"eslint": "8.37.0",
|
"eslint": "8.37.0",
|
||||||
"eslint-config-next": "13.2.4",
|
"eslint-config-next": "13.2.4",
|
||||||
"formik": "^2.2.9",
|
"formik": "^2.2.9",
|
||||||
"next": "13.2.4",
|
"next": "^13.2.4",
|
||||||
"postcss": "^8.4.23",
|
"postcss": "^8.4.23",
|
||||||
"react": "18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"swr": "^2.1.5",
|
"swr": "^2.1.5",
|
||||||
"tailwindcss": "^3.3.1",
|
"tailwindcss": "^3.3.1",
|
||||||
"typescript": "5.0.3",
|
"typescript": "5.0.3",
|
||||||
@ -168,9 +168,9 @@
|
|||||||
"integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw=="
|
"integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw=="
|
||||||
},
|
},
|
||||||
"node_modules/@next/env": {
|
"node_modules/@next/env": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.1.tgz",
|
||||||
"integrity": "sha512-+Mq3TtpkeeKFZanPturjcXt+KHfKYnLlX6jMLyCrmpq6OOs4i1GqBOAauSkii9QeKCMTYzGppar21JU57b/GEA=="
|
"integrity": "sha512-eD6WCBMFjLFooLM19SIhSkWBHtaFrZFfg2Cxnyl3vS3DAdFRfnx5TY2RxlkuKXdIRCC0ySbtK9JXXt8qLCqzZg=="
|
||||||
},
|
},
|
||||||
"node_modules/@next/eslint-plugin-next": {
|
"node_modules/@next/eslint-plugin-next": {
|
||||||
"version": "13.2.4",
|
"version": "13.2.4",
|
||||||
@ -180,40 +180,10 @@
|
|||||||
"glob": "7.1.7"
|
"glob": "7.1.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-android-arm-eabi": {
|
|
||||||
"version": "13.2.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.2.4.tgz",
|
|
||||||
"integrity": "sha512-DWlalTSkLjDU11MY11jg17O1gGQzpRccM9Oes2yTqj2DpHndajrXHGxj9HGtJ+idq2k7ImUdJVWS2h2l/EDJOw==",
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"android"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@next/swc-android-arm64": {
|
|
||||||
"version": "13.2.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-13.2.4.tgz",
|
|
||||||
"integrity": "sha512-sRavmUImUCf332Gy+PjIfLkMhiRX1Ez4SI+3vFDRs1N5eXp+uNzjFUK/oLMMOzk6KFSkbiK/3Wt8+dHQR/flNg==",
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"android"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@next/swc-darwin-arm64": {
|
"node_modules/@next/swc-darwin-arm64": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.1.tgz",
|
||||||
"integrity": "sha512-S6vBl+OrInP47TM3LlYx65betocKUUlTZDDKzTiRDbsRESeyIkBtZ6Qi5uT2zQs4imqllJznVjFd1bXLx3Aa6A==",
|
"integrity": "sha512-eF8ARHtYfnoYtDa6xFHriUKA/Mfj/cCbmKb3NofeKhMccs65G6/loZ15a6wYCCx4rPAd6x4t1WmVYtri7EdeBg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -226,9 +196,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-darwin-x64": {
|
"node_modules/@next/swc-darwin-x64": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.1.tgz",
|
||||||
"integrity": "sha512-a6LBuoYGcFOPGd4o8TPo7wmv5FnMr+Prz+vYHopEDuhDoMSHOnC+v+Ab4D7F0NMZkvQjEJQdJS3rqgFhlZmKlw==",
|
"integrity": "sha512-7cmDgF9tGWTgn5Gw+vP17miJbH4wcraMHDCOHTYWkO/VeKT73dUWG23TNRLfgtCNSPgH4V5B4uLHoZTanx9bAw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -240,40 +210,10 @@
|
|||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-freebsd-x64": {
|
|
||||||
"version": "13.2.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.2.4.tgz",
|
|
||||||
"integrity": "sha512-kkbzKVZGPaXRBPisoAQkh3xh22r+TD+5HwoC5bOkALraJ0dsOQgSMAvzMXKsN3tMzJUPS0tjtRf1cTzrQ0I5vQ==",
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"freebsd"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@next/swc-linux-arm-gnueabihf": {
|
|
||||||
"version": "13.2.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.2.4.tgz",
|
|
||||||
"integrity": "sha512-7qA1++UY0fjprqtjBZaOA6cas/7GekpjVsZn/0uHvquuITFCdKGFCsKNBx3S0Rpxmx6WYo0GcmhNRM9ru08BGg==",
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@next/swc-linux-arm64-gnu": {
|
"node_modules/@next/swc-linux-arm64-gnu": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.1.tgz",
|
||||||
"integrity": "sha512-xzYZdAeq883MwXgcwc72hqo/F/dwUxCukpDOkx/j1HTq/J0wJthMGjinN9wH5bPR98Mfeh1MZJ91WWPnZOedOg==",
|
"integrity": "sha512-qwJqmCri2ie8aTtE5gjTSr8S6O8B67KCYgVZhv9gKH44yvc/zXbAY8u23QGULsYOyh1islWE5sWfQNLOj9iryg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -286,9 +226,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-arm64-musl": {
|
"node_modules/@next/swc-linux-arm64-musl": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.1.tgz",
|
||||||
"integrity": "sha512-8rXr3WfmqSiYkb71qzuDP6I6R2T2tpkmf83elDN8z783N9nvTJf2E7eLx86wu2OJCi4T05nuxCsh4IOU3LQ5xw==",
|
"integrity": "sha512-qcC54tWNGDv/VVIFkazxhqH1Bnagjfs4enzELVRlUOoJPD2BGJTPI7z08pQPbbgxLtRiu8gl2mXvpB8WlOkMeA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -301,9 +241,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-x64-gnu": {
|
"node_modules/@next/swc-linux-x64-gnu": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.1.tgz",
|
||||||
"integrity": "sha512-Ngxh51zGSlYJ4EfpKG4LI6WfquulNdtmHg1yuOYlaAr33KyPJp4HeN/tivBnAHcZkoNy0hh/SbwDyCnz5PFJQQ==",
|
"integrity": "sha512-9TeWFlpLsBosZ+tsm/rWBaMwt5It9tPH8m3nawZqFUUrZyGRfGcI67js774vtx0k3rL9qbyY6+3pw9BCVpaYUA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -316,9 +256,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-x64-musl": {
|
"node_modules/@next/swc-linux-x64-musl": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.1.tgz",
|
||||||
"integrity": "sha512-gOvwIYoSxd+j14LOcvJr+ekd9fwYT1RyMAHOp7znA10+l40wkFiMONPLWiZuHxfRk+Dy7YdNdDh3ImumvL6VwA==",
|
"integrity": "sha512-sNDGaWmSqTS4QRUzw61wl4mVPeSqNIr1OOjLlQTRuyInxMxtqImRqdvzDvFTlDfdeUMU/DZhWGYoHrXLlZXe6A==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -331,9 +271,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-arm64-msvc": {
|
"node_modules/@next/swc-win32-arm64-msvc": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.1.tgz",
|
||||||
"integrity": "sha512-q3NJzcfClgBm4HvdcnoEncmztxrA5GXqKeiZ/hADvC56pwNALt3ngDC6t6qr1YW9V/EPDxCYeaX4zYxHciW4Dw==",
|
"integrity": "sha512-+CXZC7u1iXdLRudecoUYbhbsXpglYv8KFYsFxKBPn7kg+bk7eJo738wAA4jXIl8grTF2mPdmO93JOQym+BlYGA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -346,9 +286,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-ia32-msvc": {
|
"node_modules/@next/swc-win32-ia32-msvc": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.1.tgz",
|
||||||
"integrity": "sha512-/eZ5ncmHUYtD2fc6EUmAIZlAJnVT2YmxDsKs1Ourx0ttTtvtma/WKlMV5NoUsyOez0f9ExLyOpeCoz5aj+MPXw==",
|
"integrity": "sha512-vIoXVVc7UYO68VwVMDKwJC2+HqAZQtCYiVlApyKEeIPIQpz2gpufzGxk1z3/gwrJt/kJ5CDZjlhYDCzd3hdz+g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@ -361,9 +301,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-x64-msvc": {
|
"node_modules/@next/swc-win32-x64-msvc": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.1.tgz",
|
||||||
"integrity": "sha512-0MffFmyv7tBLlji01qc0IaPP/LVExzvj7/R5x1Jph1bTAIj4Vu81yFQWHHQAP6r4ff9Ukj1mBK6MDNVXm7Tcvw==",
|
"integrity": "sha512-n8V5ImLQZibKTu10UUdI3nIeTLkliEXe628qxqW9v8My3BAH2a7H0SaCqkV2OgqFnn8sG1wxKYw9/SNJ632kSA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -444,9 +384,9 @@
|
|||||||
"integrity": "sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg=="
|
"integrity": "sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg=="
|
||||||
},
|
},
|
||||||
"node_modules/@swc/helpers": {
|
"node_modules/@swc/helpers": {
|
||||||
"version": "0.4.14",
|
"version": "0.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.14.tgz",
|
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.1.tgz",
|
||||||
"integrity": "sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==",
|
"integrity": "sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
@ -884,6 +824,17 @@
|
|||||||
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
|
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/busboy": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
||||||
|
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
|
||||||
|
"dependencies": {
|
||||||
|
"streamsearch": "^1.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.16.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/call-bind": {
|
"node_modules/call-bind": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
|
||||||
@ -2755,39 +2706,37 @@
|
|||||||
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
|
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
|
||||||
},
|
},
|
||||||
"node_modules/next": {
|
"node_modules/next": {
|
||||||
"version": "13.2.4",
|
"version": "13.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/next/-/next-13.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/next/-/next-13.4.1.tgz",
|
||||||
"integrity": "sha512-g1I30317cThkEpvzfXujf0O4wtaQHtDCLhlivwlTJ885Ld+eOgcz7r3TGQzeU+cSRoNHtD8tsJgzxVdYojFssw==",
|
"integrity": "sha512-JBw2kAIyhKDpjhEWvNVoFeIzNp9xNxg8wrthDOtMctfn3EpqGCmW0FSviNyGgOSOSn6zDaX48pmvbdf6X2W9xA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@next/env": "13.2.4",
|
"@next/env": "13.4.1",
|
||||||
"@swc/helpers": "0.4.14",
|
"@swc/helpers": "0.5.1",
|
||||||
|
"busboy": "1.6.0",
|
||||||
"caniuse-lite": "^1.0.30001406",
|
"caniuse-lite": "^1.0.30001406",
|
||||||
"postcss": "8.4.14",
|
"postcss": "8.4.14",
|
||||||
"styled-jsx": "5.1.1"
|
"styled-jsx": "5.1.1",
|
||||||
|
"zod": "3.21.4"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"next": "dist/bin/next"
|
"next": "dist/bin/next"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.6.0"
|
"node": ">=16.8.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@next/swc-android-arm-eabi": "13.2.4",
|
"@next/swc-darwin-arm64": "13.4.1",
|
||||||
"@next/swc-android-arm64": "13.2.4",
|
"@next/swc-darwin-x64": "13.4.1",
|
||||||
"@next/swc-darwin-arm64": "13.2.4",
|
"@next/swc-linux-arm64-gnu": "13.4.1",
|
||||||
"@next/swc-darwin-x64": "13.2.4",
|
"@next/swc-linux-arm64-musl": "13.4.1",
|
||||||
"@next/swc-freebsd-x64": "13.2.4",
|
"@next/swc-linux-x64-gnu": "13.4.1",
|
||||||
"@next/swc-linux-arm-gnueabihf": "13.2.4",
|
"@next/swc-linux-x64-musl": "13.4.1",
|
||||||
"@next/swc-linux-arm64-gnu": "13.2.4",
|
"@next/swc-win32-arm64-msvc": "13.4.1",
|
||||||
"@next/swc-linux-arm64-musl": "13.2.4",
|
"@next/swc-win32-ia32-msvc": "13.4.1",
|
||||||
"@next/swc-linux-x64-gnu": "13.2.4",
|
"@next/swc-win32-x64-msvc": "13.4.1"
|
||||||
"@next/swc-linux-x64-musl": "13.2.4",
|
|
||||||
"@next/swc-win32-arm64-msvc": "13.2.4",
|
|
||||||
"@next/swc-win32-ia32-msvc": "13.2.4",
|
|
||||||
"@next/swc-win32-x64-msvc": "13.2.4"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@opentelemetry/api": "^1.4.0",
|
"@opentelemetry/api": "^1.1.0",
|
||||||
"fibers": ">= 3.1.0",
|
"fibers": ">= 3.1.0",
|
||||||
"node-sass": "^6.0.0 || ^7.0.0",
|
"node-sass": "^6.0.0 || ^7.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
@ -3515,6 +3464,14 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/streamsearch": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/string.prototype.matchall": {
|
"node_modules/string.prototype.matchall": {
|
||||||
"version": "4.0.8",
|
"version": "4.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz",
|
||||||
@ -4122,6 +4079,14 @@
|
|||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/zod": {
|
||||||
|
"version": "3.21.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz",
|
||||||
|
"integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
"eslint": "8.37.0",
|
"eslint": "8.37.0",
|
||||||
"eslint-config-next": "13.2.4",
|
"eslint-config-next": "13.2.4",
|
||||||
"formik": "^2.2.9",
|
"formik": "^2.2.9",
|
||||||
"next": "13.2.4",
|
"next": "^13.2.4",
|
||||||
"postcss": "^8.4.23",
|
"postcss": "^8.4.23",
|
||||||
"react": "18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"swr": "^2.1.5",
|
"swr": "^2.1.5",
|
||||||
"tailwindcss": "^3.3.1",
|
"tailwindcss": "^3.3.1",
|
||||||
"typescript": "5.0.3",
|
"typescript": "5.0.3",
|
||||||
|
7
web/src/app/auth/error/page.tsx
Normal file
7
web/src/app/auth/error/page.tsx
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
const Page = () => {
|
||||||
|
return (
|
||||||
|
<div>Unable to login, please try again and/or contact an administrator</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page;
|
20
web/src/app/auth/google/callback/route.ts
Normal file
20
web/src/app/auth/google/callback/route.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { buildUrl } from "@/lib/userSS";
|
||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export const GET = async (request: NextRequest) => {
|
||||||
|
// Wrapper around the FastAPI endpoint /auth/google/callback,
|
||||||
|
// which adds back a redirect to the main app.
|
||||||
|
const url = new URL(buildUrl("/auth/google/callback"));
|
||||||
|
url.search = request.nextUrl.search;
|
||||||
|
|
||||||
|
const response = await fetch(url.toString());
|
||||||
|
const setCookieHeader = response.headers.get("set-cookie");
|
||||||
|
|
||||||
|
if (!setCookieHeader) {
|
||||||
|
return NextResponse.redirect(new URL("/auth/error", request.url));
|
||||||
|
}
|
||||||
|
|
||||||
|
const redirectResponse = NextResponse.redirect(new URL("/", request.url));
|
||||||
|
redirectResponse.headers.set("set-cookie", setCookieHeader);
|
||||||
|
return redirectResponse;
|
||||||
|
};
|
44
web/src/app/auth/login/page.tsx
Normal file
44
web/src/app/auth/login/page.tsx
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { getGoogleOAuthUrlSS, getCurrentUserSS } from "@/lib/userSS";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
const Page = async () => {
|
||||||
|
const [currentUser, authorizationUrl] = await Promise.all([
|
||||||
|
getCurrentUserSS(),
|
||||||
|
getGoogleOAuthUrlSS(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// if user is already logged in, take them to the main app page
|
||||||
|
if (currentUser && currentUser.is_active && currentUser.is_verified) {
|
||||||
|
return redirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<div className="min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
||||||
|
<div className="max-w-md w-full space-y-8">
|
||||||
|
<div>
|
||||||
|
<h2 className="mt-6 text-center text-3xl font-extrabold text-gray-200">
|
||||||
|
danswer 💃
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div className="flex">
|
||||||
|
<a
|
||||||
|
href={authorizationUrl}
|
||||||
|
className={
|
||||||
|
"group relative w-64 flex justify-center " +
|
||||||
|
"py-2 px-4 border border-transparent text-sm " +
|
||||||
|
"font-medium rounded-md text-white bg-red-600 " +
|
||||||
|
"hover:bg-red-700 focus:outline-none focus:ring-2 " +
|
||||||
|
"focus:ring-offset-2 focus:ring-red-500 mx-auto"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Sign in with Google
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page;
|
@ -19,7 +19,9 @@ export default function RootLayout({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<body className={`${inter.variable} font-sans`}>{children}</body>
|
<body className={`${inter.variable} font-sans bg-gray-900`}>
|
||||||
|
{children}
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import { Inter } from "next/font/google";
|
|
||||||
import { SearchSection } from "@/components/SearchBar";
|
import { SearchSection } from "@/components/SearchBar";
|
||||||
import { Header } from "@/components/Header";
|
import { Header } from "@/components/Header";
|
||||||
|
|
||||||
const inter = Inter({ subsets: ["latin"] });
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -1,11 +1,34 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { logout } from "@/lib/user";
|
||||||
|
import { UserCircle } from "@phosphor-icons/react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import "tailwindcss/tailwind.css";
|
import "tailwindcss/tailwind.css";
|
||||||
|
|
||||||
export const Header: React.FC = () => {
|
export const Header: React.FC = () => {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="bg-gray-800 text-gray-200 py-4">
|
<header className="bg-gray-800 text-gray-200 py-4">
|
||||||
<div className="container mx-auto ml-8">
|
<div className="mx-auto mx-8 flex">
|
||||||
<h1 className="text-2xl font-bold">danswer 💃</h1>
|
<h1 className="text-2xl font-bold">danswer 💃</h1>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className="ml-auto flex items-center cursor-pointer hover:text-red-500"
|
||||||
|
onClick={() =>
|
||||||
|
logout().then((isSuccess) => {
|
||||||
|
if (!isSuccess) {
|
||||||
|
alert("Failed to logout");
|
||||||
|
}
|
||||||
|
router.push("/auth/login");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{/* TODO: make this a dropdown with more options */}
|
||||||
|
<UserCircle size={24} className="mr-1" />
|
||||||
|
Logout
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
|
8
web/src/lib/types.ts
Normal file
8
web/src/lib/types.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export interface User {
|
||||||
|
id: string;
|
||||||
|
email: string;
|
||||||
|
is_active: string;
|
||||||
|
is_superuser: string;
|
||||||
|
is_verified: string;
|
||||||
|
role: string;
|
||||||
|
}
|
21
web/src/lib/user.ts
Normal file
21
web/src/lib/user.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { User } from "./types";
|
||||||
|
|
||||||
|
// should be used client-side only
|
||||||
|
export const getCurrentUser = async (): Promise<User | null> => {
|
||||||
|
const response = await fetch("/api/users/me", {
|
||||||
|
credentials: "include",
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const user = await response.json();
|
||||||
|
return user;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const logout = async (): Promise<boolean> => {
|
||||||
|
const response = await fetch("/api/auth/database/logout", {
|
||||||
|
method: "POST",
|
||||||
|
credentials: "include",
|
||||||
|
});
|
||||||
|
return response.ok;
|
||||||
|
};
|
40
web/src/lib/userSS.ts
Normal file
40
web/src/lib/userSS.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { cookies } from "next/headers";
|
||||||
|
import { User } from "./types";
|
||||||
|
|
||||||
|
const INTERNAL_AUTH_URL =
|
||||||
|
process.env.INTERNAL_AUTH_URL || "http://127.0.0.1:8080";
|
||||||
|
|
||||||
|
export const buildUrl = (path: string) => {
|
||||||
|
if (path.startsWith("/")) {
|
||||||
|
return `${INTERNAL_AUTH_URL}${path}`;
|
||||||
|
}
|
||||||
|
return `${INTERNAL_AUTH_URL}/${path}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getGoogleOAuthUrlSS = async (): Promise<string> => {
|
||||||
|
const res = await fetch(buildUrl("/auth/google/authorize"));
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error("Failed to fetch data");
|
||||||
|
}
|
||||||
|
|
||||||
|
const data: { authorization_url: string } = await res.json();
|
||||||
|
return data.authorization_url;
|
||||||
|
};
|
||||||
|
|
||||||
|
// should be used server-side only
|
||||||
|
export const getCurrentUserSS = async (): Promise<User | null> => {
|
||||||
|
const response = await fetch(buildUrl("/users/me"), {
|
||||||
|
credentials: "include",
|
||||||
|
headers: {
|
||||||
|
cookie: cookies()
|
||||||
|
.getAll()
|
||||||
|
.map((cookie) => `${cookie.name}=${cookie.value}`)
|
||||||
|
.join("; "),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const user = await response.json();
|
||||||
|
return user;
|
||||||
|
};
|
Reference in New Issue
Block a user