-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"version": "0.2", | ||
"ignorepaths": [ | ||
".github/", | ||
".git/" | ||
], | ||
"ignorewords": [], | ||
"useGitignore": true, | ||
"language": "en", | ||
"import": [], | ||
"dictionarydefinitions": [], | ||
"dictionaries": [], | ||
"words": [ | ||
"cnap", | ||
"Dockerfile" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Document Scan | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**/*.md' | ||
pull_request: | ||
paths: | ||
- '**/*.md' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
scan_doc: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: streetsidesoftware/cspell-action@v2 | ||
with: | ||
files: | | ||
**/*.md | ||
*.md | ||
config: .github/cspell.json | ||
verbose: true | ||
incremental_files_only: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Pylint Scan | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'src/**/*.py' | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'src/**/*.py' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
codescan: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
- name: Install dependencies | ||
run: | | ||
pip3 install --upgrade pip | ||
pip3 install pylint | ||
for f in $(find -type f -name "requirements.txt"); do | ||
pip3 install -r $f | ||
done | ||
- name: Analyzing the python code | ||
run: | | ||
set -ex | ||
export PYTHONPATH=$PWD/src/tia/ | ||
find . -type f -name "*.py" | xargs pylint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# GenTrade Server | ||
|
||
|
||
## Quick Start | ||
|
||
- Run from source | ||
|
||
```shell | ||
export PYTHONPATH=<repo_dir>/src | ||
uvicorn gentrade-server.main:app --reload | ||
Check warning on line 10 in README.md GitHub Actions / scan_doc
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fastapi[standard] | ||
uvicorn |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from fastapi import Security, HTTPException, status | ||
from fastapi.security import APIKeyHeader | ||
from .db import check_api_key, get_user_from_api_key | ||
|
||
api_key_header = APIKeyHeader(name="X-API-Key") | ||
|
||
def get_user(api_key_header: str = Security(api_key_header)): | ||
if check_api_key(api_key_header): | ||
user = get_user_from_api_key(api_key_header) | ||
return user | ||
raise HTTPException( | ||
status_code=status.HTTP_401_UNAUTHORIZED, | ||
detail="Missing or invalid API key" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
api_keys = { | ||
"e54d4431-5dab-474e-b71a-0db1fcb9e659": "7oDYjo3d9r58EJKYi5x4E8", | ||
"5f0c7127-3be9-4488-b801-c7b6415b45e9": "mUP7PpTHmFAkxcQLWKMY8t" | ||
} | ||
|
||
users = { | ||
"7oDYjo3d9r58EJKYi5x4E8": { | ||
"name": "Bob" | ||
}, | ||
"mUP7PpTHmFAkxcQLWKMY8t": { | ||
"name": "Alice" | ||
}, | ||
} | ||
|
||
def check_api_key(api_key: str): | ||
return api_key in api_keys | ||
|
||
def get_user_from_api_key(api_key: str): | ||
return users[api_keys[api_key]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from fastapi import FastAPI, Depends | ||
from .routers import secure, public | ||
from .auth import get_user | ||
|
||
app = FastAPI() | ||
|
||
app.include_router( | ||
public.router, | ||
prefix="/api/v1/public" | ||
) | ||
app.include_router( | ||
secure.router, | ||
prefix="/api/v1/secure", | ||
dependencies=[Depends(get_user)] | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from fastapi import APIRouter | ||
|
||
|
||
router = APIRouter() | ||
|
||
@router.get("/") | ||
async def get_testroute(): | ||
return "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from fastapi import APIRouter, Depends | ||
from ..auth import get_user | ||
|
||
router = APIRouter() | ||
|
||
@router.get("/") | ||
async def get_testroute(user: dict = Depends(get_user)): | ||
return user |