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

Django upgrade #242

Merged
merged 94 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
32e8d30
comment out auth and deprecated tests
David-Strupinski Mar 29, 2023
3b502f8
disable auth
David-Strupinski Mar 29, 2023
cb2ea85
fully remove auth
David-Strupinski Mar 29, 2023
673b58c
update to django 2.0.*
David-Strupinski Apr 4, 2023
a5bda63
fix ForeignKey fields in models
David-Strupinski Apr 4, 2023
983b4dd
update url patterns to new syntax
David-Strupinski Apr 4, 2023
f59ada0
remove django prometheus
David-Strupinski Apr 4, 2023
0be54bf
upgrade to django 2.2.*
David-Strupinski Apr 4, 2023
5141543
add django-oauth-toolkit auth, tests don't pass
David-Strupinski Apr 6, 2023
95707bd
add migrations back, problem with new Client persists
David-Strupinski Apr 6, 2023
3c8c3db
fix migration problem, tests still don't pass
David-Strupinski Apr 6, 2023
36758cf
remove Favorites
David-Strupinski Apr 7, 2023
e3bd137
remove reviews, ratings
David-Strupinski Apr 7, 2023
aa590c9
remove shared spaces
David-Strupinski Apr 7, 2023
a7f1acd
apply migrations
David-Strupinski Apr 7, 2023
c9fb3be
Seeing if this will even run on ubuntu 20.04
abztrakt Apr 11, 2023
98a8be0
update copyright year
David-Strupinski Apr 11, 2023
7c79a81
update copyright on non-checked files
David-Strupinski Apr 11, 2023
41b347e
Ubuntu 18 does not work anymore
abztrakt Apr 11, 2023
25ce5b4
Load spottypes
abztrakt Apr 11, 2023
1d54a48
Merge branch 'django-upgrade' into task/oauth-change
David-Strupinski Apr 13, 2023
b2541db
merge migrations
David-Strupinski Apr 13, 2023
761c355
comment out last of old auth, passes testts
David-Strupinski Apr 13, 2023
6444cf1
remove user_auth_required comments
David-Strupinski Apr 18, 2023
3d8fefa
update dummy fixture to use new client
David-Strupinski Apr 18, 2023
ecf9299
ignore vscode files
David-Strupinski Apr 20, 2023
fcc63b5
move admin site out of debug
David-Strupinski Apr 20, 2023
8f8c668
remove old comment
David-Strupinski Apr 20, 2023
e5ec3a5
update client
David-Strupinski Apr 20, 2023
0eb6d4b
lowercase all REST calls
David-Strupinski Apr 20, 2023
7005c13
add oauth2 endpoint views
David-Strupinski Apr 20, 2023
44bb481
pin django-cors-headers version
David-Strupinski May 8, 2023
cec1be9
remove access token field from Client model
David-Strupinski May 8, 2023
6a3e3d2
add register application command
David-Strupinski May 8, 2023
a992dce
add scoped oauth to views
David-Strupinski May 8, 2023
a7fe613
cleanup unused imports
David-Strupinski May 8, 2023
0789e60
update Dockerfile container version
David-Strupinski Jun 9, 2023
0560ab6
add option to show credential when registering app
David-Strupinski Jun 15, 2023
9532a23
fix scope checking
David-Strupinski Jun 21, 2023
3cb9b5a
remove unnecessary setting
David-Strupinski Jun 21, 2023
6e9b16c
make scope be validated only when oauth enabled
David-Strupinski Jun 21, 2023
8d7419c
fix old GET calls
David-Strupinski Jun 21, 2023
40f2cd3
remove unnecessary code from spot_put tests
David-Strupinski Jun 22, 2023
2c3a2a9
fix spot item put tests
David-Strupinski Jun 22, 2023
0813923
remove unused imports
David-Strupinski Jun 26, 2023
8120048
move resources folder
David-Strupinski Jun 26, 2023
a4d5cab
fix create sample spots
David-Strupinski Jun 26, 2023
037dbeb
fix allowed origins
David-Strupinski Jul 5, 2023
9edc812
remove old auth files, move oauth test file
David-Strupinski Jun 27, 2023
8dedb1f
fix create_consumer for new auth
David-Strupinski Jun 27, 2023
c4facc4
remove old auth tests
David-Strupinski Jun 27, 2023
c8e5747
change spotseeker oauth setting
David-Strupinski Jun 27, 2023
0b61f79
convert oauth override in tests
David-Strupinski Jun 27, 2023
a9fbd6a
remove unicode method
David-Strupinski Jun 27, 2023
1732caa
add expired token check in dispatch
David-Strupinski Jun 29, 2023
78cb4a9
remove unnecessary default
David-Strupinski Jun 29, 2023
f9dc67e
add doc to get_client_credentials()
David-Strupinski Jun 29, 2023
c8ded8d
fix oauth test
David-Strupinski Jun 29, 2023
272c463
remove unnecessary oauth test
David-Strupinski Jun 29, 2023
c5a41fc
remove OAUTH_ENABLED as an ENV var
David-Strupinski Jun 30, 2023
74b15de
remove TrustedOAuthClient
David-Strupinski Jun 29, 2023
c63e19d
remove old model from fixture
David-Strupinski Jun 29, 2023
8292a11
allow oauth to be enabled on debug
David-Strupinski Aug 2, 2023
5af250a
make a sample spot a study spot
David-Strupinski Aug 8, 2023
8dda308
allow spots to be updated to study spots
David-Strupinski Aug 8, 2023
71327e3
Merge pull request #217 from uw-it-aca/develop
abztrakt Aug 15, 2023
267b378
Merge pull request #213 from uw-it-aca/task/oauth-change
abztrakt Aug 15, 2023
89e2c15
Add extensions so we can do a sqldiff
abztrakt Oct 10, 2023
fdacfc7
add extra techloan office to sample spots
David-Strupinski Nov 14, 2023
001aa64
add on_delete=models.CASCADE to all foreign keys
David-Strupinski Nov 21, 2023
5910de8
squash migrations
David-Strupinski Nov 21, 2023
7319e65
Restore dev-values.yml
abztrakt Nov 21, 2023
2a00741
Merge pull request #228 from uw-it-aca/task/prep-upgrade
abztrakt Nov 21, 2023
7965fdd
Re-add (again) dev-values and update cicd to use it
abztrakt Nov 21, 2023
b41422b
Merge pull request #231 from uw-it-aca/task/prep-upgrade
abztrakt Nov 21, 2023
ffc54bd
Merge branch 'feature/eval-me' into django-upgrade
abztrakt Nov 21, 2023
7648be1
Remove bad squashed migration
abztrakt Nov 21, 2023
4a4862f
Revert "Merge branch 'feature/eval-me' into django-upgrade"
David-Strupinski Nov 21, 2023
bc82cb2
Merge pull request #232 from uw-it-aca/django-upgrade
abztrakt Nov 21, 2023
015d573
Add these guys again?!
abztrakt Nov 21, 2023
9e0bd76
Fix prometheus 404s again?
abztrakt Nov 22, 2023
9b679af
Base settings have important stuff
abztrakt Nov 22, 2023
0666a10
Merge pull request #233 from uw-it-aca/feature/eval-me
abztrakt Nov 28, 2023
a37a584
set secret refresh interval lower on dev
abztrakt Feb 5, 2024
a2d306c
update UW copyright year
David-Strupinski Feb 5, 2024
1d70f65
refresh interval on the external, not environment secrets
abztrakt Feb 5, 2024
10b6121
refresh interval on the external secret
abztrakt Feb 5, 2024
d93840e
Back to default refresh interval
abztrakt Feb 6, 2024
bf7f464
fix migrations to let 6-8 work on develop
David-Strupinski Mar 4, 2024
4f4c8f6
simplify migrations
David-Strupinski Mar 4, 2024
d5debda
remove unused imports
David-Strupinski Mar 4, 2024
cf1ec49
Merge pull request #239 from uw-it-aca/fix-migrations
abztrakt Apr 2, 2024
a486f8e
update license headers and remove unneeded files
David-Strupinski Mar 1, 2024
a21b1a3
Merge branch 'temp-develop' into django-upgrade
abztrakt Apr 2, 2024
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/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ jobs:
commit_hash: ${{ needs.context.outputs.commit_hash }}
git_repo_branch: ${{ needs.context.outputs.git_repo_branch }}
gh_auth_token: ${{ secrets.GH_AUTH_TOKEN }}
app_instance: eval
app_instance: dev

- name: 'Surface context from executed build step'
id: context
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ spotseeker_web
# IDE files
.idea/

# vscode files
.vscode/

# pipenv
Pipfile
Pipfile.lock
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG DJANGO_CONTAINER_VERSION=1.3.8
ARG DJANGO_CONTAINER_VERSION=1.4.1

FROM gcr.io/uwit-mci-axdd/django-container:${DJANGO_CONTAINER_VERSION} as app-container

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "${PORT:-8000}:8000"
environment:
ENV: localdev
AUTH_MODULE: ${AUTH_MODULE:-all_ok}
SPOTSEEKER_OAUTH_ENABLED: ${SPOTSEEKER_OAUTH_ENABLED}
SPOTSEEKER_AUTH_ADMINS: ${SPOTSEEKER_AUTH_ADMINS}
SPOTSEEKER_WEB_SERVER_HOST: ${SPOTSEEKER_WEB_SERVER_HOST}
SPOTSEEKER_WEB_OAUTH_KEY: ${SPOTSEEKER_WEB_OAUTH_KEY}
Expand Down
156 changes: 156 additions & 0 deletions docker/dev-values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 1
ingress:
enabled: true
tls:
spotseeker:
secretName: dev.api.scout.uw.edu-ingress-cert
hosts:
- dev.api.scout.uw.edu
hosts:
spotseeker:
host: dev.api.scout.uw.edu
paths:
- "/"
annotations:
cert-manager.io/cluster-issuer: letsencrypt
nginx.ingress.kubernetes.io/client-body-buffer-size: "16K"
nginx.ingress.kubernetes.io/proxy-body-size: "20m"
nginx.ingress.kubernetes.io/proxy-read-timeout: "500"
nginx.ingress.kubernetes.io/ssl-ciphers: "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256"
lifecycle:
enabled: true
preStop:
enabled: true
affinity:
podsSpanNodes: true
readiness:
enabled: true
securityPolicy:
enabled: true
externalService:
enabled: true
name: spotseeker-dev-db-service
type: ClusterIP
serviceAddress: 172.18.0.196
servicePort: 3306
database:
engine: mysql
name: api_dev
hostname: spotseeker-dev-db-service
secretName: dev.api.scout.uw.edu-sql-secrets
repo: spotseeker
instance: dev
image:
repository: gcr.io/uwit-mci-axdd/spotseeker
tag: IMAGE_TAG
memcached:
enabled: true
replicaCount: 1
updateStrategy:
type: RollingUpdate
gcsCredentials:
mounted: true
secretName: dev.api.scout.uw.edu-gc-service-credentials
cronjob:
enabled: false
jobs:
- name: sync-techloan
schedule: "0,15,30,45 * * * *"
command: ["/scripts/management_command.sh"]
args: ["sync_techloan"]
daemon:
enabled: false # cronjob is probably more appropriate
daemons:
- name: sync-techloan
replicaCount: 1
command: ["/scripts/management_daemon.sh"]
args: ["--delay", "300", "sync_techloan"]
environmentVariables:
- name: AUTH_MODULE
value: oauth
- name: CLUSTER_CNAME
value: dev.api.scout.uw.edu
- name: ENV
value: dev
- name: WEBSERVER
value: nginx
- name: CACHE_MAX_ENTRIES
value: "1000"
- name: CACHE_TIMEOUT
value: "86400"
externalSecrets:
enabled: true
secrets:
- name: dev.api.scout.uw.edu-secrets
externalKey: axdd/kv/data/scout/dev-api/secrets
data:
- name: django-secret
property: django-secret
- name: spotseeker-auth-admins
property: spotseeker-auth-admins
- name: storage-bucket-name
property: storage-bucket-name
- name: storage-project-id
property: storage-project-id
- name: spotseeker-techloan-url
property: spotseeker-techloan-url
- name: spotseeker-web-server-host
property: spotseeker-web-server-host
- name: spotseeker-web-oauth-key
property: spotseeker-web-oauth-key
- name: spotseeker-web-oauth-secret
property: spotseeker-web-oauth-secret
- name: spotseeker-web-oauth-user
property: spotseeker-web-oauth-user
- name: dev.api.scout.uw.edu-sql-secrets
externalKey: axdd/kv/data/scout/common/sql-secrets
data:
- name: username
property: username
- name: password
property: password
- name: dev.api.scout.uw.edu-gc-service-credentials
externalKey: axdd/kv/data/scout/common/gc-service-credentials
data:
- name: credentials.json
property: credentials.json
environmentVariablesSecrets:
djangoSecret:
name: DJANGO_SECRET
secretName: dev.api.scout.uw.edu-secrets
secretKey: django-secret
spotseekerAuthAdmins:
name: SPOTSEEKER_AUTH_ADMINS
secretName: dev.api.scout.uw.edu-secrets
secretKey: spotseeker-auth-admins
storageBucketName:
name: STORAGE_BUCKET_NAME
secretName: dev.api.scout.uw.edu-secrets
secretKey: storage-bucket-name
storageProjectId:
name: STORAGE_PROJECT_ID
secretName: dev.api.scout.uw.edu-secrets
secretKey: storage-project-id
spotseekerTechloanUrl:
name: SPOTSEEKER_TECHLOAN_URL
secretName: dev.api.scout.uw.edu-secrets
secretKey: spotseeker-techloan-url
spotseekerWebServerHost:
name: SPOTSEEKER_WEB_SERVER_HOST
secretName: dev.api.scout.uw.edu-secrets
secretKey: spotseeker-web-server-host
spotseekerWebOauthKey:
name: SPOTSEEKER_WEB_OAUTH_KEY
secretName: dev.api.scout.uw.edu-secrets
secretKey: spotseeker-web-oauth-key
spotseekerWebOauthSecret:
name: SPOTSEEKER_WEB_OAUTH_SECRET
secretName: dev.api.scout.uw.edu-secrets
secretKey: spotseeker-web-oauth-secret
spotseekerWebOauthUser:
name: SPOTSEEKER_WEB_OAUTH_USER
secretName: dev.api.scout.uw.edu-secrets
secretKey: spotseeker-web-oauth-user
4 changes: 2 additions & 2 deletions docker/prod-values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ daemon:
command: ["/scripts/management_daemon.sh"]
args: ["--delay", "300", "sync_techloan"]
environmentVariables:
- name: AUTH_MODULE
value: oauth
- name: SPOTSEEKER_OAUTH_ENABLED
value: true
- name: CLUSTER_CNAME
value: api.scout.uw.edu
- name: ENV
Expand Down
34 changes: 29 additions & 5 deletions docker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,35 @@
DEBUG = False

INSTALLED_APPS += [
"oauth_provider",
"spotseeker_server",
"oauth2_provider",
"corsheaders",
]

MIDDLEWARE += [
"spotseeker_server.logger.oauth.LogMiddleware",
"corsheaders.middleware.CorsMiddleware",
]

AUTH_USER_MODEL = "spotseeker_server.Client"

AUTHENTICATION_BACKENDS = (
"oauth2_provider.backends.OAuth2Backend",
"django.contrib.auth.backends.ModelBackend",
)

CORS_ORIGIN_ALLOW_ALL = DEBUG
if os.getenv("ENV", "localdev") == "prod":
CORS_ALLOWED_ORIGINS = [
"https://scout.uw.edu",
"https://manager.scout.uw.edu",
]
else:
CORS_ALLOWED_ORIGINS = [
"https://test.scout.uw.edu",
"https://test.manager.scout.uw.edu",
]

# django storages settings
if not DEBUG:
DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
Expand All @@ -27,9 +48,11 @@
"/gcs/credentials.json"
)

SPOTSEEKER_AUTH_MODULE = "spotseeker_server.auth.{}".format(
os.getenv("AUTH_MODULE", "all_ok")
)
SPOTSEEKER_OAUTH_ENABLED = os.getenv("SPOTSEEKER_OAUTH_ENABLED", not DEBUG)
# convert string to boolean if set in .env
if type(SPOTSEEKER_OAUTH_ENABLED) == str:
SPOTSEEKER_OAUTH_ENABLED = SPOTSEEKER_OAUTH_ENABLED.lower() == "true"

# turn string of auth admins into list
SPOTSEEKER_AUTH_ADMINS = (
os.getenv("SPOTSEEKER_AUTH_ADMINS", "").replace(" ", "").split(",")
Expand Down Expand Up @@ -59,7 +82,8 @@
}
}
else:
# The various MEMCACHED variables are set in django-container's base_settings/common.py
# The various MEMCACHED variables are set in django-container's
# base_settings/common.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
Expand Down
4 changes: 2 additions & 2 deletions docker/test-values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ daemon:
command: ["/scripts/management_daemon.sh"]
args: ["--delay", "300", "sync_techloan"]
environmentVariables:
- name: AUTH_MODULE
value: oauth
- name: SPOTSEEKER_OAUTH_ENABLED
value: true
- name: CLUSTER_CNAME
value: test.api.scout.uw.edu
- name: ENV
Expand Down
34 changes: 12 additions & 22 deletions docker/urls.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
"""docker URL Configuration
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from .base_urls import *
from django.conf import settings
from django.conf.urls import url, include
from django.urls import path, include
from django.contrib import admin

urlpatterns = [
url(r'^auth/', include('oauth_provider.urls')),
url(r'^api/', include('spotseeker_server.urls')),
url(r'^', include('django_prometheus.urls')), # add here for django 1.11 compatibility
urlpatterns += [
path("api/", include("spotseeker_server.urls")),
path(
"auth/", include("oauth2_provider.urls", namespace="oauth2_provider")
),
]

if settings.DEBUG:
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns += [
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
path("admin/doc/", include("django.contrib.admindocs.urls")),
path("admin/", admin.site.urls),
]

urlpatterns += staticfiles_urlpatterns()
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# these two can be upgraded when django gets an update
mysqlclient~=1.3
django-prometheus~=2.0
# this is temporary for testing migrations in upgrade
django-extensions==2.2.*
-e .
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
10 changes: 6 additions & 4 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# Port to connect to with your browser
#PORT=8001

# Whether to use all_ok (default) or oauth auth module
#AUTH_MODULE=oauth

# Comma separated list of admins
#SPOTSEEKER_AUTH_ADMINS=javerage,demo_user

# enabled oauth (True or False)
#SPOTSEEKER_OAUTH_ENABLED=True

# URL to sync techloan from sync_techloan management command
#SPOTSEEKER_TECHLOAN_URL=https://EXAMPLE_DOMAIN/techloan/api/v2/type/?embed=availability&embed=class
#SPOTSEEKER_TECHLOAN_URL=https://EXAMPLE_DOMAIN/techloan/api/v2/type/?embed=availability&embed=class

#ENV=localdev
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
version="1.0",
description="REST Backend for SpaceScout",
install_requires=[
"Django==1.11.*",
"Django==2.2.*",
"future",
"mock<=1.0.1",
"oauthlib==3.1.*",
"django-oauth-toolkit",
"django-cors-headers==3.10.*",
"requests==2.26.*",
"requests-oauthlib==1.3.*",
"Pillow",
"pylibmc", # switch to what django-container uses upon upgrade
"pyproj",
"pytz",
"simplejson>=2.1",
"django-oauth-plus@git+https://github.com/edx-unsupported/django-oauth-plus#egg=2.2.9.edx-4",
"django-storages[google]",
"schema",
"six",
Expand Down
6 changes: 2 additions & 4 deletions spotseeker_server/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
[email protected]: use the same forms as used for REST.
"""

from importlib import import_module
from django.db import models
from django.contrib import admin
from django.conf import settings
from django.contrib.auth.admin import UserAdmin
from spotseeker_server.models import *
from spotseeker_server.forms.spot import SpotForm, SpotExtendedInfoForm
from spotseeker_server.forms.item import ItemForm, ItemExtendedInfoForm
Expand Down Expand Up @@ -117,7 +115,7 @@ class SpotExtendedInfoAdmin(admin.ModelAdmin):


admin.site.register(SpotType)
admin.site.register(TrustedOAuthClient)
admin.site.register(Client, UserAdmin)


class ItemAdmin(admin.ModelAdmin):
Expand Down
Empty file removed spotseeker_server/auth/__init__.py
Empty file.
Loading
Loading