Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python microservice refactor #4

Merged
merged 48 commits into from Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2d8988f
create python oauth2/data microservice server
macintoshhelper Mar 16, 2023
d10d829
fix imports
macintoshhelper Mar 20, 2023
f6c2a6c
refactor users schema
macintoshhelper Mar 20, 2023
b3da3a3
add paginated response decorator
macintoshhelper Mar 20, 2023
20c01df
implement oauth2 password grant
macintoshhelper Mar 20, 2023
0044f06
add create clients command to app
macintoshhelper Mar 20, 2023
db1e272
implement authentication and nanoid uuid gen for user model
macintoshhelper Mar 20, 2023
91de7bb
add oauth2 REST routes
macintoshhelper Mar 20, 2023
915ea62
create oauth2_clients.json file for client db field init
macintoshhelper Mar 20, 2023
8f379fb
update users api route to use OAuth2 + implement user registration
macintoshhelper Mar 20, 2023
6729ff4
add tmp config.example.py file until sensitive variables are moved to…
macintoshhelper Mar 20, 2023
939d2b5
add flask server alembic migrations
macintoshhelper Mar 21, 2023
de4fcc4
create static OAuth2Client.insert_clients method for nicer oauth2 cli…
macintoshhelper Mar 25, 2023
ceaa128
create confirm/reset auth token API routes
macintoshhelper Mar 25, 2023
b52acf6
relative imports for models entrypoint
macintoshhelper Mar 25, 2023
089c76b
fix email_confirmed update for user model
macintoshhelper Mar 25, 2023
2e0ca13
configure flask server tests/coverage with test config
macintoshhelper Mar 25, 2023
2b2d908
initial tests for oauth2, email confirm, flask factory
macintoshhelper Mar 25, 2023
8d7e74f
system/api oauth client fixes
macintoshhelper Mar 25, 2023
992148f
isolated docker setup for graphql api
macintoshhelper Apr 1, 2023
4890166
CRUD API + OAuth2 client for Flask API in GraphQL server
macintoshhelper Apr 1, 2023
390c4a0
use string uuid for /users/<id> flask route
macintoshhelper Apr 1, 2023
e68e00a
enable OAuth2 refresh token generation
macintoshhelper Apr 1, 2023
37c2a16
implement OAuth2 introspection API route
macintoshhelper Apr 1, 2023
ade35d5
migrate to account_id/email auth for now
macintoshhelper Apr 1, 2023
163dcae
add detach to nextjs docker compose commands
macintoshhelper Apr 1, 2023
f3dfd79
add authorize wrapper to OAuth2Client class
macintoshhelper Apr 1, 2023
0a14377
add oauth query/resolver GraphQL schema/resolver
macintoshhelper Apr 1, 2023
cbeb2bf
return access/refresh token instead of code in login graphql schema
macintoshhelper Apr 1, 2023
7fa5b69
add docker compose setup for flask api server
macintoshhelper Apr 1, 2023
796c761
install gunicorn
macintoshhelper Apr 1, 2023
2b177f0
migrate graphql user resolvers and context to use Flask microservice …
macintoshhelper Apr 1, 2023
7870c0e
load dotenv in flask app.py
macintoshhelper Apr 1, 2023
6a8d624
create flask login API route with internal authorization code flow
macintoshhelper Apr 1, 2023
94519a1
map user uuid to id in schema
macintoshhelper Apr 1, 2023
1c8d36e
add missing expires_at method to OAuth2Token model
macintoshhelper Apr 1, 2023
38e9dc0
generate login_id on user creation (username/account ID for emailess …
macintoshhelper Apr 1, 2023
ae61d2d
remove unused username code
macintoshhelper Apr 1, 2023
184cc16
remove client side email verification requirement
macintoshhelper Apr 1, 2023
e314357
[WIP] create authorize page wrapping graphql resolver (design to be d…
macintoshhelper Apr 1, 2023
0d592e6
add migration
macintoshhelper Apr 1, 2023
cc3ac52
bug fixes
macintoshhelper Apr 1, 2023
67c3514
remove comments
macintoshhelper Apr 5, 2023
3c737b1
oauth2 env var cleanup
macintoshhelper Apr 5, 2023
a507c31
update docker compose config
macintoshhelper Apr 6, 2023
70dfff5
create populate/update client script
macintoshhelper Apr 6, 2023
953900a
user schema fixes
macintoshhelper Apr 6, 2023
3f5cade
finish initial OAuth2 flow with client app support for login/authoriz…
macintoshhelper Apr 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .editorconfig
@@ -0,0 +1,7 @@
[*.py]
indent_style = space
indent_size = 4

[*.js|*.ts]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -114,3 +114,4 @@ certs/
# .env.local
lib/
private.key
.vscode
22 changes: 21 additions & 1 deletion README.md
Expand Up @@ -53,6 +53,11 @@ npm run start:local # alias for the docker-compose script
- https://www.apollographql.com/blog/backend/architecture/how-to-structure-graphql-server-code/#.w8djt4dyf
- https://www.apollographql.com/blog/community/backend/graphql-at-facebook-by-dan-schafer/
-
- https://github.com/spruceid/siwe-quickstart/blob/main/03_complete_app/backend/src/index.js
- Sign-in With Ethereum – https://login.xyz/
-
- https://nhost.io/product/auth
-
- https://app.postdrop.io/ - email HTML (for React templating?)
-
- VERIFYING EMAILS: https://designmodo.com/verification-emails/
Expand All @@ -63,4 +68,19 @@ npm run start:local # alias for the docker-compose script
- https://github.com/curityio/react-haapi-demo/blob/master/src/components/OidcClient.js
- https://github.com/curityio/react-haapi-demo/blob/master/src/components/HAAPIProcessor.js
-
-
-

Docker cron - https://levelup.gitconnected.com/cron-docker-the-easiest-job-scheduler-youll-ever-create-e1753eb5ea44
https://github.com/mcuadros/ofelia

## Python Server



```sh
pip freeze > requirements.txt
```

```bash
pip install -r requirements.txt
```
22 changes: 22 additions & 0 deletions packages/api/Dockerfile.dev
@@ -0,0 +1,22 @@
FROM node:16-bullseye-slim

RUN apt-get update -y

# RUN apt-get install -y libpq-dev g++ make
# RUN apt-get install -y python3
# RUN npm install -g node-gyp

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install
# RUN node-gyp rebuild -C ./node_modules/argon2
# RUN npm install argon2 --build-from-source

# Bundle app source
COPY . .


EXPOSE 8081
CMD ["npm", "run", "dev"]
16 changes: 16 additions & 0 deletions packages/api/docker-compose.local.yml
@@ -0,0 +1,16 @@
version: '3' # Version of the Docker Compose file format
services:
api:
build:
context: .
dockerfile: Dockerfile.dev
restart: always
volumes:
- ./:/app
- /app/node_modules
- /app/.next
environment:
- VIRTUAL_HOST=api.elemental-sso.local
- VIRTUAL_PORT=8081
- NODE_ENV=development
- APP_ENV=local
8 changes: 8 additions & 0 deletions packages/api/docker-compose.prod.yml
@@ -0,0 +1,8 @@
version: '3'
services:
api:
environment:
- VIRTUAL_HOST=sso-api.elementalzcash.com
- VIRTUAL_PORT=8081
- NODE_ENV=production
- APP_ENV=production
8 changes: 8 additions & 0 deletions packages/api/docker-compose.staging.yml
@@ -0,0 +1,8 @@
version: '3'
services:
api:
environment:
- VIRTUAL_HOST=sso-staging-api.elementalzcash.com
- VIRTUAL_PORT=8081
- NODE_ENV=production
- APP_ENV=staging
22 changes: 22 additions & 0 deletions packages/api/docker-compose.yml
@@ -0,0 +1,22 @@
version: '3'
services:
api:
build: .
environment:
- PORT=8081
networks:
- elemental_net
env_file:
.env
#volumes:
# - ./packages/api:/usr/src/app
# links:
# - redis
# - zecwallet_api
# - database
# depends_on:
# - nginx-proxy
networks:
elemental_net:
external: true
driver: bridge
3 changes: 3 additions & 0 deletions packages/api/package.json
Expand Up @@ -15,6 +15,9 @@
"build": "run-s clean build:js build:types build:sql build:dkim",
"dev": "NODE_ENV=development nodemon --watch src -e ts,ejs --exec npm run dev:start",
"dev:start": "npm-run-all clean build start",
"start:local": "docker compose -f docker-compose.yml -f docker-compose.local.yml up --build",
"start:staging": "docker compose -f docker-compose.yml -f docker-compose.staging.yml up",
"start:prod": "docker compose -f docker-compose.yml -f docker-compose.prod.yml up",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
Expand Down