-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for github. Handle no refresh_token and no expire
- Loading branch information
Showing
21 changed files
with
206 additions
and
111 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 |
---|---|---|
|
@@ -4,5 +4,6 @@ node_modules | |
log.txt | ||
/yarn.lock | ||
/src/react-app-env.d.ts | ||
/tsconfig.json | ||
/src/yarn.lock | ||
.env | ||
__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,20 @@ | ||
version: "3.8" | ||
|
||
services: | ||
api: | ||
build: ./github-auth-proxy | ||
restart: unless-stopped | ||
volumes: | ||
- ./github-auth-proxy:/code | ||
environment: | ||
CLIENT_ID: c43524cc7d3c82b05a47 | ||
CLIENT_SECRET: ${CLIENT_SECRET} | ||
ports: | ||
- "5000:5000" | ||
web: | ||
build: ./web-app | ||
restart: unless-stopped | ||
volumes: | ||
- ./web-app/src:/app/src | ||
ports: | ||
- "3000:3000" |
19 changes: 19 additions & 0 deletions
19
examples/github-auth-provider/github-auth-proxy/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,19 @@ | ||
FROM python:3.10-slim | ||
WORKDIR /code | ||
EXPOSE 5000 | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
ENV PYTHONPATH=/code | ||
|
||
RUN pip install --upgrade pip && \ | ||
pip install poetry && \ | ||
poetry config virtualenvs.create false | ||
|
||
COPY pyproject.toml pyproject.toml | ||
COPY poetry.lock poetry.lock | ||
|
||
RUN poetry install | ||
COPY . . | ||
USER 1000 | ||
CMD ["python", "api.py"] | ||
|
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,49 @@ | ||
import os | ||
|
||
import requests | ||
import uvicorn | ||
from fastapi import FastAPI, Form | ||
from fastapi.middleware.cors import CORSMiddleware | ||
|
||
origins = [ | ||
"http://localhost:3000", | ||
] | ||
|
||
|
||
def create_app() -> FastAPI: | ||
app = FastAPI() | ||
|
||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=origins, | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"], | ||
) | ||
|
||
@app.post("/api/token") | ||
def get_github_token(code: str = Form()): | ||
parameters = { | ||
"client_id": os.getenv("CLIENT_ID"), | ||
"client_secret": os.getenv("CLIENT_SECRET"), | ||
"code": code | ||
} | ||
response = requests.post( | ||
"https://github.com/login/oauth/access_token", | ||
params=parameters, | ||
headers={"Accept": "application/json"} | ||
) | ||
response.raise_for_status() | ||
return response.json() | ||
|
||
return app | ||
|
||
|
||
if __name__ == "__main__": | ||
uvicorn.run( | ||
"api:create_app", | ||
host="0.0.0.0", | ||
port=5000, | ||
reload=True, | ||
log_level='debug', | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
Binary file removed
BIN
-1.25 KB
examples/react-app/github-auth-proxy/__pycache__/api.cpython-310.pyc
Binary file not shown.
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
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
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
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
Oops, something went wrong.