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

Session auth client #435

Merged
merged 86 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
f67eb52
client request to login
TangoYankee Feb 28, 2022
f46a88b
cors headers
TangoYankee Feb 28, 2022
9c13acc
rest and all auth
TangoYankee Feb 28, 2022
47ca179
email based login
TangoYankee Feb 28, 2022
c65dc88
disable users route
TangoYankee Feb 28, 2022
7b261e0
client sends email data
TangoYankee Feb 28, 2022
74ea508
react types
TangoYankee Feb 28, 2022
9670e69
set token context on login
TangoYankee Feb 28, 2022
bf6cc90
create logout component
TangoYankee Feb 28, 2022
5699c70
lint
TangoYankee Feb 28, 2022
587cd7d
set token on application load
TangoYankee Feb 28, 2022
4278aa8
logout functionality
TangoYankee Feb 28, 2022
526e6b0
react router dom types
TangoYankee Feb 28, 2022
b6f4fd2
auth context to login and out
TangoYankee Feb 28, 2022
01289e0
registration page
TangoYankee Mar 1, 2022
0ebc13e
basic password match feedback
TangoYankee Mar 1, 2022
8913fa6
headers for upload and logout
TangoYankee Mar 1, 2022
6956fe3
loading data for token
TangoYankee Mar 1, 2022
d2b5ebe
auth boundary
TangoYankee Mar 1, 2022
e0c5add
loader for log in and out
TangoYankee Mar 1, 2022
5881670
upgrade to dj-rest-auth
TangoYankee Mar 3, 2022
09f790d
remove TODO for logout feedback
TangoYankee Mar 3, 2022
66580f1
Auth notes
TangoYankee Mar 3, 2022
efd3460
specific cors origins
TangoYankee Mar 4, 2022
e2bae1d
Revert "remove TODO for logout feedback"
TangoYankee Mar 4, 2022
fe07a27
consolidate upload util files
TangoYankee Mar 4, 2022
d22de81
lint
TangoYankee Mar 4, 2022
3ecaa5f
saveCollection as util
TangoYankee Mar 4, 2022
8fc8437
outline error path for uploads
TangoYankee Mar 4, 2022
0602643
Merge branch 'develop' of https://github.com/openoakland/woeip into s…
TangoYankee Mar 13, 2022
1d3d045
revert to simple save collection error handling
TangoYankee Mar 13, 2022
7d76d76
Remove redundant nginx cors settings
TangoYankee Mar 13, 2022
b6e0cbe
document and test authTokenHeaderFormat
TangoYankee Mar 14, 2022
ee3aa4a
lint
TangoYankee Mar 14, 2022
53c848b
remove cancel token from saveCollection
TangoYankee Mar 14, 2022
e741cd1
create isRequestSuccessful utility function
TangoYankee Mar 14, 2022
cf43424
simple registration error handling
TangoYankee Mar 14, 2022
d8346db
simple login error handling
TangoYankee Mar 14, 2022
ada23a2
simple logout error handling
TangoYankee Mar 14, 2022
844c6e6
setloading in login sooner. avoid memory leak
TangoYankee Mar 14, 2022
f72d641
loading screen when registering
TangoYankee Mar 14, 2022
247c6ae
rearrange logout logic. Remove feedback TODO
TangoYankee Mar 14, 2022
a3fec61
add overviews to auth api utility function JSDocs
TangoYankee Mar 14, 2022
9224782
wait for token to load before setting header links
TangoYankee Mar 14, 2022
e893d3f
notes to remove redundant code check from logout
TangoYankee Mar 14, 2022
8ec141a
display alert message on duplicate file upload
TangoYankee Mar 14, 2022
5a43ab0
Rely on unsuccessful logouts always throwing
TangoYankee Mar 14, 2022
f113de1
remove isRequestSuccessful bc of axios validate
TangoYankee Mar 14, 2022
8455f0c
Account for authorization errors when uploading
TangoYankee Mar 14, 2022
2a87c50
welcome component on home and login
TangoYankee Mar 19, 2022
ba7bcb5
login styling
TangoYankee Mar 19, 2022
0b187a4
welcome width
TangoYankee Mar 19, 2022
6a67a55
registration styling
TangoYankee Mar 19, 2022
8eea4aa
logging out phrasing
TangoYankee Mar 19, 2022
e6301dc
redirect to upload on signin
TangoYankee Mar 19, 2022
65b3621
Display "Sign In" to user
TangoYankee Mar 19, 2022
fa5fe73
lint
TangoYankee Mar 19, 2022
da0de2c
Application test
TangoYankee Mar 20, 2022
edb6fe9
Navigation tests
TangoYankee Mar 20, 2022
baaa34c
bar test
TangoYankee Mar 20, 2022
4b0d409
lint
TangoYankee Mar 20, 2022
d86a16f
home test
TangoYankee Mar 20, 2022
0f58ba2
outline auth and save tests
TangoYankee Mar 27, 2022
23c2bf8
token local storage tests
TangoYankee Mar 27, 2022
8f7a11f
lint
TangoYankee Mar 27, 2022
dc0ba50
test login util
TangoYankee Mar 27, 2022
f2e80ed
test logout util
TangoYankee Mar 27, 2022
65b5467
test register util
TangoYankee Mar 27, 2022
f7a5f7b
auth boundary loading and authed tests
TangoYankee Mar 27, 2022
fb30893
unused component from boundary
TangoYankee Mar 27, 2022
71cb783
logout component test
TangoYankee Mar 27, 2022
d00af84
login component tests
TangoYankee Mar 27, 2022
8306186
test register form shape
TangoYankee Mar 27, 2022
bb383d7
Merge branch 'develop' of https://github.com/openoakland/woeip into s…
TangoYankee Mar 30, 2022
b6abaee
remove note for unauthenticated in confirm
TangoYankee Mar 31, 2022
dddd379
upgrade user event
TangoYankee Mar 31, 2022
a6dc2d5
link login and register inputs with labels
TangoYankee Mar 31, 2022
fe4a41e
remove TODO imperative from boundary test
TangoYankee Mar 31, 2022
e34509a
test registration flow
TangoYankee Mar 31, 2022
7a3cf1e
lint
TangoYankee Mar 31, 2022
2beecd5
getCollectionErrorMessage test
TangoYankee Mar 31, 2022
3c28e8a
guard against undefined responses
TangoYankee Mar 31, 2022
9532e83
test save collection
TangoYankee Mar 31, 2022
4d0309a
Merge branch 'develop' of https://github.com/openoakland/woeip into s…
TangoYankee Apr 2, 2022
dbf785a
Merge branch 'develop' of https://github.com/openoakland/woeip into s…
TangoYankee Apr 2, 2022
74206ae
django -> dj rest auth; update prod reqs
TangoYankee Apr 2, 2022
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
9 changes: 9 additions & 0 deletions api/requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ charset-normalizer==2.0.12
coreapi==2.3.3
coreschema==0.0.4
coverage==6.3.2
cryptography==36.0.1
defusedxml==0.7.1
dj-rest-auth==2.2.3
Django==3.2.12
django-allauth==0.49.0
django-boto==0.3.12
django-cors-headers==3.11.0
django-debug-toolbar==3.2.4
django-environ==0.8.1
django-extensions==3.1.5
Expand All @@ -34,19 +39,23 @@ MarkupSafe==2.1.0
mypy==0.931
mypy-extensions==0.4.3
numpy==1.22.2
oauthlib==3.2.0
packaging==21.3
pandas==1.4.1
pluggy==1.0.0
psycopg2-binary==2.9.3
py==1.11.0
pycparser==2.21
PyJWT==2.3.0
pynmea2==1.18.0
pyparsing==3.0.7
pytest==7.0.1
pytest-django==4.5.2
python-dateutil==2.8.2
python3-openid==3.2.0
pytz==2021.3
requests==2.27.1
requests-oauthlib==1.3.1
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.6
six==1.16.0
Expand Down
9 changes: 9 additions & 0 deletions api/requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ cffi==1.15.0
charset-normalizer==2.0.12
coreapi==2.3.3
coreschema==0.0.4
cryptography==36.0.1
defusedxml==0.7.1
dj-rest-auth==2.2.3
Django==3.2.12
django-allauth==0.49.0
django-boto==0.3.12
django-cors-headers==3.11.0
django-environ==0.8.1
django-extensions==3.1.5
django-model-utils==4.2.0
Expand All @@ -24,15 +29,19 @@ itypes==1.2.0
Jinja2==3.0.3
MarkupSafe==2.1.0
numpy==1.22.2
oauthlib==3.2.0
packaging==21.3
pandas==1.4.1
psycopg2-binary==2.9.3
pycparser==2.21
PyJWT==2.3.0
pynmea2==1.18.0
pyparsing==3.0.7
python-dateutil==2.8.2
python3-openid==3.2.0
pytz==2021.3
requests==2.27.1
requests-oauthlib==1.3.1
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.6
six==1.16.0
Expand Down
2 changes: 2 additions & 0 deletions api/woeip/apps/core/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from django import forms
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
33 changes: 29 additions & 4 deletions api/woeip/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"django.contrib.gis",
]

THIRD_PARTY_APPS = ["django_extensions", "rest_framework", "storages", "drf_yasg"]
THIRD_PARTY_APPS = ["corsheaders", "django_extensions", "rest_framework", 'rest_framework.authtoken', "dj_rest_auth", "allauth", 'allauth.account', 'allauth.socialaccount', 'dj_rest_auth.registration', "storages", "drf_yasg"]

LOCAL_APPS = ["woeip.apps.core", "woeip.apps.air_quality"]

Expand All @@ -57,6 +57,7 @@


MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
Expand All @@ -67,6 +68,33 @@
"django.contrib.flatpages.middleware.FlatpageFallbackMiddleware",
]

REST_FRAMEWORK = {
'DATETIME_FORMAT': "%m/%d/%Y %I:%M%P",
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
]
}

AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
)

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'

CORS_ALLOWED_ORIGINS = [
"http://lvh.me",
"https://woaq.org",
"http://localhost:3000",
"http://127.0.0.1:3000",
]

ROOT_URLCONF = "woeip.urls"

TEMPLATES = [
Expand Down Expand Up @@ -192,8 +220,5 @@ def generate_file_handler(filename):
},
}

LOGIN_REDIRECT_URL = "upload"
LOGOUT_REDIRECT_URL = "login"

EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
EMAIL_FILE_PATH = str(project_root.path("sent_emails"))
5 changes: 3 additions & 2 deletions api/woeip/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
router.register(r"pollutant_values", views.PollutantValueViewSet)
router.register(r"sensors", views.SensorViewSet)
router.register(r"timegeo", views.TimeGeoViewSet)
router.register(r"users", core_views.UserViewSet)
# router.register(r"users", core_views.UserViewSet) # Disable to prevent personal information leaking


urlpatterns = [
path("", include(router.urls)),
path("admin/", admin.site.urls),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
path("auth/", include("dj_rest_auth.urls")),
path("auth/register/", include('dj_rest_auth.registration.urls')),
]

urlpatterns += swagger_urlpatterns
Expand Down
3 changes: 1 addition & 2 deletions nginx-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
FROM jwilder/nginx-proxy
ARG API_DOMAIN
COPY cors.conf /etc/nginx/vhost.d/$API_DOMAIN
COPY api_static_assets_routing /etc/nginx/vhost.d/${API_DOMAIN}_location
COPY api_static_assets_routing /etc/nginx/vhost.d/${API_DOMAIN}_location
4 changes: 0 additions & 4 deletions nginx-proxy/cors.conf

This file was deleted.

116 changes: 115 additions & 1 deletion web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
"devDependencies": {
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.7.1",
"@testing-library/user-event": "^12.8.3",
"@types/react": "^17.0.39",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/parser": "^4.15.1",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
Expand Down