Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
21
Issues
21
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
go
Commits
3749c917
Commit
3749c917
authored
Dec 31, 2018
by
David Haynes
🙆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fuck token auth we session auth now boyssssssssssss
parent
e14d8cc3
Pipeline
#3567
passed with stage
in 1 minute and 13 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
176 deletions
+110
-176
go/go_ahead/src/Components/Pages/DebugCRUD.jsx
go/go_ahead/src/Components/Pages/DebugCRUD.jsx
+2
-2
go/go_ahead/src/Utils/GetAllGoLinks.js
go/go_ahead/src/Utils/GetAllGoLinks.js
+6
-2
go/go_ahead/src/Utils/Routes.jsx
go/go_ahead/src/Utils/Routes.jsx
+9
-52
go/go_back/views.py
go/go_back/views.py
+1
-1
go/settings/settings.py
go/settings/settings.py
+92
-119
No files found.
go/go_ahead/src/Components/Pages/DebugCRUD.jsx
View file @
3749c917
...
...
@@ -16,11 +16,11 @@ const SignupSchema = Yup.object().shape({
class
DebugCRUD
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
AllGoLinks
:
""
,
error
:
null
};
this
.
state
=
{
AllGoLinks
:
[]
,
error
:
null
};
}
async
componentDidMount
()
{
GetAllGoLinks
(
this
.
props
.
authToken
)
GetAllGoLinks
()
.
then
(
data
=>
this
.
setState
({
AllGoLinks
:
data
...
...
go/go_ahead/src/Utils/GetAllGoLinks.js
View file @
3749c917
async
function
GetAllGoLinks
(
token
)
{
let
response
=
await
fetch
(
"
/auth/token
"
);
async
function
GetAllGoLinks
()
{
let
response
=
await
fetch
(
"
/api/golinks/
"
,
{
headers
:
{
"
Content-Type
"
:
"
application/json
"
}
});
let
data
=
await
response
.
json
();
return
data
;
}
...
...
go/go_ahead/src/Utils/Routes.jsx
View file @
3749c917
...
...
@@ -10,57 +10,14 @@ import {
const
NavBarWithRouter
=
withRouter
(
props
=>
<
NavBar
{
...
props
}
/>);
class
Routes
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
error
:
null
,
authToken
:
null
};
}
componentDidMount
()
{
fetch
(
"
/auth/token
"
)
.
then
(
res
=>
res
.
json
())
.
then
(
result
=>
{
this
.
setState
({
authToken
:
result
.
token
});
},
error
=>
{
this
.
setState
({
error
});
}
);
}
render
()
{
const
{
authToken
}
=
this
.
state
;
return
(
<
div
>
<
NavBarWithRouter
/>
<
Route
path
=
"/"
exact
render
=
{
props
=>
<
HomePage
{
...
props
}
authToken
=
{
authToken
}
/>
}
/>
<
Route
path
=
"/dhaynes"
render
=
{
props
=>
<
DhaynesPage
{
...
props
}
authToken
=
{
authToken
}
/>
}
/>
<
Route
path
=
"/about"
render
=
{
props
=>
<
AboutPage
{
...
props
}
authToken
=
{
authToken
}
/>
}
/>
<
Route
path
=
"/debug"
render
=
{
props
=>
<
DebugCRUD
{
...
props
}
authToken
=
{
authToken
}
/>
}
/>
</
div
>
);
}
}
const
Routes
=
()
=>
(
<
div
>
<
NavBarWithRouter
/>
<
Route
path
=
"/"
exact
component
=
{
HomePage
}
/>
<
Route
path
=
"/dhaynes"
component
=
{
DhaynesPage
}
/>
<
Route
path
=
"/about"
component
=
{
AboutPage
}
/>
<
Route
path
=
"/debug"
component
=
{
DebugCRUD
}
/>
</
div
>
);
export
default
Routes
;
go/go_back/views.py
View file @
3749c917
...
...
@@ -34,7 +34,7 @@ class URLViewSet(viewsets.ModelViewSet):
API endpoint that handles creation/read/update/deletion of URL objects.
"""
authentication_classes
=
(
TokenAuthentication
,)
authentication_classes
=
(
TokenAuthentication
,
SessionAuthentication
)
serializer_class
=
URLSerializer
permission_classes
=
(
URLPermission
,
IsAuthenticated
)
lookup_field
=
"short"
...
...
go/settings/settings.py
View file @
3749c917
...
...
@@ -8,21 +8,14 @@ import os
import
sys
# DEV vs PROD
if
os
.
environ
[
'GO_ENV'
]
!=
'production'
:
if
os
.
environ
[
"GO_ENV"
]
!=
"production"
:
DEBUG
=
True
# dummy cache for development-- doesn't actually cache things
CACHES
=
{
'default'
:
{
'BACKEND'
:
'django.core.cache.backends.dummy.DummyCache'
,
}
}
CACHES
=
{
"default"
:
{
"BACKEND"
:
"django.core.cache.backends.dummy.DummyCache"
}}
else
:
DEBUG
=
False
CACHES
=
{
'default'
:
{
'BACKEND'
:
'redis_cache.RedisCache'
,
'LOCATION'
:
'localhost:6379'
,
},
"default"
:
{
"BACKEND"
:
"redis_cache.RedisCache"
,
"LOCATION"
:
"localhost:6379"
}
}
# STANDALONE VARS
...
...
@@ -32,14 +25,14 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# You can generate a secret key from the following link:
# http://www.miniwebtool.com/django-secret-key-generator/
SECRET_KEY
=
os
.
environ
[
'GO_SECRET_KEY'
]
SECRET_KEY
=
os
.
environ
[
"GO_SECRET_KEY"
]
# Peoplefinder API
PF_URL
=
"https://api.srct.gmu.edu/peoplefinder/v1/"
# The domains this application will be deployed on
# e.g. Which domains this app should listen to requests from.
ALLOWED_HOSTS
=
[
os
.
environ
[
'GO_ALLOWED_HOSTS'
]]
ALLOWED_HOSTS
=
[
os
.
environ
[
"GO_ALLOWED_HOSTS"
]]
ADMINS
=
()
MANAGERS
=
ADMINS
...
...
@@ -47,47 +40,39 @@ MANAGERS = ADMINS
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
LANGUAGE_CODE
=
'en-us'
TIME_ZONE
=
'UTC'
LANGUAGE_CODE
=
"en-us"
TIME_ZONE
=
"UTC"
USE_I18N
=
True
USE_L10N
=
True
USE_TZ
=
True
# MEDIA/STATIC FILE CONFIGURATION
MEDIA_URL
=
'/media/'
MEDIA_ROOT
=
''
MEDIAFILES_DIRS
=
(
os
.
path
.
join
(
BASE_DIR
,
'media/'
),
)
MEDIA_URL
=
"/media/"
MEDIA_ROOT
=
""
MEDIAFILES_DIRS
=
(
os
.
path
.
join
(
BASE_DIR
,
"media/"
),)
STATIC_URL
=
'/static/'
STATIC_ROOT
=
''
STATICFILES_DIRS
=
(
os
.
path
.
join
(
BASE_DIR
,
'static/'
),
'./go/static/'
)
STATIC_URL
=
"/static/"
STATIC_ROOT
=
""
STATICFILES_DIRS
=
(
os
.
path
.
join
(
BASE_DIR
,
"static/"
),
"./go/static/"
)
STATICFILES_FINDERS
=
(
'django.contrib.staticfiles.finders.FileSystemFinder'
,
'django.contrib.staticfiles.finders.AppDirectoriesFinder'
,
"django.contrib.staticfiles.finders.FileSystemFinder"
,
"django.contrib.staticfiles.finders.AppDirectoriesFinder"
,
)
# TEMPLATING
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
),
'./go/go_ahead/templates/'
],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'django.template.context_processors.debug'
,
'django.template.context_processors.request'
,
'django.contrib.auth.context_processors.auth'
,
'django.contrib.messages.context_processors.messages'
,
],
"BACKEND"
:
"django.template.backends.django.DjangoTemplates"
,
"DIRS"
:
[
os
.
path
.
join
(
BASE_DIR
,
"templates"
),
"./go/go_ahead/templates/"
],
"APP_DIRS"
:
True
,
"OPTIONS"
:
{
"context_processors"
:
[
"django.template.context_processors.debug"
,
"django.template.context_processors.request"
,
"django.contrib.auth.context_processors.auth"
,
"django.contrib.messages.context_processors.messages"
,
]
},
}
]
...
...
@@ -95,127 +80,115 @@ TEMPLATES = [
# Use the same DB everywhere.
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.mysql'
,
'NAME'
:
os
.
environ
[
'GO_DB_NAME'
],
'USER'
:
os
.
environ
[
'GO_DB_USER'
],
'PASSWORD'
:
os
.
environ
[
'GO_DB_PASSWORD'
],
'HOST'
:
os
.
environ
[
'GO_DB_HOST'
],
'PORT'
:
os
.
environ
[
'GO_DB_PORT'
],
'OPTIONS'
:
{
'charset'
:
'utf8mb4'
}
"default"
:
{
"ENGINE"
:
"django.db.backends.mysql"
,
"NAME"
:
os
.
environ
[
"GO_DB_NAME"
],
"USER"
:
os
.
environ
[
"GO_DB_USER"
],
"PASSWORD"
:
os
.
environ
[
"GO_DB_PASSWORD"
],
"HOST"
:
os
.
environ
[
"GO_DB_HOST"
],
"PORT"
:
os
.
environ
[
"GO_DB_PORT"
],
"OPTIONS"
:
{
"charset"
:
"utf8mb4"
},
}
}
MIDDLEWARE
=
[
'django.middleware.common.CommonMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
'cas.middleware.CASMiddleware'
,
"django.middleware.common.CommonMiddleware"
,
"django.contrib.sessions.middleware.SessionMiddleware"
,
"django.middleware.csrf.CsrfViewMiddleware"
,
"django.contrib.auth.middleware.AuthenticationMiddleware"
,
"django.contrib.messages.middleware.MessageMiddleware"
,
"cas.middleware.CASMiddleware"
,
]
ROOT_URLCONF
=
'settings.urls'
WSGI_APPLICATION
=
'settings.wsgi.application'
ROOT_URLCONF
=
"settings.urls"
WSGI_APPLICATION
=
"settings.wsgi.application"
INSTALLED_APPS
=
(
# Django apps
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.sites'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'django.contrib.admin'
,
'go_back'
,
'go_ahead'
,
"django.contrib.auth"
,
"django.contrib.contenttypes"
,
"django.contrib.sessions"
,
"django.contrib.sites"
,
"django.contrib.messages"
,
"django.contrib.staticfiles"
,
"django.contrib.admin"
,
"go_back"
,
"go_ahead"
,
# Third party
'crispy_forms'
,
'cas'
,
'rest_framework'
,
'rest_framework.authtoken'
"crispy_forms"
,
"cas"
,
"rest_framework"
,
"rest_framework.authtoken"
,
)
CRISPY_TEMPLATE_PACK
=
'bootstrap4'
CRISPY_TEMPLATE_PACK
=
"bootstrap4"
LOGGING
=
{
'version'
:
1
,
'disable_existing_loggers'
:
False
,
'filters'
:
{
'require_debug_false'
:
{
'()'
:
'django.utils.log.RequireDebugFalse'
}
},
'handlers'
:
{
'mail_admins'
:
{
'level'
:
'ERROR'
,
'filters'
:
[
'require_debug_false'
],
'class'
:
'django.utils.log.AdminEmailHandler'
"version"
:
1
,
"disable_existing_loggers"
:
False
,
"filters"
:
{
"require_debug_false"
:
{
"()"
:
"django.utils.log.RequireDebugFalse"
}},
"handlers"
:
{
"mail_admins"
:
{
"level"
:
"ERROR"
,
"filters"
:
[
"require_debug_false"
],
"class"
:
"django.utils.log.AdminEmailHandler"
,
},
'console'
:
{
'level'
:
'INFO'
,
'class'
:
'logging.StreamHandler'
,
'stream'
:
sys
.
stdout
}
},
'loggers'
:
{
'django.request'
:
{
'handlers'
:
[
'mail_admins'
],
'level'
:
'ERROR'
,
'propagate'
:
True
,
"console"
:
{
"level"
:
"INFO"
,
"class"
:
"logging.StreamHandler"
,
"stream"
:
sys
.
stdout
,
},
'django'
:
{
'handlers'
:
[
'console'
],
'level'
:
'INFO'
,
'propogate'
:
True
},
"loggers"
:
{
"django.request"
:
{
"handlers"
:
[
"mail_admins"
],
"level"
:
"ERROR"
,
"propagate"
:
True
,
},
}
"django"
:
{
"handlers"
:
[
"console"
],
"level"
:
"INFO"
,
"propogate"
:
True
},
},
}
"""
CAS Authentication Settings
"""
LOGIN_URL
=
'/login'
LOGOUT_URL
=
'/logout'
LOGIN_REDIRECT_URL
=
'/'
LOGIN_URL
=
"/login"
LOGOUT_URL
=
"/logout"
LOGIN_REDIRECT_URL
=
"/"
AUTHENTICATION_BACKENDS
=
(
'django.contrib.auth.backends.ModelBackend'
,
'cas.backends.CASBackend'
,
"django.contrib.auth.backends.ModelBackend"
,
"cas.backends.CASBackend"
,
)
CAS_LOGOUT_COMPLETELY
=
True
CAS_PROVIDE_URL_TO_LOGOUT
=
True
CAS_RESPONSE_CALLBACKS
=
(
'go_back.cas_callbacks.create_user'
,
)
CAS_RESPONSE_CALLBACKS
=
(
"go_back.cas_callbacks.create_user"
,)
CAS_SERVER_URL
=
"https://login.gmu.edu"
"""
Mail Settings
"""
EMAIL_HOST
=
os
.
environ
[
'GO_EMAIL_HOST'
]
EMAIL_PORT
=
os
.
environ
[
'GO_EMAIL_PORT'
]
EMAIL_HOST_USER
=
os
.
environ
[
'GO_EMAIL_HOST_USER'
]
EMAIL_HOST_PASSWORD
=
os
.
environ
[
'GO_EMAIL_HOST_PASSWORD'
]
EMAIL_FROM
=
os
.
environ
[
'GO_EMAIL_FROM'
]
EMAIL_TO
=
os
.
environ
[
'GO_EMAIL_TO'
]
EMAIL_HOST
=
os
.
environ
[
"GO_EMAIL_HOST"
]
EMAIL_PORT
=
os
.
environ
[
"GO_EMAIL_PORT"
]
EMAIL_HOST_USER
=
os
.
environ
[
"GO_EMAIL_HOST_USER"
]
EMAIL_HOST_PASSWORD
=
os
.
environ
[
"GO_EMAIL_HOST_PASSWORD"
]
EMAIL_FROM
=
os
.
environ
[
"GO_EMAIL_FROM"
]
EMAIL_TO
=
os
.
environ
[
"GO_EMAIL_TO"
]
# Domain used to email to users. See implementation in views.py
# ie. '@gmu.edu'
EMAIL_DOMAIN
=
os
.
environ
[
'GO_EMAIL_DOMAIN'
]
EMAIL_DOMAIN
=
os
.
environ
[
"GO_EMAIL_DOMAIN"
]
"""
Django Rest Framework Settings
"""
REST_FRAMEWORK
=
{
'DEFAULT_PERMISSION_CLASSES'
:
[
'rest_framework.permissions.IsAuthenticated'
],
'DEFAULT_AUTHENTICATION_CLASSES'
:
[
'rest_framework.authentication.TokenAuthentication'
,
'rest_framework.authentication.SessionAuthentication'
,
"DEFAULT_PERMISSION_CLASSES"
:
[
"rest_framework.permissions.IsAuthenticated"
],
"DEFAULT_AUTHENTICATION_CLASSES"
:
[
"rest_framework.authentication.TokenAuthentication"
,
"rest_framework.authentication.SessionAuthentication"
,
],
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment