diff --git a/.gitmodules b/.gitmodules deleted file mode 100755 index 15a8324..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "osintbuddy-plugins"] - path = backend/backend/osintbuddy-plugins - url = https://github.com/jerlendds/osintbuddy-plugins.git diff --git a/CITATION.cff b/CITATION.cff old mode 100755 new mode 100644 diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 index ce2fab1..22fc438 --- a/README.md +++ b/README.md @@ -22,7 +22,8 @@ [Discord](https://discord.gg/gsbbYHA3K3)                                                                [forum.osintbuddy.com](https://forum.osintbuddy.com)                                              [osintbuddy-plugins](https://github.com/jerlendds/osintbuddy-plugins) -

Introducing OSINTBuddy

+ ## Introducing OSINTBuddy +

Welcome to the OSINTBuddy project where you can connect, combine, and get insights from unstructured and public data as results that @@ -90,19 +91,15 @@ We've decided to do something about it. The rapid developments in technologies s ### Key Features - Simplified data fetching from multiple sources. - Visual representation of fetched data for easy understanding. -- A powerful development platform that is open for contributions. -- New plugin-based system for transforming data, check out the [osintbuddy](https://pypi.org/project/osintbuddy/) package. Documentation is coming soon. +- A development platform that is open for contributions. +- Plugin-based system for transforming data, check out the [osintbuddy](https://pypi.org/project/osintbuddy/) package. -## [↑](#what-is-osintbuddycom)Getting Started +## Getting Started To start using OSINTBuddy, follow these simple installation steps: - - ### Installation 1. Clone the repo and submodules ```sh @@ -115,11 +112,11 @@ https://willi.am/blog/2016/08/11/docker-for-windows-dealing-with-windows-line-en - [Learn how to install Docker on Linux](https://docs.docker.com/desktop/install/linux-install/) 3. Start the stack with Docker: ```sh - # run ./launcher with no arguments for help - ./launcher bootstrap - ./launcher start + # ./launcher # display usage information. + ./launcher bootstrap # ensure the environment is setup correctly; build images. + ./launcher start # start the osintbuddy stack. ``` - - **Note:** the stack will take a few minutes to startup while solr and scylladb configure themselves for JanusGraph. If you try to connect before all the databases are ready you will encounter errors. + - **Note:** the stack will take a few minutes to startup while Solr and ScyllaDB configure themselves for JanusGraph. If you try to connect before all the databases are ready you will encounter errors. - **URLs** - Frontend: http://localhost:3000 @@ -128,18 +125,18 @@ https://willi.am/blog/2016/08/11/docker-for-windows-dealing-with-windows-line-en - Documentation: http://localhost:8000/docs - Access OSINTBuddy through the URLs provided for the frontend, backend, and documentation. -## [↑](#what-is-osintbuddycom)Roadmap +## [↑](#introducing-osintbuddy)Roadmap ~~See our [trello board](https://trello.com/b/99Q70frX/) for a list of our upcoming features.~~ -See the forum: [forum.osintbuddy.com](https://forum.osintbuddy.com), for a list of our upcoming features, potential ideas, and more. (*Note: We're currently in the process of setting up the forum and moving trello issues over. We're not sure when this will be completed. For the time being you can count on dev log updates being on the forum from now on.*) +See the forum: [forum.osintbuddy.com](https://forum.osintbuddy.com), for a list of our upcoming features, potential ideas, and more (*Note: We're currently in the process of setting up the forum and moving trello issues over. We're not sure when this will be completed. For the time being you can count on dev log updates being on the forum from now on*). See the [open issues](https://github.com/jerlendds/osintbuddy/issues) for a list of requested features (and known issues). -## [↑](#what-is-osintbuddycom)Progress Notes +### [↑](#introducing-osintbuddy)Progress Notes - [x] Website node - [x] Google search node @@ -153,13 +150,17 @@ for a list of requested features (and known issues). - [x] Added a plugin system - [x] Updated plugin system to be easier to work with - [x] Implemented automatic saving for project graphs - -- For this update you'll have to rebuild your docker containers (`./launcher build`)! After a long wait you'll be rewarded with a new UX, an updated plugin system now running as its own service, Casdoor managed auth for signing in/up, a new CLI tool, `ob` for managing plugin development, and another CLI `./launcher` for managing the OSINTBuddy stack: `launcher`! - -[osintbuddy](https://pypi.org/project/osintbuddy/) +- [x] Added `ob` and `launcher` CLI tools +- [x] Added Casdoor for auth +- [x] Improved UI/UX +- [] Added wizards for plugin create and custom `.env` setup +- [] Moved plugin system to its own service -## [↑](#what-is-osintbuddycom)Contributing +For this update you'll have to rebuild your docker containers (`./launcher build`)! After a long wait you'll be rewarded with a new UX, an updated plugin system now running as its own service, Casdoor managed auth for signing in/up, a new CLI tool, `ob`, for managing plugin development and the plugin server, and another CLI `./launcher` for managing the OSINTBuddy stack. + + +## [↑](#introducing-osintbuddy)Contributing Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. @@ -170,7 +171,27 @@ Contributions are what make the open source community such an amazing place to l 5. Open a Pull Request -## [↑](#what-is-osintbuddycom)License +## [↑](#introducing-osintbuddy)Sponsor OSINTBuddy +Help us keep the OSINTBuddy project free and maintained forever. +Sponsor the OSINTBuddy project for unique benefits. Learn more on the [OSINTBuddy OpenCollective project page](https://opencollective.com/openinfolabs/projects/osintbuddy#category-CONTRIBUTE) + +[![Yearly OpenCollective Income](https://badgen.net/opencollective/yearly/osintbuddy)](https://opencollective.com/openinfolabs/projects/osintbuddy#category-CONTRIBUTE) +[![OpenCollective Backers](https://badgen.net/opencollective/backers/osintbuddy)](https://opencollective.com/openinfolabs/projects/osintbuddy#category-CONTRIBUTE) + + + +## [↑](#introducing-osintbuddy)Contact + +[Open an issue](https://github.com/jerlendds/osintbuddy/issues/new?assignees=jerlendds&labels=Type%3A+Suggestion&projects=&template=feature.md&title=%5BFEATURE+REQUEST%5D+Your_feature_request_here) if you need to get in touch with me or send an email to jerlendds@osintbuddy.com. + + +- osintbuddy: [github.com/jerlendds/osintbuddy](https://github.com/jerlendds/osintbuddy) +- osintbuddy-core-plugins: [github.com/jerlendds/osintbuddy-core-plugins](https://github.com/jerlendds/osintbuddy-core-plugins) +- osintbuddy-plugins: [github.com/jerlendds/osintbuddy-plugins](https://github.com/jerlendds/osintbuddy-plugins) - [pypi.org/project/osintbuddy](https://pypi.org/project/osintbuddy/) +- patched `aiogremlin` library: [github.com/jerlendds/gremlinpy](https://github.com/jerlendds/gremlinpy/) + + +## [↑](#introducing-osintbuddy)License Licensed under the GNU Affero General Public License v3.0. @@ -179,23 +200,6 @@ Copyright 2023 jerlendds. [GNU AGPL v3](https://choosealicense.com/licenses/apac *Note: the [OSINTBuddy PyPi package](https://github.com/jerlendds/osintbuddy-plugins) is MIT licensed*. -## [↑](#what-is-osintbuddycom)Contact - -[Open an issue](https://github.com/jerlendds/osintbuddy/issues/new?assignees=jerlendds&labels=Type%3A+Suggestion&projects=&template=feature.md&title=%5BFEATURE+REQUEST%5D+Your_feature_request_here) if you need to get in touch with me or send an email to jerlendds@osintbuddy.com. - - -- osintbuddy: [github.com/jerlendds/osintbuddy](https://github.com/jerlendds/osintbuddy) -- osintbuddy-core-plugins: [github.com/jerlendds/osintbuddy-core-plugins](https://github.com/jerlendds/osintbuddy-core-plugins) -- osintbuddy-plugins: [github.com/jerlendds/osintbuddy-plugins](https://github.com/jerlendds/osintbuddy-plugins) -- patched `aiogremlin` library: [github.com/jerlendds/gremlinpy](https://github.com/jerlendds/gremlinpy/) - -## [↑](#what-is-osintbuddycom)Sponsor OSINTBuddy -Help us keep the OSINTBuddy project free and maintained forever. -Sponsor the OSINTBuddy project for unique benefits. Learn more on the [OSINTBuddy OpenCollective project page](https://opencollective.com/openinfolabs/projects/osintbuddy#category-CONTRIBUTE) - -[![Yearly OpenCollective Income](https://badgen.net/opencollective/yearly/osintbuddy)](https://opencollective.com/openinfolabs/projects/osintbuddy#category-CONTRIBUTE) -[![OpenCollective Backers](https://badgen.net/opencollective/backers/osintbuddy)](https://opencollective.com/openinfolabs/projects/osintbuddy#category-CONTRIBUTE) - [contributors-shield]: https://img.shields.io/github/contributors/jerlendds/osintbuddy.svg?style=for-the-badge [contributors-url]: https://github.com/jerlendds/osintbuddy/graphs/contributors [forks-shield]: https://img.shields.io/github/forks/jerlendds/osintbuddy.svg?style=for-the-badge @@ -204,3 +208,4 @@ Sponsor the OSINTBuddy project for unique benefits. Learn more on the [OSINTBudd [stars-url]: https://github.com/jerlendds/osintbuddy/stargazers [issues-shield]: https://img.shields.io/github/issues/jerlendds/osintbuddy.svg?style=for-the-badge [issues-url]: https://github.com/jerlendds/osintbuddy/issues + diff --git a/backend/backend/.dockerignore b/backend/.dockerignore similarity index 100% rename from backend/backend/.dockerignore rename to backend/.dockerignore diff --git a/backend/backend/.gitignore b/backend/.gitignore similarity index 100% rename from backend/backend/.gitignore rename to backend/.gitignore diff --git a/backend/backend/app/alembic.ini b/backend/app/alembic.ini similarity index 100% rename from backend/backend/app/alembic.ini rename to backend/app/alembic.ini diff --git a/backend/backend/app/alembic/README b/backend/app/alembic/README similarity index 100% rename from backend/backend/app/alembic/README rename to backend/app/alembic/README diff --git a/backend/backend/app/alembic/env.py b/backend/app/alembic/env.py similarity index 100% rename from backend/backend/app/alembic/env.py rename to backend/app/alembic/env.py diff --git a/backend/backend/app/alembic/script.py.mako b/backend/app/alembic/script.py.mako similarity index 100% rename from backend/backend/app/alembic/script.py.mako rename to backend/app/alembic/script.py.mako diff --git a/backend/backend/app/alembic/versions/5173e62ae5a5_last_initial_revision_reset.py b/backend/app/alembic/versions/5173e62ae5a5_last_initial_revision_reset.py similarity index 100% rename from backend/backend/app/alembic/versions/5173e62ae5a5_last_initial_revision_reset.py rename to backend/app/alembic/versions/5173e62ae5a5_last_initial_revision_reset.py diff --git a/backend/backend/app/alembic/versions/5260b5f19250_projects_to_graphs.py b/backend/app/alembic/versions/5260b5f19250_projects_to_graphs.py similarity index 100% rename from backend/backend/app/alembic/versions/5260b5f19250_projects_to_graphs.py rename to backend/app/alembic/versions/5260b5f19250_projects_to_graphs.py diff --git a/backend/backend/app/alembic/versions/964597ac2699_add_users.py b/backend/app/alembic/versions/964597ac2699_add_users.py similarity index 100% rename from backend/backend/app/alembic/versions/964597ac2699_add_users.py rename to backend/app/alembic/versions/964597ac2699_add_users.py diff --git a/backend/backend/app/alembic/versions/9a20076792f7_add_username_user.py b/backend/app/alembic/versions/9a20076792f7_add_username_user.py similarity index 100% rename from backend/backend/app/alembic/versions/9a20076792f7_add_username_user.py rename to backend/app/alembic/versions/9a20076792f7_add_username_user.py diff --git a/backend/backend/app/alembic/versions/d51c30bacade_migrate.py b/backend/app/alembic/versions/d51c30bacade_migrate.py similarity index 100% rename from backend/backend/app/alembic/versions/d51c30bacade_migrate.py rename to backend/app/alembic/versions/d51c30bacade_migrate.py diff --git a/backend/backend/app/alembic/versions/fab5d9c099df_add_disabled_user.py b/backend/app/alembic/versions/fab5d9c099df_add_disabled_user.py similarity index 100% rename from backend/backend/app/alembic/versions/fab5d9c099df_add_disabled_user.py rename to backend/app/alembic/versions/fab5d9c099df_add_disabled_user.py diff --git a/backend/backend/app/app/__init__.py b/backend/app/app/__init__.py similarity index 100% rename from backend/backend/app/app/__init__.py rename to backend/app/app/__init__.py diff --git a/backend/backend/app/app/api/__init__.py b/backend/app/app/api/__init__.py similarity index 100% rename from backend/backend/app/app/api/__init__.py rename to backend/app/app/api/__init__.py diff --git a/backend/backend/app/app/api/api_v1/__init__.py b/backend/app/app/api/api_v1/__init__.py similarity index 100% rename from backend/backend/app/app/api/api_v1/__init__.py rename to backend/app/app/api/api_v1/__init__.py diff --git a/backend/backend/app/app/api/api_v1/api.py b/backend/app/app/api/api_v1/api.py similarity index 61% rename from backend/backend/app/app/api/api_v1/api.py rename to backend/app/app/api/api_v1/api.py index b4f6632..7870271 100755 --- a/backend/backend/app/app/api/api_v1/api.py +++ b/backend/app/app/api/api_v1/api.py @@ -1,11 +1,12 @@ from fastapi import APIRouter, Header, Depends -from app.api.api_v1.endpoints import graphs, nodes, entities, login, scans +from app.api.api_v1.endpoints import graphs, nodes, entities, login, scans, accounts api_router = APIRouter() -api_router.include_router(nodes.router, tags=["Nodes"]) -api_router.include_router(scans.router, tags=["Scans"]) -api_router.include_router(entities.router, tags=["Entities"]) +api_router.include_router(login.router, tags=["Login"]) +api_router.include_router(accounts.router, tags=["Accounts"]) api_router.include_router(graphs.router, tags=["Graphs"]) -api_router.include_router(login.router, tags=["login"]) +api_router.include_router(entities.router, tags=["Entities"]) +api_router.include_router(nodes.router, tags=["Nodes"]) +api_router.include_router(scans.router, tags=["Scans"]) \ No newline at end of file diff --git a/backend/backend/app/app/api/api_v1/endpoints/__init__.py b/backend/app/app/api/api_v1/endpoints/__init__.py similarity index 100% rename from backend/backend/app/app/api/api_v1/endpoints/__init__.py rename to backend/app/app/api/api_v1/endpoints/__init__.py diff --git a/backend/app/app/api/api_v1/endpoints/accounts.py b/backend/app/app/api/api_v1/endpoints/accounts.py new file mode 100644 index 0000000..2c4ed83 --- /dev/null +++ b/backend/app/app/api/api_v1/endpoints/accounts.py @@ -0,0 +1,31 @@ +from typing import Annotated + +from casdoor import AsyncCasdoorSDK +from fastapi import APIRouter, Request, Depends, HTTPException + +from app import crud, schemas, models +from app.core.logger import get_logger +from app.api import deps + + +log = get_logger("api_v1.endpoints.users") +router = APIRouter(prefix="/account") + + +@router.get( + "/", + response_model=schemas.CasdoorUser, + response_model_exclude_none=True +) +async def get_account( + request: Request, + user: Annotated[schemas.CasdoorUser, Depends(deps.get_user_from_session)] +): + sdk: AsyncCasdoorSdk = request.app.state.CASDOOR_SDK + username = user.get("name") + try: + user_data = await sdk.get_user(username) + return schemas.CasdoorUser(**user_data) + except Exception as e: + log.error("Error inside accounts.get_account:") + log.error(e) diff --git a/backend/backend/app/app/api/api_v1/endpoints/entities.py b/backend/app/app/api/api_v1/endpoints/entities.py similarity index 100% rename from backend/backend/app/app/api/api_v1/endpoints/entities.py rename to backend/app/app/api/api_v1/endpoints/entities.py diff --git a/backend/backend/app/app/api/api_v1/endpoints/graphs.py b/backend/app/app/api/api_v1/endpoints/graphs.py similarity index 98% rename from backend/backend/app/app/api/api_v1/endpoints/graphs.py rename to backend/app/app/api/api_v1/endpoints/graphs.py index 623fe4d..45ebef9 100755 --- a/backend/backend/app/app/api/api_v1/endpoints/graphs.py +++ b/backend/app/app/api/api_v1/endpoints/graphs.py @@ -16,6 +16,7 @@ from app import crud, schemas from app.core.logger import get_logger from app.db.janus import ProjectGraphConnection, janus_create_db + log = get_logger("api_v1.endpoints.graphs") router = APIRouter(prefix="/graphs") @@ -55,7 +56,7 @@ async def update_favorite_graph_uuid( response_model=schemas.GraphsList ) async def get_graphs( - user: Annotated[schemas.CasdoorUser, Depends(deps.get_user_from_session)], + user: schemas.CasdoorUser = Depends(deps.get_user_from_session), db: Session = Depends(deps.get_db), skip: int = 0, limit: int = 100, @@ -75,6 +76,7 @@ async def get_graphs( } + @router.post( '', response_model=schemas.Graph diff --git a/backend/app/app/api/api_v1/endpoints/login.py b/backend/app/app/api/api_v1/endpoints/login.py new file mode 100755 index 0000000..d7ee1e8 --- /dev/null +++ b/backend/app/app/api/api_v1/endpoints/login.py @@ -0,0 +1,37 @@ +from typing import Annotated, Union + +from casdoor import AsyncCasdoorSDK +from fastapi import APIRouter, Body, Request, Depends, HTTPException + +from app import crud, schemas +from app.api import deps +from app.core.logger import get_logger + + +log = get_logger("api_v1.endpoints.login") +router = APIRouter(prefix="/auth") + + +@router.post("/sign-in", response_model=schemas.Status) +async def post_signin(code: str, request: Request): + try: + sdk: AsyncCasdoorSDK = request.app.state.CASDOOR_SDK + casdoor_tokens = await sdk.get_oauth_token(code) + tokens = schemas.CasdoorTokens(**casdoor_tokens) + + user = sdk.parse_jwt_token(tokens.access_token) + request.session["member"] = user + return {"status": "ok"} + except Exception as e: + log.error("Error in login.post_signin:") + log.error(e) + return HTTPException( + status_code=422, + detail="A sign in error has occurred." + ) + + +@router.post("/sign-out", response_model=schemas.Status) +async def post_signout(request: Request): + del request.session["member"] + return {"status": "ok"} diff --git a/backend/backend/app/app/api/api_v1/endpoints/nodes.py b/backend/app/app/api/api_v1/endpoints/nodes.py similarity index 100% rename from backend/backend/app/app/api/api_v1/endpoints/nodes.py rename to backend/app/app/api/api_v1/endpoints/nodes.py diff --git a/backend/backend/app/app/api/api_v1/endpoints/scans.py b/backend/app/app/api/api_v1/endpoints/scans.py similarity index 91% rename from backend/backend/app/app/api/api_v1/endpoints/scans.py rename to backend/app/app/api/api_v1/endpoints/scans.py index ae2fcc6..03eb0ad 100755 --- a/backend/backend/app/app/api/api_v1/endpoints/scans.py +++ b/backend/app/app/api/api_v1/endpoints/scans.py @@ -1,8 +1,4 @@ -import uuid - from fastapi import APIRouter, HTTPException, Depends -from gremlinpy import Cluster -from gremlinpy.exception import GremlinServerError from sqlalchemy.orm import Session from app.api import deps diff --git a/backend/backend/app/app/api/deps.py b/backend/app/app/api/deps.py similarity index 78% rename from backend/backend/app/app/api/deps.py rename to backend/app/app/api/deps.py index 85fd0f0..940dc8c 100755 --- a/backend/backend/app/app/api/deps.py +++ b/backend/app/app/api/deps.py @@ -1,36 +1,35 @@ -from typing import Generator, Annotated +from typing import Generator, Annotated, Optional from contextlib import contextmanager import boto3 -from jose import jwt -from fastapi import Depends, HTTPException, status, Security +import datetime +from fastapi import Depends, HTTPException, status, Security, Response, Request, Cookie +from fastapi.responses import JSONResponse from fastapi.security import OAuth2PasswordBearer, SecurityScopes -from starlette.requests import Request +from fastapi.responses import JSONResponse from sqlalchemy.orm import Session from pydantic import ValidationError import undetected_chromedriver as uc from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities - -from app.core import security +from casdoor import AsyncCasdoorSDK from app.db.session import SessionLocal from app import crud, models, schemas from app.core.config import settings from app.core.logger import get_logger +from fastapi.encoders import jsonable_encoder + log = get_logger("api.deps") - oauth2_scheme = OAuth2PasswordBearer( tokenUrl=f"{settings.API_V1_STR}/signin", ) -async def get_user_from_session(request: Request): - try: - sdk = request.app.state.CASDOOR_SDK - user_jwt = request.headers.get("authorization", "").replace("Bearer ", "") - user = sdk.parse_jwt_token(user_jwt) - return schemas.CasdoorUser.validate(user) - except Exception as e: - log.error(e) + +async def get_user_from_session( + request: Request, +): + if user := request.session.get("member"): + return user raise HTTPException(status_code=401, detail="Unauthorized") diff --git a/backend/backend/app/app/api/utils.py b/backend/app/app/api/utils.py similarity index 100% rename from backend/backend/app/app/api/utils.py rename to backend/app/app/api/utils.py diff --git a/backend/backend/app/app/backend_pre_start.py b/backend/app/app/backend_pre_start.py similarity index 100% rename from backend/backend/app/app/backend_pre_start.py rename to backend/app/app/backend_pre_start.py diff --git a/backend/backend/app/app/celeryworker_pre_start.py b/backend/app/app/celeryworker_pre_start.py similarity index 100% rename from backend/backend/app/app/celeryworker_pre_start.py rename to backend/app/app/celeryworker_pre_start.py diff --git a/backend/backend/app/app/core/__init__.py b/backend/app/app/core/__init__.py similarity index 100% rename from backend/backend/app/app/core/__init__.py rename to backend/app/app/core/__init__.py diff --git a/backend/backend/app/app/core/casdoor.py b/backend/app/app/core/casdoor.py similarity index 100% rename from backend/backend/app/app/core/casdoor.py rename to backend/app/app/core/casdoor.py diff --git a/backend/backend/app/app/core/celery_app.py b/backend/app/app/core/celery_app.py similarity index 100% rename from backend/backend/app/app/core/celery_app.py rename to backend/app/app/core/celery_app.py diff --git a/backend/backend/app/app/core/config.py b/backend/app/app/core/config.py similarity index 90% rename from backend/backend/app/app/core/config.py rename to backend/app/app/core/config.py index 14fee81..60c2611 100755 --- a/backend/backend/app/app/core/config.py +++ b/backend/app/app/core/config.py @@ -62,13 +62,7 @@ class Settings(BaseSettings): SENTRY_DSN: str = None - SUPERUSER_EMAIL: str = "admin@example.com" - SUPERUSER_PASSWORD: str = "password" - SUPERUSER_USERNAME: str = "sudo" - SUPERUSER_FULL_NAME: str = "Super Admin" - BACKEND_LOG_LEVEL: str = "info" - UVICORN_HOST: str = "0.0.0.0" class Config: case_sensitive = True diff --git a/backend/backend/app/app/core/logger.py b/backend/app/app/core/logger.py similarity index 100% rename from backend/backend/app/app/core/logger.py rename to backend/app/app/core/logger.py diff --git a/backend/backend/app/app/crud/__init__.py b/backend/app/app/crud/__init__.py similarity index 100% rename from backend/backend/app/app/crud/__init__.py rename to backend/app/app/crud/__init__.py diff --git a/backend/backend/app/app/crud/base.py b/backend/app/app/crud/base.py similarity index 100% rename from backend/backend/app/app/crud/base.py rename to backend/app/app/crud/base.py diff --git a/backend/backend/app/app/crud/crud_entities.py b/backend/app/app/crud/crud_entities.py similarity index 100% rename from backend/backend/app/app/crud/crud_entities.py rename to backend/app/app/crud/crud_entities.py diff --git a/backend/backend/app/app/crud/crud_graphs.py b/backend/app/app/crud/crud_graphs.py similarity index 100% rename from backend/backend/app/app/crud/crud_graphs.py rename to backend/app/app/crud/crud_graphs.py diff --git a/backend/backend/app/app/crud/crud_scan_machines.py b/backend/app/app/crud/crud_scan_machines.py similarity index 64% rename from backend/backend/app/app/crud/crud_scan_machines.py rename to backend/app/app/crud/crud_scan_machines.py index b3f4c3d..84df1bf 100755 --- a/backend/backend/app/app/crud/crud_scan_machines.py +++ b/backend/app/app/crud/crud_scan_machines.py @@ -1,9 +1,3 @@ -import datetime -from typing import Any, Dict, Optional, Union - -from sqlalchemy.orm import Session - -from app.core.security import get_password_hash, verify_password from app.crud.base import CRUDBase from app.models.scans import Scan_Machines from app.schemas.scan_machines import ScanMachineCreate, ScanMachineUpdate diff --git a/backend/app/app/crud/crud_user.py b/backend/app/app/crud/crud_user.py new file mode 100755 index 0000000..7ee0a27 --- /dev/null +++ b/backend/app/app/crud/crud_user.py @@ -0,0 +1,28 @@ +import datetime +from typing import Any, Dict, Optional, Union + +from sqlalchemy.orm import Session + +from app.crud.base import CRUDBase +from app.models.user import User +from app.schemas.user import UserCreate, UserUpdate + + +class CRUDUser(CRUDBase[User, UserCreate, UserUpdate]): + def get_by_email(self, db: Session, *, email: str) -> Optional[User]: + return db.query(User).filter(User.email == email).first() + + def full_name(self, user: User) -> str: + return user.full_name + + def is_active(self, user: User) -> bool: + return user.is_active + + def is_superuser(self, user: User) -> bool: + return user.is_superuser + + def is_disabled(self, user: User) -> bool: + return user.disabled + + +user = CRUDUser(User) diff --git a/backend/backend/app/app/db/__init__.py b/backend/app/app/db/__init__.py similarity index 100% rename from backend/backend/app/app/db/__init__.py rename to backend/app/app/db/__init__.py diff --git a/backend/backend/app/app/db/base.py b/backend/app/app/db/base.py similarity index 100% rename from backend/backend/app/app/db/base.py rename to backend/app/app/db/base.py diff --git a/backend/backend/app/app/db/base_class.py b/backend/app/app/db/base_class.py similarity index 100% rename from backend/backend/app/app/db/base_class.py rename to backend/app/app/db/base_class.py diff --git a/backend/backend/app/app/db/encoder.py b/backend/app/app/db/encoder.py similarity index 100% rename from backend/backend/app/app/db/encoder.py rename to backend/app/app/db/encoder.py diff --git a/backend/backend/app/app/db/init_db.py b/backend/app/app/db/init_db.py similarity index 100% rename from backend/backend/app/app/db/init_db.py rename to backend/app/app/db/init_db.py diff --git a/backend/backend/app/app/db/janus.py b/backend/app/app/db/janus.py similarity index 100% rename from backend/backend/app/app/db/janus.py rename to backend/app/app/db/janus.py diff --git a/backend/backend/app/app/db/session.py b/backend/app/app/db/session.py similarity index 100% rename from backend/backend/app/app/db/session.py rename to backend/app/app/db/session.py diff --git a/backend/backend/app/app/email-templates/src/new_account.mjml b/backend/app/app/email-templates/src/new_account.mjml similarity index 100% rename from backend/backend/app/app/email-templates/src/new_account.mjml rename to backend/app/app/email-templates/src/new_account.mjml diff --git a/backend/backend/app/app/email-templates/src/reset_password.mjml b/backend/app/app/email-templates/src/reset_password.mjml similarity index 100% rename from backend/backend/app/app/email-templates/src/reset_password.mjml rename to backend/app/app/email-templates/src/reset_password.mjml diff --git a/backend/backend/app/app/email-templates/src/test_email.mjml b/backend/app/app/email-templates/src/test_email.mjml similarity index 100% rename from backend/backend/app/app/email-templates/src/test_email.mjml rename to backend/app/app/email-templates/src/test_email.mjml diff --git a/backend/backend/app/app/exceptions.py b/backend/app/app/exceptions.py similarity index 100% rename from backend/backend/app/app/exceptions.py rename to backend/app/app/exceptions.py diff --git a/backend/backend/app/app/gunicorn_conf.py b/backend/app/app/gunicorn_conf.py similarity index 100% rename from backend/backend/app/app/gunicorn_conf.py rename to backend/app/app/gunicorn_conf.py diff --git a/backend/backend/app/app/initial_data.py b/backend/app/app/initial_data.py similarity index 100% rename from backend/backend/app/app/initial_data.py rename to backend/app/app/initial_data.py diff --git a/backend/backend/app/app/logging.yml b/backend/app/app/logging.yml similarity index 100% rename from backend/backend/app/app/logging.yml rename to backend/app/app/logging.yml diff --git a/backend/backend/app/app/main.py b/backend/app/app/main.py similarity index 93% rename from backend/backend/app/app/main.py rename to backend/app/app/main.py index 809dd1d..547cfba 100755 --- a/backend/backend/app/app/main.py +++ b/backend/app/app/main.py @@ -1,5 +1,6 @@ +from typing import Annotated from contextlib import asynccontextmanager -from fastapi import FastAPI, Request +from fastapi import FastAPI, Request, Response, Depends from fastapi.routing import APIRoute from fastapi.responses import UJSONResponse from fastapi.openapi.utils import get_openapi @@ -14,7 +15,8 @@ from osintbuddy import discover_plugins from app.api.api_v1.api import api_router from app.core.config import settings, use_route_names_as_operation_ids from app.core.casdoor import Config as CasdoorConfig - +from app.api import deps +from app import schemas # if settings.SENTRY_DSN: # sentry_sdk.init( # # integrations=(AsyncioIntegration(),), @@ -64,9 +66,11 @@ app.add_middleware( ], ) + app.add_middleware( SessionMiddleware, secret_key=CasdoorConfig.SECRET_KEY, + max_age=settings.ACCESS_TOKEN_EXPIRE_MINUTES ) app.state.CASDOOR_SDK = CasdoorConfig().CASDOOR_SDK app.state.REDIRECT_URI = CasdoorConfig().REDIRECT_URI @@ -74,8 +78,6 @@ app.state.SECRET_TYPE = CasdoorConfig().SECRET_TYPE app.state.SECRET_KEY = CasdoorConfig().SECRET_KEY - - use_route_names_as_operation_ids(app) def app_openapi_schema(app): diff --git a/backend/backend/app/app/models/__init__.py b/backend/app/app/models/__init__.py similarity index 100% rename from backend/backend/app/app/models/__init__.py rename to backend/app/app/models/__init__.py diff --git a/backend/backend/app/app/models/entities.py b/backend/app/app/models/entities.py similarity index 100% rename from backend/backend/app/app/models/entities.py rename to backend/app/app/models/entities.py diff --git a/backend/backend/app/app/models/graphs.py b/backend/app/app/models/graphs.py similarity index 100% rename from backend/backend/app/app/models/graphs.py rename to backend/app/app/models/graphs.py diff --git a/backend/backend/app/app/models/proxy.py b/backend/app/app/models/proxy.py similarity index 100% rename from backend/backend/app/app/models/proxy.py rename to backend/app/app/models/proxy.py diff --git a/backend/backend/app/app/models/scans.py b/backend/app/app/models/scans.py similarity index 100% rename from backend/backend/app/app/models/scans.py rename to backend/app/app/models/scans.py diff --git a/backend/backend/app/app/models/user.py b/backend/app/app/models/user.py similarity index 100% rename from backend/backend/app/app/models/user.py rename to backend/app/app/models/user.py diff --git a/backend/backend/app/app/schemas/__init__.py b/backend/app/app/schemas/__init__.py similarity index 69% rename from backend/backend/app/app/schemas/__init__.py rename to backend/app/app/schemas/__init__.py index 36a309e..9628c2f 100755 --- a/backend/backend/app/app/schemas/__init__.py +++ b/backend/app/app/schemas/__init__.py @@ -19,8 +19,22 @@ from .entities import ( # noqa EntityInDB, PostEntityCreate, ) -from .user import User, UserUpdate, UserCreate, UserBase, UserInDB, UserInDBBase, CasdoorUser # noqa -from .token import Token, TokenPayload, TokenData # noqa +from .user import ( # noqa + User, + UserUpdate, + UserCreate, + UserBase, + UserInDB, + UserInDBBase, + CasdoorUser +) +from .token import ( + Token, + TokenPayload, + TokenData, + Status, + CasdoorTokens +) # noqa from .scan_machines import ( ScanMachine, ScanMachineBase, diff --git a/backend/backend/app/app/schemas/api_errors.py b/backend/app/app/schemas/api_errors.py similarity index 100% rename from backend/backend/app/app/schemas/api_errors.py rename to backend/app/app/schemas/api_errors.py diff --git a/backend/backend/app/app/schemas/entities.py b/backend/app/app/schemas/entities.py similarity index 100% rename from backend/backend/app/app/schemas/entities.py rename to backend/app/app/schemas/entities.py diff --git a/backend/backend/app/app/schemas/graphs.py b/backend/app/app/schemas/graphs.py similarity index 100% rename from backend/backend/app/app/schemas/graphs.py rename to backend/app/app/schemas/graphs.py diff --git a/backend/backend/app/app/schemas/msg.py b/backend/app/app/schemas/msg.py similarity index 100% rename from backend/backend/app/app/schemas/msg.py rename to backend/app/app/schemas/msg.py diff --git a/backend/backend/app/app/schemas/node.py b/backend/app/app/schemas/node.py similarity index 100% rename from backend/backend/app/app/schemas/node.py rename to backend/app/app/schemas/node.py diff --git a/backend/backend/app/app/schemas/scan_machines.py b/backend/app/app/schemas/scan_machines.py similarity index 100% rename from backend/backend/app/app/schemas/scan_machines.py rename to backend/app/app/schemas/scan_machines.py diff --git a/backend/backend/app/app/schemas/token.py b/backend/app/app/schemas/token.py similarity index 58% rename from backend/backend/app/app/schemas/token.py rename to backend/app/app/schemas/token.py index c879901..7ad72a7 100755 --- a/backend/backend/app/app/schemas/token.py +++ b/backend/app/app/schemas/token.py @@ -15,3 +15,17 @@ class TokenPayload(BaseModel): class TokenData(BaseModel): username: str | None = None scopes: List[str] = [] + + +class Status(BaseModel): + status: str + + +class CasdoorTokens(BaseModel): + access_token: str + id_token: str + refresh_token: str + token_type: str + scope: str + expires_in: int + \ No newline at end of file diff --git a/backend/backend/app/app/schemas/user.py b/backend/app/app/schemas/user.py similarity index 65% rename from backend/backend/app/app/schemas/user.py rename to backend/app/app/schemas/user.py index 1e4a0c5..81ab6a5 100755 --- a/backend/backend/app/app/schemas/user.py +++ b/backend/app/app/schemas/user.py @@ -6,37 +6,41 @@ from pydantic import BaseModel, EmailStr class CasdoorUser(BaseModel): - id: UUID - name: str - displayName: str - createdTime: datetime.datetime - updatedTime: datetime.datetime - sub: UUID - firstName: str - lastName: str - avatar: str - avatarType: str - permanentAvatar: str - email: str - emailVerified: bool - phone: str - countryCode: str - region: str - location: str - bio: str - language: str - isOnline: bool - isAdmin: bool - isForbidden: bool - isDeleted: bool owner: str = "org_ob" type: str = "normal-user" signupApplication: str = "application_ob" - aud: List[str] = [] - exp: int - nbf: int - iat: int - jti: str + + id: UUID + sub: Optional[UUID] = None + exp: Optional[int] = None + nbf: Optional[int] = None + iat: Optional[int] = None + jti: Optional[str] = None + aud: List[str] = None + + avatar: Optional[str] + avatarType: Optional[str] + permanentAvatar: Optional[str] + firstName: Optional[str] = None + lastName: Optional[str] = None + + name: str + displayName: str + email: str + emailVerified: bool + phone: Optional[str] + countryCode: Optional[str] + region: Optional[str] + location: Optional[str] + bio: Optional[str] + language: Optional[str] = "en" + + isOnline: Optional[bool] = False + isAdmin: Optional[bool] = False + isForbidden: Optional[bool] = False + isDeleted: Optional[bool] = False + updatedTime: datetime.datetime + createdTime: datetime.datetime # Shared properties diff --git a/backend/backend/app/app/shell.py b/backend/app/app/shell.py similarity index 100% rename from backend/backend/app/app/shell.py rename to backend/app/app/shell.py diff --git a/backend/backend/app/app/start.py b/backend/app/app/start.py similarity index 100% rename from backend/backend/app/app/start.py rename to backend/app/app/start.py diff --git a/backend/backend/app/app/tests/.gitignore b/backend/app/app/tests/.gitignore similarity index 100% rename from backend/backend/app/app/tests/.gitignore rename to backend/app/app/tests/.gitignore diff --git a/backend/backend/app/app/tests/__init__.py b/backend/app/app/tests/__init__.py similarity index 100% rename from backend/backend/app/app/tests/__init__.py rename to backend/app/app/tests/__init__.py diff --git a/backend/backend/app/app/tests/api/__init__.py b/backend/app/app/tests/api/__init__.py similarity index 100% rename from backend/backend/app/app/tests/api/__init__.py rename to backend/app/app/tests/api/__init__.py diff --git a/backend/backend/app/app/tests/api/api_v1/__init__.py b/backend/app/app/tests/api/api_v1/__init__.py similarity index 100% rename from backend/backend/app/app/tests/api/api_v1/__init__.py rename to backend/app/app/tests/api/api_v1/__init__.py diff --git a/backend/backend/app/app/tests/api_v1/test_login.py b/backend/app/app/tests/api_v1/test_login.py similarity index 100% rename from backend/backend/app/app/tests/api_v1/test_login.py rename to backend/app/app/tests/api_v1/test_login.py diff --git a/backend/backend/app/app/tests/api_v1/test_users.py b/backend/app/app/tests/api_v1/test_users.py similarity index 100% rename from backend/backend/app/app/tests/api_v1/test_users.py rename to backend/app/app/tests/api_v1/test_users.py diff --git a/backend/backend/app/app/tests/conftest.py b/backend/app/app/tests/conftest.py similarity index 100% rename from backend/backend/app/app/tests/conftest.py rename to backend/app/app/tests/conftest.py diff --git a/backend/backend/app/app/tests/crud/__init__.py b/backend/app/app/tests/crud/__init__.py similarity index 100% rename from backend/backend/app/app/tests/crud/__init__.py rename to backend/app/app/tests/crud/__init__.py diff --git a/backend/backend/app/app/tests/crud/test_user.py b/backend/app/app/tests/crud/test_user.py similarity index 100% rename from backend/backend/app/app/tests/crud/test_user.py rename to backend/app/app/tests/crud/test_user.py diff --git a/backend/backend/app/app/tests/utils/__init__.py b/backend/app/app/tests/utils/__init__.py similarity index 100% rename from backend/backend/app/app/tests/utils/__init__.py rename to backend/app/app/tests/utils/__init__.py diff --git a/backend/backend/app/app/tests/utils/user.py b/backend/app/app/tests/utils/user.py similarity index 100% rename from backend/backend/app/app/tests/utils/user.py rename to backend/app/app/tests/utils/user.py diff --git a/backend/backend/app/app/tests/utils/utils.py b/backend/app/app/tests/utils/utils.py similarity index 100% rename from backend/backend/app/app/tests/utils/utils.py rename to backend/app/app/tests/utils/utils.py diff --git a/backend/backend/app/app/tests_pre_start.py b/backend/app/app/tests_pre_start.py similarity index 100% rename from backend/backend/app/app/tests_pre_start.py rename to backend/app/app/tests_pre_start.py diff --git a/backend/backend/app/app/utils.py b/backend/app/app/utils.py similarity index 100% rename from backend/backend/app/app/utils.py rename to backend/app/app/utils.py diff --git a/backend/backend/app/app/worker.py b/backend/app/app/worker.py similarity index 100% rename from backend/backend/app/app/worker.py rename to backend/app/app/worker.py diff --git a/backend/backend/app/prestart.sh b/backend/app/prestart.sh similarity index 100% rename from backend/backend/app/prestart.sh rename to backend/app/prestart.sh diff --git a/backend/backend/app/start-reload.sh b/backend/app/start-reload.sh similarity index 100% rename from backend/backend/app/start-reload.sh rename to backend/app/start-reload.sh diff --git a/backend/backend/app/start.sh b/backend/app/start.sh similarity index 100% rename from backend/backend/app/start.sh rename to backend/app/start.sh diff --git a/backend/backend/app/tests-start.sh b/backend/app/tests-start.sh similarity index 100% rename from backend/backend/app/tests-start.sh rename to backend/app/tests-start.sh diff --git a/backend/backend/app/worker-start.sh b/backend/app/worker-start.sh similarity index 100% rename from backend/backend/app/worker-start.sh rename to backend/app/worker-start.sh diff --git a/backend/backend/backend.Dockerfile b/backend/backend.Dockerfile similarity index 100% rename from backend/backend/backend.Dockerfile rename to backend/backend.Dockerfile diff --git a/backend/backend/app/app/api/api_v1/endpoints/login.py b/backend/backend/app/app/api/api_v1/endpoints/login.py deleted file mode 100755 index c2a0a36..0000000 --- a/backend/backend/app/app/api/api_v1/endpoints/login.py +++ /dev/null @@ -1,45 +0,0 @@ -from datetime import timedelta -from typing import Any - -from fastapi import APIRouter, Body, Request, Depends, HTTPException -from fastapi.security import OAuth2PasswordRequestForm -from sqlalchemy.orm import Session -from fastapi.responses import JSONResponse -from app import crud, schemas -from app.api import deps -from app.core import security -from app.core.config import settings -from app.core.logger import get_logger -from app.core.security import get_password_hash -from app.utils import ( - generate_password_reset_token, - send_reset_password_email, - verify_password_reset_token, -) - - -log = get_logger("api_v1.endpoints.login") -router = APIRouter() - - -@router.get("/get-account", response_class=JSONResponse) -async def get_account(request: Request, user=Depends(deps.get_user_from_session)): - sdk = request.app.state.CASDOOR_SDK - user_data = await sdk.get_user(user["name"]) - return user_data - - -@router.post("/sign-in", response_class=JSONResponse) -async def post_signin(code: str, request: Request): - state = request.query_params.get("state") - sdk = request.app.state.CASDOOR_SDK - token = await sdk.get_oauth_token(code) - user = sdk.parse_jwt_token(token.get("access_token", None)) - request.session["obUser"] = user - return {"success": True} - - -@router.post("/sign-out", response_class=JSONResponse) -async def post_signout(request: Request): - del request.session["obUser"] - return {"success": True} diff --git a/backend/backend/app/app/core/security.py b/backend/backend/app/app/core/security.py deleted file mode 100755 index c27dfea..0000000 --- a/backend/backend/app/app/core/security.py +++ /dev/null @@ -1,35 +0,0 @@ -from datetime import datetime, timedelta -from typing import Any, Union - -from jose import jwt -from passlib.context import CryptContext # noqa - -from app.core.config import settings - -pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") - - -ALGORITHM = "HS256" - - -def create_access_token( - data: dict, expires_delta: timedelta = None -) -> str: - to_encode = data.copy() - if expires_delta: - expire = datetime.utcnow() + expires_delta - else: - expire = datetime.utcnow() + timedelta( - minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES - ) - to_encode.update({"exp": expire}) - encoded_jwt = jwt.encode(to_encode, settings.SECRET_KEY, algorithm=ALGORITHM) - return encoded_jwt - - -def verify_password(plain_password: str, hashed_password: str) -> bool: - return pwd_context.verify(plain_password, hashed_password) - - -def get_password_hash(password: str) -> str: - return pwd_context.hash(password) diff --git a/backend/backend/app/app/crud/crud_user.py b/backend/backend/app/app/crud/crud_user.py deleted file mode 100755 index 3e41e6f..0000000 --- a/backend/backend/app/app/crud/crud_user.py +++ /dev/null @@ -1,85 +0,0 @@ -import datetime -from typing import Any, Dict, Optional, Union - -from sqlalchemy.orm import Session - -from app.core.security import get_password_hash, verify_password -from app.crud.base import CRUDBase -from app.models.user import User -from app.schemas.user import UserCreate, UserUpdate - - -class CRUDUser(CRUDBase[User, UserCreate, UserUpdate]): - def get_by_email(self, db: Session, *, email: str) -> Optional[User]: - return db.query(User).filter(User.email == email).first() - - def create(self, db: Session, *, obj_in: UserCreate) -> User: - if isinstance(obj_in, dict): - user_data = obj_in - else: - user_data = obj_in.dict(exclude_unset=True) - - if user_data["password"]: - hashed_password = get_password_hash(user_data["password"]) - del user_data["password"] - user_data["hashed_password"] = hashed_password - - db_obj = self.model(**user_data) - db.add(db_obj) - db.commit() - db.refresh(db_obj) - return db_obj - - def create_superuser(self, db: Session, *, obj_in: UserCreate) -> User: - if isinstance(obj_in, dict): - user_data = obj_in - else: - user_data = obj_in.dict(exclude_unset=True) - - if user_data["password"]: - hashed_password = get_password_hash(user_data["password"]) - del user_data["password"] - user_data["hashed_password"] = hashed_password - user_data['is_superuser'] = True - db_obj = self.model(**user_data) - db.add(db_obj) - db.commit() - db.refresh(db_obj) - return db_obj - - def update( - self, db: Session, *, db_obj: User, obj_in: Union[UserUpdate, Dict[str, Any]] - ) -> User: - if isinstance(obj_in, dict): - update_data = obj_in - else: - update_data = obj_in.dict(exclude_unset=True) - if update_data["password"]: - hashed_password = get_password_hash(update_data["password"]) - del update_data["password"] - update_data["hashed_password"] = hashed_password - update_data["modified"] = datetime.datetime.utcnow() - return super().update(db, db_obj=db_obj, obj_in=update_data) - - def authenticate(self, db: Session, *, email: str, password: str) -> Optional[User]: - user = self.get_by_email(db, email=email) - if not user: - return None - if not verify_password(password, user.hashed_password): - return None - return user - - def full_name(self, user: User) -> str: - return user.full_name - - def is_active(self, user: User) -> bool: - return user.is_active - - def is_superuser(self, user: User) -> bool: - return user.is_superuser - - def is_disabled(self, user: User) -> bool: - return user.disabled - - -user = CRUDUser(User) diff --git a/backend/backend/dev-requirements.txt b/backend/dev-requirements.txt similarity index 100% rename from backend/backend/dev-requirements.txt rename to backend/dev-requirements.txt diff --git a/backend/backend/requirements.txt b/backend/requirements.txt similarity index 100% rename from backend/backend/requirements.txt rename to backend/requirements.txt diff --git a/backend/backend/worker.Dockerfile b/backend/worker.Dockerfile similarity index 100% rename from backend/backend/worker.Dockerfile rename to backend/worker.Dockerfile diff --git a/frontend/.yarnrc.yml b/frontend/.yarnrc.yml deleted file mode 100755 index 3186f3f..0000000 --- a/frontend/.yarnrc.yml +++ /dev/null @@ -1 +0,0 @@ -nodeLinker: node-modules diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 1be497e..69a4ba0 100755 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,9 +1,16 @@ FROM node:18-alpine LABEL maintainer="jerlendds " -WORKDIR /app/ +RUN adduser -D osintbuddy-system +WORKDIR /home/osintbuddy-system +USER osintbuddy-system COPY package.json yarn.lock ./ -RUN yarn install && ls && pwd -COPY . . -CMD [ "yarn", "start" ] +ARG REACT_APP_BASE_URL +ENV REACT_APP_BASE_URL ${REACT_APP_BASE_URL} +RUN yarn + +USER root +RUN mkdir /app +WORKDIR /app +COPY . . diff --git a/frontend/README.md b/frontend/README.md old mode 100755 new mode 100644 index 86999e0..25de284 --- a/frontend/README.md +++ b/frontend/README.md @@ -33,7 +33,7 @@ ```bash cd frontend yarn - yarn start + yarn ui:dev ``` 3. From the `osintbuddy` directory, start the rest of the stack: diff --git a/frontend/craco.config.js b/frontend/craco.config.js old mode 100755 new mode 100644 index 0bec853..681912f --- a/frontend/craco.config.js +++ b/frontend/craco.config.js @@ -1,5 +1,12 @@ const path = require('path'); +const cracoSwcPlugin = require('craco-swc'); + module.exports = { + plugins: [ + { + plugin: cracoSwcPlugin, + } + ], webpack: { alias: { '@': path.resolve(__dirname, 'src'), diff --git a/frontend/entrypoint.sh b/frontend/entrypoint.sh new file mode 100755 index 0000000..e5957e3 --- /dev/null +++ b/frontend/entrypoint.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +cp -r /home/osintbuddy-system/node_modules/ /app/ + +echo "$0 0" +echo "$1 1" +echo "$2 2" +echo "$3 3" +echo "$4 4" +echo "$REACT_APP_BASE_URL" +echo "$BASE_URL" +yarn ui:dev diff --git a/frontend/nginx.conf b/frontend/nginx.conf deleted file mode 100755 index 3eacd96..0000000 --- a/frontend/nginx.conf +++ /dev/null @@ -1,11 +0,0 @@ -server { - listen 80; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html =404; - } - - include /etc/nginx/extra-conf.d/*.conf; -} \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json old mode 100755 new mode 100644 index 268505f..0ea1668 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,10 +1,8 @@ { - "name": "frontend", + "name": "osintbuddy-ui", "version": "0.3.0", "private": true, "dependencies": { - "@axa-fr/oidc-client": "^7.7.2", - "@axa-fr/react-oidc": "^7.7.2", "@codemirror/lang-python": "^6.1.3", "@excalidraw/excalidraw": "^0.16.1", "@headlessui/react": "^1.7.7", @@ -12,6 +10,7 @@ "@lexical/file": "^0.12.2", "@lexical/headless": "^0.12.2", "@lexical/mark": "^0.12.2", + "@lexical/react": "^0.12.2", "@locker/near-membrane-dom": "^0.12.14", "@open-rpc/client-js": "^1.8.1", "@reactour/tour": "^3.4.0", @@ -23,12 +22,14 @@ "@yaireo/dragsort": "^1.3.1", "@yaireo/tagify": "^4.17.8", "axios": "^1.2.1", + "casdoor-js-sdk": "^0.11.0", "chartist": "^1.3.0", "classnames": "^2.3.2", "dagre": "^0.8.5", "formik": "^2.2.9", "graphology": "^0.25.4", "katex": "^0.16.9", + "lexical": "^0.12.2", "lodash-es": "^4.17.21", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -49,10 +50,10 @@ "yup": "^0.32.11" }, "scripts": { - "start": "craco start", + "ui:dev": "craco start", "build": "craco build", "test": "craco test", - "swagger:codegen": "rm -f -dr ./src/app/openapi && mkdir ./src/app/openapi && openapi --name obSDK --client axios -i http://localhost:8000/api/v1/openapi.json --output ./src/app/openapi --exportModels true --exportSchemas true --indent 2 --postfixServices v1" + "swagger:codegen": "rm -f -dr ./src/app/openapi && mkdir ./src/app/openapi && openapi --name obSDK -i http://localhost:8000/api/v1/openapi.json --output ./src/app/openapi --exportModels true --exportSchemas true --indent 2 --postfixServices v1" }, "eslintConfig": { "extends": [ @@ -75,7 +76,6 @@ "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@craco/craco": "^7.1.0", - "@lexical/react": "^0.12.2", "@swc/helpers": "^0.5.1", "@tailwindcss/typography": "^0.5.9", "@testing-library/jest-dom": "^5.16.5", @@ -94,7 +94,6 @@ "autoprefixer": "^10.4.13", "buffer": "^6.0.3", "craco-swc": "^0.5.1", - "lexical": "^0.12.2", "openapi-typescript-codegen": "^0.25.0", "postcss": "^8.4.20", "tailwindcss": "^3.2.4", diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js old mode 100755 new mode 100644 diff --git a/frontend/src/@types/api.d.ts b/frontend/src/@types/api.d.ts deleted file mode 100755 index 8fd58cc..0000000 --- a/frontend/src/@types/api.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -interface FetchProps { - pageSize: number; - pageIndex: number; -} - -interface NodeData { - label: string; - color: HexColor; - icon: TablerIcon; - style: {}; - elements: NodeInput[]; -} - -interface ApiNode { - id: string; - position: XYPosition; - data: NodeData; - type: 'base'; -} - -interface ApiTransforms { - type: string; - transforms: { label: string; icon: TablerIcon }; -} - diff --git a/frontend/src/@types/globals.d.ts b/frontend/src/@types/globals.d.ts deleted file mode 100644 index 2f3fe66..0000000 --- a/frontend/src/@types/globals.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module '@yaireo/dragsort'; - -declare type JSONObject = { - [any: string]: any -}; -type HexColor = `#${string}`; diff --git a/frontend/src/@types/nodes.d.ts b/frontend/src/@types/nodes.d.ts deleted file mode 100755 index 5347fdd..0000000 --- a/frontend/src/@types/nodes.d.ts +++ /dev/null @@ -1,88 +0,0 @@ -interface XYPosition { - x: number; - y: number; -} - -interface ActiveProject { - name: string; - description: string; - uuid: string; - id: number; -} - -interface EditState { - editId: string; - editLabel: string; - editValue: string; -} - - - - -interface ActiveProjectGraph { - id: number; - uuid: string; - name: string; - description?: string -} - -interface NodeMenu { - id: string; - node: HTMLElement; - data: JSONObject; - label: string; - transforms: string[]; - bounds: DOMRect; -} - -interface AddNode { - id: number; - type: string; - position: XYPosition; - data: any; -} - -interface AddEdge { - source: string; - target: string; - sourceHandle?: string | undefined; - targetHandle?: string | undefined; - type?: string | undefined; -} - -type NodeTypes = - | 'dropdown' - | 'text' - | 'number' - | 'decimal' - | 'upload' - | 'title' - | 'section' - | 'image' - | 'video' - | 'json' - | 'list' - | 'table' - | 'copy-text' - | 'copy-code' - | 'empty'; - -interface NodeInput { - type: NodeTypes; - label: string; - style: React.CSSProperties; - placeholder: string; - options?: DropdownOption[]; - value?: string; - icon?: any; - title?: string; - subtitle?: string; - text?: string; - dispatch: () => void; - sendJsonMessage: () => void; -} - -interface DropdownOption { - label: string; - tooltip: string; -} diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx old mode 100755 new mode 100644 index b5a91f9..d4a9f23 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -9,7 +9,7 @@ const config: SdkConfig = { organizationName: "org_ob", appName: "application_ob", redirectPath: "/callback", - signinPath: "/api/v1/sign-in", + signinPath: "/api/v1/auth/sign-in", } window.sdk = new SDK(config) diff --git a/frontend/src/app/api.ts b/frontend/src/app/api.ts index 74a9175..2d0b63e 100755 --- a/frontend/src/app/api.ts +++ b/frontend/src/app/api.ts @@ -2,14 +2,11 @@ import axios from 'axios'; import { obSDK } from './openapi'; const DOMAIN = process.env.REACT_APP_BASE_URL?.replace('https://', '').replace('http://', '') -const BASE_URL = process.env.NODE_ENV === 'development' ? 'http://localhost:8000' : process.env.REACT_APP_BASE_URL; +const BASE_URL = process.env.REACT_APP_BASE_URL; const API_PREFIX = '/api/v1'; -const WS_URL = - process.env.NODE_ENV === 'development' - ? 'localhost:8000' + API_PREFIX - : DOMAIN + API_PREFIX; +const WS_URL = DOMAIN + API_PREFIX; const LS_USER_AUTH_KEY = 'user-data'; @@ -17,18 +14,11 @@ const api = axios.create({ baseURL: BASE_URL + API_PREFIX, }); -const setHeader = () => { - const accessToken = sessionStorage.getItem('accessToken') - if (accessToken) { - api.defaults.headers.common['Authorization'] = `Bearer ${sessionStorage.getItem('accessToken')}`; - return accessToken; - } -}; - export const sdk = new obSDK({ BASE: BASE_URL, - TOKEN: setHeader(), + CREDENTIALS: "include", + WITH_CREDENTIALS: true, }) -export { BASE_URL, LS_USER_AUTH_KEY, WS_URL, API_PREFIX, setHeader }; +export { BASE_URL, LS_USER_AUTH_KEY, WS_URL, API_PREFIX }; export default api; diff --git a/frontend/src/app/openapi/core/AxiosHttpRequest.ts b/frontend/src/app/openapi/core/FetchHttpRequest.ts similarity index 93% rename from frontend/src/app/openapi/core/AxiosHttpRequest.ts rename to frontend/src/app/openapi/core/FetchHttpRequest.ts index 3cd6639..d9cb463 100644 --- a/frontend/src/app/openapi/core/AxiosHttpRequest.ts +++ b/frontend/src/app/openapi/core/FetchHttpRequest.ts @@ -8,7 +8,7 @@ import type { CancelablePromise } from './CancelablePromise'; import type { OpenAPIConfig } from './OpenAPI'; import { request as __request } from './request'; -export class AxiosHttpRequest extends BaseHttpRequest { +export class FetchHttpRequest extends BaseHttpRequest { constructor(config: OpenAPIConfig) { super(config); diff --git a/frontend/src/app/openapi/core/request.ts b/frontend/src/app/openapi/core/request.ts index 7398f8f..115f664 100644 --- a/frontend/src/app/openapi/core/request.ts +++ b/frontend/src/app/openapi/core/request.ts @@ -2,10 +2,6 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ -import axios from 'axios'; -import type { AxiosError, AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios'; -import FormData from 'form-data'; - import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; @@ -42,10 +38,6 @@ export const isFormData = (value: any): value is FormData => { return value instanceof FormData; }; -export const isSuccess = (status: number): boolean => { - return status >= 200 && status < 300; -}; - export const base64 = (str: string): string => { try { return btoa(str); @@ -144,24 +136,22 @@ export const resolve = async (options: ApiRequestOptions, resolver?: T | Reso return resolver; }; -export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions, formData?: FormData): Promise> => { +export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { const token = await resolve(options, config.TOKEN); const username = await resolve(options, config.USERNAME); const password = await resolve(options, config.PASSWORD); const additionalHeaders = await resolve(options, config.HEADERS); - const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {} const headers = Object.entries({ Accept: 'application/json', ...additionalHeaders, ...options.headers, - ...formHeaders, }) - .filter(([_, value]) => isDefined(value)) - .reduce((headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), {} as Record); + .filter(([_, value]) => isDefined(value)) + .reduce((headers, [key, value]) => ({ + ...headers, + [key]: String(value), + }), {} as Record); if (isStringWithValue(token)) { headers['Authorization'] = `Bearer ${token}`; @@ -184,53 +174,52 @@ export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptio } } - return headers; + return new Headers(headers); }; export const getRequestBody = (options: ApiRequestOptions): any => { - if (options.body) { - return options.body; + if (options.body !== undefined) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } } return undefined; }; -export const sendRequest = async ( +export const sendRequest = async ( config: OpenAPIConfig, options: ApiRequestOptions, url: string, body: any, formData: FormData | undefined, - headers: Record, - onCancel: OnCancel, - axiosClient: AxiosInstance -): Promise> => { - const source = axios.CancelToken.source(); + headers: Headers, + onCancel: OnCancel +): Promise => { + const controller = new AbortController(); - const requestConfig: AxiosRequestConfig = { - url, + const request: RequestInit = { headers, - data: body ?? formData, + body: body ?? formData, method: options.method, - withCredentials: config.WITH_CREDENTIALS, - cancelToken: source.token, + signal: controller.signal, }; - onCancel(() => source.cancel('The user aborted a request.')); - - try { - return await axiosClient.request(requestConfig); - } catch (error) { - const axiosError = error as AxiosError; - if (axiosError.response) { - return axiosError.response; - } - throw error; + if (config.WITH_CREDENTIALS) { + request.credentials = config.CREDENTIALS; } + + onCancel(() => controller.abort()); + + return await fetch(url, request); }; -export const getResponseHeader = (response: AxiosResponse, responseHeader?: string): string | undefined => { +export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => { if (responseHeader) { - const content = response.headers[responseHeader]; + const content = response.headers.get(responseHeader); if (isString(content)) { return content; } @@ -238,9 +227,22 @@ export const getResponseHeader = (response: AxiosResponse, responseHeader?: return undefined; }; -export const getResponseBody = (response: AxiosResponse): any => { +export const getResponseBody = async (response: Response): Promise => { if (response.status !== 204) { - return response.data; + try { + const contentType = response.headers.get('Content-Type'); + if (contentType) { + const jsonTypes = ['application/json', 'application/problem+json'] + const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type)); + if (isJSON) { + return await response.json(); + } else { + return await response.text(); + } + } + } catch (error) { + console.error(error); + } } return undefined; }; @@ -283,26 +285,25 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): * Request method * @param config The OpenAPI configuration object * @param options The request options from the service - * @param axiosClient The axios client instance to use * @returns CancelablePromise * @throws ApiError */ -export const request = (config: OpenAPIConfig, options: ApiRequestOptions, axiosClient: AxiosInstance = axios): CancelablePromise => { +export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { return new CancelablePromise(async (resolve, reject, onCancel) => { try { const url = getUrl(config, options); const formData = getFormData(options); const body = getRequestBody(options); - const headers = await getHeaders(config, options, formData); + const headers = await getHeaders(config, options); if (!onCancel.isCancelled) { - const response = await sendRequest(config, options, url, body, formData, headers, onCancel, axiosClient); - const responseBody = getResponseBody(response); + const response = await sendRequest(config, options, url, body, formData, headers, onCancel); + const responseBody = await getResponseBody(response); const responseHeader = getResponseHeader(response, options.responseHeader); const result: ApiResult = { url, - ok: isSuccess(response.status), + ok: response.ok, status: response.status, statusText: response.statusText, body: responseHeader ?? responseBody, diff --git a/frontend/src/app/openapi/index.ts b/frontend/src/app/openapi/index.ts index 4b6d83d..bf72bcd 100644 --- a/frontend/src/app/openapi/index.ts +++ b/frontend/src/app/openapi/index.ts @@ -10,6 +10,7 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI } from './core/OpenAPI'; export type { OpenAPIConfig } from './core/OpenAPI'; +export type { CasdoorUser } from './models/CasdoorUser'; export type { CreateNode } from './models/CreateNode'; export type { EntityBase } from './models/EntityBase'; export type { Graph } from './models/Graph'; @@ -18,9 +19,11 @@ export type { GraphsList } from './models/GraphsList'; export type { HTTPValidationError } from './models/HTTPValidationError'; export type { PostEntityCreate } from './models/PostEntityCreate'; export type { ScanMachineCreate } from './models/ScanMachineCreate'; +export type { Status } from './models/Status'; export type { ValidationError } from './models/ValidationError'; export type { XYPosition } from './models/XYPosition'; +export { $CasdoorUser } from './schemas/$CasdoorUser'; export { $CreateNode } from './schemas/$CreateNode'; export { $EntityBase } from './schemas/$EntityBase'; export { $Graph } from './schemas/$Graph'; @@ -29,6 +32,7 @@ export { $GraphsList } from './schemas/$GraphsList'; export { $HTTPValidationError } from './schemas/$HTTPValidationError'; export { $PostEntityCreate } from './schemas/$PostEntityCreate'; export { $ScanMachineCreate } from './schemas/$ScanMachineCreate'; +export { $Status } from './schemas/$Status'; export { $ValidationError } from './schemas/$ValidationError'; export { $XYPosition } from './schemas/$XYPosition'; @@ -38,3 +42,4 @@ export { Graphsv1 } from './services/Graphsv1'; export { Loginv1 } from './services/Loginv1'; export { Nodesv1 } from './services/Nodesv1'; export { Scansv1 } from './services/Scansv1'; +export { Usersv1 } from './services/Usersv1'; diff --git a/frontend/src/app/openapi/models/CasdoorUser.ts b/frontend/src/app/openapi/models/CasdoorUser.ts new file mode 100644 index 0000000..5fe116d --- /dev/null +++ b/frontend/src/app/openapi/models/CasdoorUser.ts @@ -0,0 +1,39 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type CasdoorUser = { + id: string; + sub: string; + name: string; + displayName: string; + firstName: string; + lastName: string; + avatar: string; + avatarType: string; + permanentAvatar: string; + email: string; + emailVerified: boolean; + phone: string; + countryCode: string; + region: string; + location: string; + bio: string; + language: string; + aud?: Array; + exp: number; + nbf: number; + iat: number; + jti: string; + isOnline: boolean; + isAdmin: boolean; + isForbidden: boolean; + isDeleted: boolean; + owner?: string; + type?: string; + signupApplication?: string; + createdTime: string; + updatedTime: string; +}; + diff --git a/frontend/src/app/openapi/models/Status.ts b/frontend/src/app/openapi/models/Status.ts new file mode 100644 index 0000000..277d6ce --- /dev/null +++ b/frontend/src/app/openapi/models/Status.ts @@ -0,0 +1,9 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Status = { + status: string; +}; + diff --git a/frontend/src/app/openapi/obSDK.ts b/frontend/src/app/openapi/obSDK.ts index 82a2441..71991f5 100644 --- a/frontend/src/app/openapi/obSDK.ts +++ b/frontend/src/app/openapi/obSDK.ts @@ -4,7 +4,7 @@ /* eslint-disable */ import type { BaseHttpRequest } from './core/BaseHttpRequest'; import type { OpenAPIConfig } from './core/OpenAPI'; -import { AxiosHttpRequest } from './core/AxiosHttpRequest'; +import { FetchHttpRequest } from './core/FetchHttpRequest'; import { Defaultv1 } from './services/Defaultv1'; import { Entitiesv1 } from './services/Entitiesv1'; @@ -12,6 +12,7 @@ import { Graphsv1 } from './services/Graphsv1'; import { Loginv1 } from './services/Loginv1'; import { Nodesv1 } from './services/Nodesv1'; import { Scansv1 } from './services/Scansv1'; +import { Usersv1 } from './services/Usersv1'; type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest; @@ -23,10 +24,11 @@ export class obSDK { public readonly login: Loginv1; public readonly nodes: Nodesv1; public readonly scans: Scansv1; + public readonly users: Usersv1; public readonly request: BaseHttpRequest; - constructor(config?: Partial, HttpRequest: HttpRequestConstructor = AxiosHttpRequest) { + constructor(config?: Partial, HttpRequest: HttpRequestConstructor = FetchHttpRequest) { this.request = new HttpRequest({ BASE: config?.BASE ?? '', VERSION: config?.VERSION ?? '/api/v1', @@ -45,6 +47,7 @@ export class obSDK { this.login = new Loginv1(this.request); this.nodes = new Nodesv1(this.request); this.scans = new Scansv1(this.request); + this.users = new Usersv1(this.request); } } diff --git a/frontend/src/app/openapi/schemas/$CasdoorUser.ts b/frontend/src/app/openapi/schemas/$CasdoorUser.ts new file mode 100644 index 0000000..df773ff --- /dev/null +++ b/frontend/src/app/openapi/schemas/$CasdoorUser.ts @@ -0,0 +1,135 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $CasdoorUser = { + properties: { + id: { + type: 'string', + isRequired: true, + format: 'uuid', + }, + sub: { + type: 'string', + isRequired: true, + format: 'uuid', + }, + name: { + type: 'string', + isRequired: true, + }, + displayName: { + type: 'string', + isRequired: true, + }, + firstName: { + type: 'string', + isRequired: true, + }, + lastName: { + type: 'string', + isRequired: true, + }, + avatar: { + type: 'string', + isRequired: true, + }, + avatarType: { + type: 'string', + isRequired: true, + }, + permanentAvatar: { + type: 'string', + isRequired: true, + }, + email: { + type: 'string', + isRequired: true, + }, + emailVerified: { + type: 'boolean', + isRequired: true, + }, + phone: { + type: 'string', + isRequired: true, + }, + countryCode: { + type: 'string', + isRequired: true, + }, + region: { + type: 'string', + isRequired: true, + }, + location: { + type: 'string', + isRequired: true, + }, + bio: { + type: 'string', + isRequired: true, + }, + language: { + type: 'string', + isRequired: true, + }, + aud: { + type: 'array', + contains: { + type: 'string', + }, + }, + exp: { + type: 'number', + isRequired: true, + }, + nbf: { + type: 'number', + isRequired: true, + }, + iat: { + type: 'number', + isRequired: true, + }, + jti: { + type: 'string', + isRequired: true, + }, + isOnline: { + type: 'boolean', + isRequired: true, + }, + isAdmin: { + type: 'boolean', + isRequired: true, + }, + isForbidden: { + type: 'boolean', + isRequired: true, + }, + isDeleted: { + type: 'boolean', + isRequired: true, + }, + owner: { + type: 'string', + }, + type: { + type: 'string', + }, + signupApplication: { + type: 'string', + }, + createdTime: { + type: 'string', + isRequired: true, + format: 'date-time', + }, + updatedTime: { + type: 'string', + isRequired: true, + format: 'date-time', + }, + }, +} as const; diff --git a/frontend/src/app/openapi/schemas/$Status.ts b/frontend/src/app/openapi/schemas/$Status.ts new file mode 100644 index 0000000..25bcc36 --- /dev/null +++ b/frontend/src/app/openapi/schemas/$Status.ts @@ -0,0 +1,12 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $Status = { + properties: { + status: { + type: 'string', + isRequired: true, + }, + }, +} as const; diff --git a/frontend/src/app/openapi/services/Loginv1.ts b/frontend/src/app/openapi/services/Loginv1.ts index 62931d3..b9c23cd 100644 --- a/frontend/src/app/openapi/services/Loginv1.ts +++ b/frontend/src/app/openapi/services/Loginv1.ts @@ -2,6 +2,8 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { Status } from '../models/Status'; + import type { CancelablePromise } from '../core/CancelablePromise'; import type { BaseHttpRequest } from '../core/BaseHttpRequest'; @@ -9,30 +11,18 @@ export class Loginv1 { constructor(public readonly httpRequest: BaseHttpRequest) {} - /** - * Get Account - * @returns any Successful Response - * @throws ApiError - */ - public getAccount(): CancelablePromise { - return this.httpRequest.request({ - method: 'GET', - url: '/api/v1/get-account', - }); - } - /** * Post Signin * @param code - * @returns any Successful Response + * @returns Status Successful Response * @throws ApiError */ public postSignin( code: string, - ): CancelablePromise { + ): CancelablePromise { return this.httpRequest.request({ method: 'POST', - url: '/api/v1/sign-in', + url: '/api/v1/auth/sign-in', query: { 'code': code, }, @@ -44,13 +34,13 @@ export class Loginv1 { /** * Post Signout - * @returns any Successful Response + * @returns Status Successful Response * @throws ApiError */ - public postSignout(): CancelablePromise { + public postSignout(): CancelablePromise { return this.httpRequest.request({ method: 'POST', - url: '/api/v1/sign-out', + url: '/api/v1/auth/sign-out', }); } diff --git a/frontend/src/app/openapi/services/Usersv1.ts b/frontend/src/app/openapi/services/Usersv1.ts new file mode 100644 index 0000000..35d1b8e --- /dev/null +++ b/frontend/src/app/openapi/services/Usersv1.ts @@ -0,0 +1,26 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CasdoorUser } from '../models/CasdoorUser'; + +import type { CancelablePromise } from '../core/CancelablePromise'; +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; + +export class Usersv1 { + + constructor(public readonly httpRequest: BaseHttpRequest) {} + + /** + * Get Account + * @returns CasdoorUser Successful Response + * @throws ApiError + */ + public getAccount(): CancelablePromise { + return this.httpRequest.request({ + method: 'GET', + url: '/api/v1/account/', + }); + } + +} diff --git a/frontend/src/app/store.ts b/frontend/src/app/store.ts index 207993d..58910a3 100755 --- a/frontend/src/app/store.ts +++ b/frontend/src/app/store.ts @@ -1,11 +1,11 @@ import { configureStore, ThunkAction, Action, combineReducers } from '@reduxjs/toolkit'; -import settings from '@/features/settings/settingsSlice'; +import account from '@/features/account/accountSlice'; import graph from '@/features/graph/graphSlice'; import dashboard from '@/features/dashboard/dashboardSlice'; const reducer = combineReducers({ dashboard, - settings, + account, graph, }); diff --git a/frontend/src/@types/casdoor.d.ts b/frontend/src/casdoor.d.ts old mode 100755 new mode 100644 similarity index 100% rename from frontend/src/@types/casdoor.d.ts rename to frontend/src/casdoor.d.ts diff --git a/frontend/src/components/Notes/images/cat-typing.gif b/frontend/src/components/Notes/images/cat-typing.gif deleted file mode 100644 index 4f45feb..0000000 Binary files a/frontend/src/components/Notes/images/cat-typing.gif and /dev/null differ diff --git a/frontend/src/components/Notes/images/landscape.jpg b/frontend/src/components/Notes/images/landscape.jpg deleted file mode 100644 index a54a11a..0000000 Binary files a/frontend/src/components/Notes/images/landscape.jpg and /dev/null differ diff --git a/frontend/src/components/Notes/images/logo.svg b/frontend/src/components/Notes/images/logo.svg deleted file mode 100644 index b3d52c6..0000000 --- a/frontend/src/components/Notes/images/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/frontend/src/components/Notes/images/yellow-flower-small.jpg b/frontend/src/components/Notes/images/yellow-flower-small.jpg deleted file mode 100644 index 93a6ad0..0000000 Binary files a/frontend/src/components/Notes/images/yellow-flower-small.jpg and /dev/null differ diff --git a/frontend/src/components/Notes/images/yellow-flower.jpg b/frontend/src/components/Notes/images/yellow-flower.jpg deleted file mode 100644 index 9f96c1e..0000000 Binary files a/frontend/src/components/Notes/images/yellow-flower.jpg and /dev/null differ diff --git a/frontend/src/components/Notes/plugins/ComponentPickerPlugin/index.tsx b/frontend/src/components/Notes/plugins/ComponentPickerPlugin/index.tsx index 80d6fe1..3e787f2 100644 --- a/frontend/src/components/Notes/plugins/ComponentPickerPlugin/index.tsx +++ b/frontend/src/components/Notes/plugins/ComponentPickerPlugin/index.tsx @@ -36,7 +36,6 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; import useModal from '../../hooks/useModal'; -import catTypingGif from '../../images/cat-typing.gif'; import { EmbedConfigs } from '../AutoEmbedPlugin'; import { INSERT_COLLAPSIBLE_COMMAND } from '../CollapsiblePlugin'; import { InsertEquationDialog } from '../EquationsPlugin'; @@ -278,15 +277,7 @@ function getBaseOptions(editor: LexicalEditor, showModal: ShowModal) { )), }), - new ComponentPickerOption('GIF', { - icon: , - keywords: ['gif', 'animate', 'image', 'file'], - onSelect: () => - editor.dispatchCommand(INSERT_IMAGE_COMMAND, { - altText: 'Cat typing on a laptop', - src: catTypingGif, - }), - }), + new ComponentPickerOption('Image', { icon: , keywords: ['image', 'photo', 'picture', 'file'], diff --git a/frontend/src/components/Notes/plugins/ImagesPlugin/index.tsx b/frontend/src/components/Notes/plugins/ImagesPlugin/index.tsx index aef9de4..fcbc86d 100644 --- a/frontend/src/components/Notes/plugins/ImagesPlugin/index.tsx +++ b/frontend/src/components/Notes/plugins/ImagesPlugin/index.tsx @@ -27,9 +27,6 @@ import { } from 'lexical'; import { useEffect, useRef, useState } from 'react'; import * as React from 'react'; - -import landscapeImage from '../../images/landscape.jpg'; -import yellowFlowerImage from '../../images/yellow-flower.jpg'; import { $createImageNode, $isImageNode, @@ -167,24 +164,7 @@ export function InsertImageDialog({ <> {!mode && ( - + - { + window.location.href = window.sdk.getSignupUrl(); + }} className='rounded-full bg-slate-800 py-2 px-4 text-sm font-medium text-white hover:bg-slate-700 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white/50 active:text-slate-400' > - View on GitHub - + Sign up + diff --git a/frontend/src/setupTests.ts b/frontend/src/setupTests.ts old mode 100755 new mode 100644 diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js old mode 100755 new mode 100644 diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json old mode 100755 new mode 100644 diff --git a/frontend/tsconfig.paths.json b/frontend/tsconfig.paths.json old mode 100755 new mode 100644 diff --git a/frontend/yarn.lock b/frontend/yarn.lock index f762552..35bb0f7 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -44,27 +44,6 @@ call-me-maybe "^1.0.1" js-yaml "^4.1.0" -"@axa-fr/oidc-client-service-worker@7.7.2": - version "7.7.2" - resolved "https://registry.yarnpkg.com/@axa-fr/oidc-client-service-worker/-/oidc-client-service-worker-7.7.2.tgz#92817735d423ec5d3f3ec70915499d9100afedba" - integrity sha512-xjLbwcuwYUWMjfL1XSGKa82EImYzdrcaO26vUu5w3Q6ch/goVa84P4MvSBrJL7b7ZlVy5a377R3mTiGsR/qJwQ== - -"@axa-fr/oidc-client@7.7.2", "@axa-fr/oidc-client@^7.7.2": - version "7.7.2" - resolved "https://registry.yarnpkg.com/@axa-fr/oidc-client/-/oidc-client-7.7.2.tgz#4cf41beab1d8ab22baecb1862be5fd88677375d7" - integrity sha512-/kBVW3uuk/RQfyVf6mrmx0HDnM2seRl+y2OUbz2pjqe3k47ZNzq6oUId5jdBGCp8qpsGggQ3Cx4jj5hx/7As6w== - dependencies: - "@axa-fr/oidc-client-service-worker" "7.7.2" - -"@axa-fr/react-oidc@^7.7.2": - version "7.7.2" - resolved "https://registry.yarnpkg.com/@axa-fr/react-oidc/-/react-oidc-7.7.2.tgz#2bbb819a60f192bb376c4f0e74380a3a8891ca45" - integrity sha512-IqysixmWTqKr3cTIpKsK7XpgkuI5+UGRMlwoxdLzS99LSotKhGAKlRiFkhgThE7gBYOuVd++WW+hpEedAU/d9Q== - dependencies: - "@axa-fr/oidc-client" "7.7.2" - "@axa-fr/oidc-client-service-worker" "7.7.2" - base64-js "1.5.1" - "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.8.3": version "7.22.13" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.13.tgz#e3c1c099402598483b7a8c46a721d1038803755e" @@ -3560,9 +3539,9 @@ acorn-walk@^7.1.1: integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + version "8.3.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.0.tgz#2097665af50fd0cf7a2dfccd2b9368964e66540f" + integrity sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA== acorn@^7.1.1: version "7.4.1" @@ -3570,9 +3549,9 @@ acorn@^7.1.1: integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== acorn@^8.2.4, acorn@^8.4.1, acorn@^8.7.1, acorn@^8.8.2, acorn@^8.9.0: - version "8.10.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" - integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== + version "8.11.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.2.tgz#ca0d78b51895be5390a5903c5b3bdcdaf78ae40b" + integrity sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w== address@^1.0.1, address@^1.1.2: version "1.2.2" @@ -3883,9 +3862,9 @@ axe-core@^4.6.2: integrity sha512-/dlp0fxyM3R8YW7MFzaHWXrf4zzbr0vaYb23VBFCl83R7nWNPg/yaQw2Dc8jzCMmDVLhSdzH8MjrsuIUuvX+6g== axios@^1.2.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.1.tgz#11fbaa11fc35f431193a9564109c88c1f27b585f" - integrity sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A== + version "1.6.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.0.tgz#f1e5292f26b2fd5c2e66876adc5b06cdbd7d2102" + integrity sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg== dependencies: follow-redirects "^1.15.0" form-data "^4.0.0" @@ -4039,7 +4018,7 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base64-js@1.5.1, base64-js@^1.3.1: +base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== @@ -4241,9 +4220,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001538, caniuse-lite@^1.0.30001541: - version "1.0.30001554" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001554.tgz#ba80d88dff9acbc0cd4b7535fc30e0191c5e2e2a" - integrity sha512-A2E3U//MBwbJVzebddm1YfNp7Nud5Ip+IPn4BozBmn4KqVX7AvluoIDFWjsv5OkGnKUXQVmMSoMKLa3ScCblcQ== + version "1.0.30001555" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001555.tgz#e36f4d49e345337d6788f32093867cec8d951789" + integrity sha512-NzbUFKUnJ3DTcq6YyZB6+qqhfD112uR3uoEnkmfzm2wVzUNsFkU7AwBjKQ654Sp5cau0JxhFyRSn/tQZ+XfygA== casdoor-js-sdk@^0.11.0: version "0.11.0" @@ -5247,9 +5226,9 @@ ejs@^3.1.6: jake "^10.8.5" electron-to-chromium@^1.4.535: - version "1.4.567" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.567.tgz#c92e8fbc2bd15df3068d92571733a218a5413add" - integrity sha512-8KR114CAYQ4/r5EIEsOmOMqQ9j0MRbJZR3aXD/KFA8RuKzyoUB4XrUCg+l8RUGqTVQgKNIgTpjaG8YHRPAbX2w== + version "1.4.569" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.569.tgz#1298b67727187ffbaac005a7425490d157f3ad03" + integrity sha512-LsrJjZ0IbVy12ApW3gpYpcmHS3iRxH4bkKOW98y1/D+3cvDUWGcbzbsFinfUS8knpcZk/PG/2p/RnkMCYN7PVg== emittery@^0.10.2: version "0.10.2" diff --git a/launcher b/launcher index 77676f5..2cd7c29 100755 --- a/launcher +++ b/launcher @@ -39,6 +39,7 @@ usage () { echo -e " $(c YsB)build$(c): Build the OSINTBuddy app (or a specific container ./launcher build ui)." echo -e " $(c YsB)restart$(c): Restart the app (or a specific container: ./launcher restart janus)." echo -e " $(c YsB)api:gen$(c): Generate API client SDK from the backend OpenAPI spec; launch the UI outside of the container" + echo -e " $(c YsB)setup:dev$(c): Create python venv and install dev dependencies" echo -e " $(c YsB)bootstrap$(c): Initialize and download dependencies and check for environment misconfigurations" echo -e " $(c YsB)debug:send$(c): Upload all logs to https://paste.c-net.org for help with debugging" echo -e " $(c YsB)cleanup$(c): Remove docker volumes." @@ -46,6 +47,7 @@ usage () { echo -e " $(c YsB)migrate$(c): Generate a migration." echo -e " $(c YsB)python$(c): Open a python shell on the backend." echo -e " $(c YsB)ui$(c): Stop the UI container and launch the frontend locally." + echo -e " $(c YsB)kill$(c): Kill containers; down the stack." echo -e " $(c YsB)containers$(c): List the names you can access the containers by" usage_containers @@ -78,10 +80,11 @@ case "$OB_CMD" in api:gen) cmd/api:gen ;; + kill) + cmd/downkill + ;; ui) - cmd/api:gen - ob_compose stop ui && \ - cd ../frontend && yarn start + cmd/ui_dev ;; debug:send) cmd/debug:send @@ -99,6 +102,9 @@ case "$OB_CMD" in migrate) cmd/migrate ;; + setup:dev) + cmd/setup:dev + ;; containers) usage_containers ;; diff --git a/ob/.env.alpha b/ob/.env.alpha index 6aa6169..9a1a441 100755 --- a/ob/.env.alpha +++ b/ob/.env.alpha @@ -1,14 +1,9 @@ PROJECT_NAME="osintbuddy" ENVIRONMENT="production" -REACT_APP_BASE_URL="http://0.0.0.0:8000" +REACT_APP_BASE_URL="http://localhost:8000" BACKEND_LOG_LEVEL="info" # Options: critical, error, warning, debug, trace -SUPERUSER_EMAIL="admin@example.com" -SUPERUSER_PASSWORD="password" -SUPERUSER_USERNAME="sudo" -SUPERUSER_FULL_NAME="Super Admin" - ########################################## # Error reporting! (TODO: Wait for sentry to finish implementing their fixes for Python 3.11.4 then reimplement me...) # Remove if you don't want application errors @@ -33,8 +28,8 @@ BACKEND_IMAGE="python:3.11.4-slim-bullseye" ########################################## # Port configuration ########################################## -FRONTEND_PORT=3000 -BACKEND_PORT=8000 +FRONTEND_PORT=3000 # if changed, update BACKEND_CORS_ORIGINS +BACKEND_PORT=8000 # if changed, update REACT_APP_BASE_URL port REDIS_PORT=6379 FLOWER_PORT=5555 POSTGRES_PORT=5432 @@ -89,7 +84,7 @@ FLOWER_BASIC_AUTH="admin:password" ########################################## # FastAPI configuration ########################################## -BACKEND_CORS_ORIGINS=["https://api.YOUR_WEBSITE.com","https://YOUR_WEBSITE.com","http://YOUR_WEBSITE.com","http://localhost:3000","http://localhost","http://local.host:3000","*"] +BACKEND_CORS_ORIGINS=["http://YOUR_WEBSITE.com","http://localhost:3000","http://localhost:80","http://local.host:3000","http://0.0.0.0:3000","http://0.0.0.0:80"] # Run: `openssl rand -hex 32` and replace the below with your output SECRET_KEY=d7c612d43c083f72f98a5ed6d3dc275516f0ac6ebdcc5fdb8c563a29cd114199 diff --git a/ob/alpha-compose.yml b/ob/alpha-compose.yml index c59858e..7167251 100755 --- a/ob/alpha-compose.yml +++ b/ob/alpha-compose.yml @@ -6,11 +6,16 @@ services: container_name: "ob_dev_ui" build: context: ../frontend + args: + REACT_APP_BASE_URL: $REACT_APP_BASE_URL + NODE_ENV: development + command: [ "/app/entrypoint.sh" ] volumes: - - ../frontend/:/app/ - - ../frontend/node_modules:/app/node_modules + - ../frontend/:/app ports: - "${FRONTEND_PORT-3000}:3000" + environment: + NODE_ENV: development env_file: - .env.alpha backend: @@ -18,7 +23,7 @@ services: container_name: "ob_dev_backend" command: ["/bin/sh", "-c", "./start-reload.sh"] build: - context: ../backend/backend + context: ../backend dockerfile: backend.Dockerfile healthcheck: test: ["CMD", "curl", "-f", "http://localhost:${BACKEND_PORT:-8000}/status"] @@ -26,7 +31,7 @@ services: timeout: 2s retries: 5 volumes: - - ../backend/backend/app:/app/ + - ../backend/app:/app/ depends_on: - db environment: @@ -101,7 +106,7 @@ services: tty: true container_name: "ob_dev_worker" build: - context: ../backend/backend + context: ../backend dockerfile: worker.Dockerfile command: ./worker-start.sh env_file: diff --git a/ob/cmd/bootstrap b/ob/cmd/bootstrap index 7088529..151144b 100755 --- a/ob/cmd/bootstrap +++ b/ob/cmd/bootstrap @@ -65,12 +65,12 @@ prepare_windows() { git_autocrlf=$(git config --get core.autocrlf) info "Windows Tip: \n\t\t\thttps://tabby.sh/ configured with a git bash profile is recommended for development" - if [[ ! -z "$git_autocrlf" ]] && [[ "$git_autocrlf" == "true" ]]; then warning "Misconfiguration detected! For this project to work you need unix line endings (https://stackoverflow.com/a/13154031).\n\t\t\tTo fix this error try running the following commands:" info " 1. cd .. && rm -dr osintbuddy" info " 2. git config --global core.autocrlf false" info " 3. git clone --depth=1 --recurse-submodules https://github.com/jerlendds/osintbuddy.git" + info "Windows Tip: https://willi.am/blog/2016/08/11/docker-for-windows-dealing-with-windows-line-endings/" abort else success "Unix line endings detected!" diff --git a/ob/cmd/container_ids b/ob/cmd/container_ids index 9709960..98f6186 100755 --- a/ob/cmd/container_ids +++ b/ob/cmd/container_ids @@ -1,15 +1,16 @@ #!/usr/bin/env sh -. cmd/env export_container_ids() { - export ID_UI=$(cmd/container_id "ui"); - export ID_BACKEND=$(cmd/container_id "backend"); - export ID_REDIS=$(cmd/container_id "redis"); - export ID_DB=$(cmd/container_id "db"); - export ID_JANUS=$(cmd/container_id "janus"); - export ID_SDB=$(cmd/container_id "sdb"); - export ID_INDEX=$(cmd/container_id "index"); - export ID_WORKER=$(cmd/container_id "worker"); - export ID_CLEARLY=$(cmd/container_id "clearly"); - export ID_S3=$(cmd/container_id "s3"); -} \ No newline at end of file + export ID_OB_UI=$(cmd/container_id "ui"); + export ID_OB_BACKEND=$(cmd/container_id "backend"); + export ID_OB_REDIS=$(cmd/container_id "redis"); + export ID_OB_DB=$(cmd/container_id "db"); + export ID_OB_JANUS=$(cmd/container_id "janus"); + export ID_OB_SDB=$(cmd/container_id "sdb"); + export ID_OB_INDEX=$(cmd/container_id "index"); + export ID_OB_WORKER=$(cmd/container_id "worker"); + export ID_OB_CLEARLY=$(cmd/container_id "clearly"); + export ID_OB_S3=$(cmd/container_id "s3"); +} + +export_container_ids \ No newline at end of file diff --git a/ob/cmd/downkill b/ob/cmd/downkill new file mode 100755 index 0000000..159bfab --- /dev/null +++ b/ob/cmd/downkill @@ -0,0 +1,10 @@ +#!/usr/bin/env sh +. cmd/env + +run_down_kill() { + source cmd/container_ids + $docker_path kill $ID_OB_UI $ID_OB_BACKEND $ID_OB_REDIS $ID_OB_DB $ID_OB_JANUS $ID_OB_SDB $ID_OB_INDEX $ID_OB_WORKER $ID_OB_CLEARLY $ID_OB_S3 + ob_compose down +} + +run_down_kill \ No newline at end of file diff --git a/ob/cmd/setup:dev b/ob/cmd/setup:dev new file mode 100755 index 0000000..c3406cf --- /dev/null +++ b/ob/cmd/setup:dev @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +. cmd/env + +run_setup_dev () { + cd ../ + if [ -d "venv" ]; then + rm -dr venv + fi + python3 -m venv venv + . venv/bin/activate + python3 -m pip install --upgrade pip + pip install -r backend/backend/requirements.txt + pip install backend/backend/osintbuddy-plugins +} + +run_setup_dev + diff --git a/ob/cmd/start b/ob/cmd/start index 2dfc85c..7a9e876 100755 --- a/ob/cmd/start +++ b/ob/cmd/start @@ -2,7 +2,11 @@ . cmd/env start() { - ob_compose up -d + if [[ ! -z "$OB_CMD_ARGS" ]]; then + ob_compose up -d $OB_CMD_ARGS + else + ob_compose up -d + fi } @@ -13,7 +17,12 @@ run_start() { error "We ran into an error starting OSINTBuddy. Please file an issue on Github." exit 1 else - ob_compose logs -f + if [[ ! -z "$OB_CMD_ARGS" ]]; then + ob_compose logs -f $OB_CMD_ARGS + else + ob_compose logs -f + fi + success "Starting OSINTBuddy..." success "After JanusGraph connects to ScyllaDB and Solr, the app is ready for use." success "Please allow a few minutes for JanusGraph to finish starting up." diff --git a/ob/cmd/ui_dev b/ob/cmd/ui_dev new file mode 100755 index 0000000..91b47f2 --- /dev/null +++ b/ob/cmd/ui_dev @@ -0,0 +1,21 @@ +#!/usr/bin/env sh +. cmd/env + +run_uidev() { + unset ERR + cmd/api:gen || ERR=$? + if [[ $ERR > 0 ]]; then + error "We ran into an error generating the frontends API client. Is the backend running?" + fi + success "Starting frontend:" + info " http://localhost:3000" + ob_compose stop ui > /dev/null 2>&1 + source "./.env.alpha" + ls -a + echo "envs vars: $REACT_APP_BASE_URL" + cd ../frontend + export REACT_APP_BASE_URL=$REACT_APP_BASE_URL; yarn ui:dev + exit 0 +} + +run_uidev \ No newline at end of file