Skip to content

Bugfix/484/enable single sign on for react app through people depot #485

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

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
582dfde
Enable CORS for React application
ethanstrominger Oct 16, 2024
dd3fc1c
Partially working, some code commented out
ethanstrominger Nov 26, 2024
4627e3f
Handle jwt decode error,
ethanstrominger Nov 26, 2024
2553707
WIP
ethanstrominger Nov 28, 2024
0c52805
Small changes
ethanstrominger Nov 30, 2024
e94bfd6
Resolve views.py conflict
ethanstrominger Nov 30, 2024
83082c8
Merge branch 'main' of https://github.com/hackforla/peopledepot into …
ethanstrominger Nov 30, 2024
884e8d4
Change post to patch
ethanstrominger Nov 30, 2024
319ae56
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2024
72f72dc
Changes to support React
ethanstrominger Nov 30, 2024
e1de3dc
Changes for CORS so REACT works
ethanstrominger Nov 30, 2024
3e96aaf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2024
1c31653
Add blank line
ethanstrominger Nov 30, 2024
dd4036b
Merge branch 'cors' of https://github.com/ethanstrominger/peopledepot…
ethanstrominger Nov 30, 2024
6b233c9
Revert changes to files related to /login local
ethanstrominger Dec 1, 2024
698a3eb
Merge branch 'cors' of https://github.com/ethanstrominger/peopledepot…
ethanstrominger Dec 1, 2024
dc5b878
Remove /login API implementation
ethanstrominger Dec 1, 2024
dddcb7c
Restore jwt.py
ethanstrominger Dec 1, 2024
ace3579
Restore update-table.md
ethanstrominger Dec 1, 2024
368e92a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2024
6d69f40
Restore jwt.py
ethanstrominger Dec 1, 2024
f6e880f
Merge branch 'cors' of https://github.com/ethanstrominger/peopledepot…
ethanstrominger Dec 1, 2024
ac7bb08
Remove duplicate env variable in .env.docker-example
ethanstrominger Dec 1, 2024
9cc11eb
Restore docker-compose.yml
ethanstrominger Dec 1, 2024
ddfe984
Remove unused import
ethanstrominger Dec 1, 2024
ed177de
pre-commit and update-table.md
ethanstrominger Dec 1, 2024
1909194
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2024
8e1f7db
Try to fix update-table.md hanging space
ethanstrominger Dec 1, 2024
c18fe5d
Merge branch 'cors' of https://github.com/ethanstrominger/peopledepot…
ethanstrominger Dec 1, 2024
c75db16
Fix trailing whitespace
ethanstrominger Dec 1, 2024
775d753
Modify to tricker pre-commit
ethanstrominger Dec 1, 2024
0d70d8f
Update graphviz
ethanstrominger Dec 18, 2024
8d9bd82
Squashed commit of the following:
ethanstrominger Dec 19, 2024
8a73893
Merge branch 'cors' of https://github.com/ethanstrominger/peopledepot…
ethanstrominger Dec 19, 2024
2924fb9
Squashed commit of the following:
ethanstrominger Dec 19, 2024
302df99
Merge branch 'main' of https://github.com/hackforla/peopledepot
ethanstrominger Dec 23, 2024
e1fa593
Merge main from pd
ethanstrominger Dec 27, 2024
6482739
Merge branch 'main' into bugfix/484/Enable-single-sign-on-for-React-a…
ethanstrominger Mar 18, 2025
af890a0
Modify after merge, update requirements.in
ethanstrominger Mar 18, 2025
3fd27fc
Merge branch 'main' of https://github.com/hackforla/peopledepot
ethanstrominger Mar 18, 2025
97236e6
Merge branch 'main' into bugfix/484/Enable-single-sign-on-for-React-a…
ethanstrominger Mar 18, 2025
71307b0
Fix reference to jwt
ethanstrominger Mar 22, 2025
15a6106
Changed .env.docker-example
ethanstrominger Mar 25, 2025
af172ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/update-table.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Update Table
about: Describe this issue template's purpose here.
about: Describe the purpose of the template here.
title: 'Update Table: [TABLE NAME]'
labels: 'feature: update table, good first issue, milestone: missing, role: back end, size: 0.25pt, stakeholder: missing'
assignees: ''
Expand Down
43 changes: 13 additions & 30 deletions app/.env.docker-example
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,23 @@ DJANGO_SUPERUSER_USERNAME=admin1111
[email protected]
DJANGO_SUPERUSER_PASSWORD=admin

# settings for db container environment variables in compose file
POSTGRES_USER=people_depot
POSTGRES_PASSWORD=people_depot
POSTGRES_DB=people_depot_dev
CORS_ALLOWED_ORIGINS="http://localhost:3000 https://your-production-server.com"

# postgres settings for docker
SQL_USER=$POSTGRES_USER
SQL_PASSWORD=$POSTGRES_PASSWORD
SQL_DATABASE=$POSTGRES_DB
# used in DATABASES configuration in settings.py
SQL_ENGINE=django.db.backends.postgresql
SQL_DATABASE=people_depot_dev
SQL_USER=people_depot
SQL_PASSWORD=people_depot
SQL_HOST=db
SQL_PORT=5432
DATABASE=postgres

# postgres settings for local development
# SQL_ENGINE=django.db.backends.postgresql
# SQL_DATABASE=postgres
# SQL_USER=
# SQL_PASSWORD=
# SQL_HOST=localhost
# SQL_PORT=5432
# DATABASE=postgres
# used by docker
POSTGRES_DB: $SQL_DATABASE
POSTGRES_USER: $SQL_USER
POSTGRES_PASSWORD: $SQL_PASSWORD

# sqlite settings for local development
# SQL_ENGINE=
# SQL_DATABASE=
# SQL_USER=
# SQL_PASSWORD=
# SQL_HOST=
# SQL_PORT=
# DATABASE=

COGNITO_DOMAIN=peopledepot
COGNITO_AWS_REGION=us-west-2
COGNITO_USER_POOL=us-west-2_Fn4rkZpuB

PEOPLE_DEPOT_API_SECRET=people-depot-api-secret
# Define below if using COGNITO
# COGNITO_DOMAIN=peopledepot
# COGNITO_AWS_REGION=us-west-2
# COGNITO_USER_POOL=us-west-2_Fn4rkZpuB
17 changes: 17 additions & 0 deletions app/core/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from rest_framework.mixins import RetrieveModelMixin
from rest_framework.permissions import IsAuthenticated
from rest_framework.permissions import IsAuthenticatedOrReadOnly
from rest_framework.response import Response

from ..models import Affiliate
from ..models import Affiliation
Expand Down Expand Up @@ -69,6 +70,22 @@ def get(self, request, *args, **kwargs):
"""
return self.retrieve(request, *args, **kwargs)

def patch(self, request, *args, **kwargs):
"""
Update the profile of the current logged-in user.
"""
user = self.get_object() # Get the logged-in user
serializer = self.serializer_class(user, data=request.data, partial=True)

if serializer.is_valid():
# Save the updated user data
serializer.save()
return Response({"data": serializer.data}) # Return the updated user data

return Response(
serializer.errors, status=400
) # Return validation errors if invalid data


@extend_schema_view(
list=extend_schema(
Expand Down
16 changes: 16 additions & 0 deletions app/peopledepot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
# Application definition

INSTALLED_APPS = [
"corsheaders",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
Expand All @@ -81,6 +82,7 @@
# 3rd party
"django_extensions",
"rest_framework",
"rest_framework.authtoken",
"drf_spectacular",
"phonenumber_field",
"timezone_field",
Expand All @@ -90,7 +92,21 @@
"data",
]

# Allow specific origins (like your React dev and production URLs)
CORS_ALLOWED_ORIGINS = os.getenv("CORS_ALLOWED_ORIGINS").split(" ")

# Optional: Allow credentials (for cookies or tokens)
CORS_ALLOW_CREDENTIALS = True

# Optional: Control which headers are allowed
CORS_ALLOW_HEADERS = [
"Authorization",
"Content-Type",
]


MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
Expand Down
1 change: 1 addition & 0 deletions app/requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
django~=4.2.0
django-cors-headers
django-extensions
django-linear-migrations
django-phonenumber-field[phonenumbers]
Expand Down
36 changes: 21 additions & 15 deletions app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
asgiref==3.8.1
# via django
attrs==24.2.0
# via
# django
# django-cors-headers
attrs==25.3.0
# via
# jsonschema
# referencing
cffi==1.17.1
# via cryptography
coverage==7.6.8
coverage==7.7.0
# via pytest-cov
cryptography==44.0.0
cryptography==44.0.2
# via pyjwt
django==4.2.16
django==4.2.20
# via
# django-cors-headers
# django-extensions
# django-linear-migrations
# django-phonenumber-field
# django-timezone-field
# djangorestframework
# drf-jwt
# drf-spectacular
django-cors-headers==4.7.0
django-extensions==3.2.3
django-linear-migrations==2.16.0
django-linear-migrations==2.17.0
django-phonenumber-field==8.0.0
django-timezone-field==7.0
django-timezone-field==7.1
djangorestframework==3.15.2
# via
# drf-jwt
Expand All @@ -44,7 +48,7 @@ jsonschema-specifications==2024.10.1
markdown==3.7
packaging==24.2
# via pytest
phonenumbers==8.13.51
phonenumbers==9.0.1
# via django-phonenumber-field
pluggy==1.5.0
# via pytest
Expand All @@ -53,32 +57,34 @@ pycparser==2.22
# via cffi
pyjwt==2.10.1
# via drf-jwt
pytest==8.3.4
pytest==8.3.5
# via
# pytest-cov
# pytest-django
# pytest-xdist
pytest-cov==6.0.0
pytest-django==4.9.0
pytest-django==4.10.0
pytest-xdist==3.6.1
pyyaml==6.0.2
# via drf-spectacular
referencing==0.35.1
referencing==0.36.2
# via
# jsonschema
# jsonschema-specifications
rpds-py==0.22.1
rpds-py==0.23.1
# via
# jsonschema
# referencing
sqlparse==0.5.2
sqlparse==0.5.3
# via django
tomli==2.2.1
# via
# coverage
# pytest
typing-extensions==4.12.2
# via asgiref
tzdata==2024.2
# via
# asgiref
# referencing
tzdata==2025.1
uritemplate==4.1.1
# via drf-spectacular