Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ryan Karyadiputera
ppl-berkah-back
Commits
63a67299
Commit
63a67299
authored
Apr 28, 2021
by
Ryan Karyadiputera
Browse files
test
parent
ebde7009
Pipeline
#73843
passed with stage
in 2 minutes and 26 seconds
Changes
197
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
sip-old/__init__.py
0 → 100644
View file @
63a67299
sip-old/asgi.py
0 → 100644
View file @
63a67299
"""
ASGI config for sip project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""
import
os
from
django.core.asgi
import
get_asgi_application
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'sip.settings'
)
application
=
get_asgi_application
()
sip-old/settings/.env.example
0 → 100644
View file @
63a67299
DJANGO_SECRET_KEY
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME
SQL_ENGINE
SQL_DATABASE
SQL_USER
SQL_PASSWORD
SQL_HOST
SQL_PORT
\ No newline at end of file
sip-old/settings/dev.py
0 → 100644
View file @
63a67299
"""
Django settings for sip project.
Generated by 'django-admin startproject' using Django 3.0.3.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import
environ
import
os
import
dj_database_url
from
datetime
import
timedelta
# Environ Setup
env
=
environ
.
Env
()
environ
.
Env
.
read_env
()
# Reading .env file
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
env
(
'DJANGO_SECRET_KEY'
)
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
# HOST_URL = os.getenv('HOST_URL')
ALLOWED_HOSTS
=
[
'*'
]
# Application definition
INSTALLED_APPS
=
[
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'rest_framework'
,
'drf_yasg'
,
'lembaga'
,
'laporan_praktikum'
,
'django_cas_ng'
,
'corsheaders'
,
'authentication'
,
]
MIDDLEWARE
=
[
'corsheaders.middleware.CorsMiddleware'
,
'django.middleware.security.SecurityMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
'corsheaders.middleware.CorsMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
'whitenoise.middleware.WhiteNoiseMiddleware'
,
]
ROOT_URLCONF
=
'sip.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'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'
,
],
},
},
]
WSGI_APPLICATION
=
'sip.wsgi.application'
# Rest Framework configuration settings
REST_FRAMEWORK
=
{
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES'
:
[
'rest_framework.permissions.IsAuthenticated'
,
'rest_framework.permissions.IsAdminUser'
,
],
'TEST_REQUEST_DEFAULT_FORMAT'
:
'json'
,
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
'rest_framework_jwt.authentication.JSONWebTokenAuthentication'
,
),
}
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
BASE_DIR
,
'db.sqlite3'
),
}
}
# Switch between sqlite (dev branch) and PostgreSQL (staging branch)
# Temporary, for staging only
if
os
.
environ
.
get
(
'DATABASE_URL'
)
is
not
None
:
DATABASES
[
'default'
]
=
dj_database_url
.
config
(
conn_max_age
=
600
,
ssl_require
=
True
)
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS
=
[
{
'NAME'
:
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.MinimumLengthValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.CommonPasswordValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.NumericPasswordValidator'
,
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE
=
'en-us'
TIME_ZONE
=
'Asia/Jakarta'
USE_I18N
=
True
USE_L10N
=
False
USE_TZ
=
False
DATETIME_INPUT_FORMATS
=
'%d-%m-%Y %H:%M'
,
# '21-04-2020 12:30'
PROJECT_ROOT
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL
=
'/static/'
STATIC_ROOT
=
os
.
path
.
join
(
PROJECT_ROOT
,
'static'
)
STATICFILES_DIRS
=
[
'static/'
,
os
.
path
.
join
(
BASE_DIR
,
"static"
),
]
STATIFILES_STORAGE
=
'whitenoise.storage.CompressManifestStaticFilesStrorage'
MEDIA_URL
=
'/media/'
MEDIA_ROOT
=
os
.
path
.
join
(
PROJECT_ROOT
,
'media'
)
# Authentication backends
# https://docs.djangoproject.com/en/2.1/topics/auth/customizing/#specifying-authentication-backends
AUTHENTICATION_BACKENDS
=
(
'django.contrib.auth.backends.ModelBackend'
,
'django_cas_ng.backends.CASBackend'
,
)
# Django CAS-NG configuration
CAS_SERVER_URL
=
os
.
getenv
(
"CAS_SERVER_URL"
,
'https://sso.ui.ac.id/cas2/'
)
CAS_LOGIN_URL_NAME
=
'authentication:login-sivitas'
CAS_FORCE_CHANGE_USERNAME_CASE
=
'lower'
# SSO-UI configuration
SSO_UI_ORG_DETAIL_FILE_PATH
=
"authentication/static/sso/kodoru.json"
SSO_UI_ORG_DETAIL_LANG
=
"id"
JWT_AUTH
=
{
'JWT_ENCODE_HANDLER'
:
'rest_framework_jwt.utils.jwt_encode_handler'
,
'JWT_DECODE_HANDLER'
:
'rest_framework_jwt.utils.jwt_decode_handler'
,
'JWT_PAYLOAD_HANDLER'
:
'rest_framework_jwt.utils.jwt_payload_handler'
,
'JWT_PAYLOAD_GET_USER_ID_HANDLER'
:
'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler'
,
'JWT_RESPONSE_PAYLOAD_HANDLER'
:
'rest_framework_jwt.utils.jwt_response_payload_handler'
,
'JWT_SECRET_KEY'
:
'SECRET_KEY'
,
'JWT_GET_USER_SECRET_KEY'
:
None
,
'JWT_PUBLIC_KEY'
:
None
,
'JWT_PRIVATE_KEY'
:
None
,
'JWT_ALGORITHM'
:
'HS256'
,
'JWT_VERIFY'
:
True
,
'JWT_VERIFY_EXPIRATION'
:
True
,
'JWT_LEEWAY'
:
0
,
'JWT_EXPIRATION_DELTA'
:
timedelta
(
days
=
30
),
'JWT_AUDIENCE'
:
None
,
'JWT_ISSUER'
:
None
,
'JWT_ALLOW_REFRESH'
:
False
,
'JWT_REFRESH_EXPIRATION_DELTA'
:
timedelta
(
days
=
30
),
'JWT_AUTH_HEADER_PREFIX'
:
'Bearer'
,
'JWT_AUTH_COOKIE'
:
None
,
}
SUCCESS_SSO_AUTH_REDIRECT
=
"http://localhost:3000/"
# flake8: noqa
def
CAS_CHECK_NEXT
(
_
):
return
True
CORS_ORIGIN_ALLOW_ALL
=
True
sip-old/settings/production.py
0 → 100644
View file @
63a67299
"""
Django settings for sip project.
Generated by 'django-admin startproject' using Django 3.0.3.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import
environ
import
os
from
datetime
import
timedelta
# Environ Setup
env
=
environ
.
Env
()
environ
.
Env
.
read_env
()
# Reading .env file
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
env
(
'DJANGO_SECRET_KEY'
)
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
False
HOST_URL
=
os
.
getenv
(
'HOST_URL'
)
ALLOWED_HOSTS
=
[
'*'
]
# Application definition
INSTALLED_APPS
=
[
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'rest_framework'
,
'drf_yasg'
,
'lembaga'
,
'laporan_praktikum'
,
'django_cas_ng'
,
'corsheaders'
,
'authentication'
,
'storages'
]
MIDDLEWARE
=
[
'corsheaders.middleware.CorsMiddleware'
,
'django.middleware.security.SecurityMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
]
ROOT_URLCONF
=
'sip.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'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'
,
],
},
},
]
WSGI_APPLICATION
=
'sip.wsgi.application'
# Rest Framework configuration settings
REST_FRAMEWORK
=
{
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES'
:
[
'rest_framework.permissions.IsAuthenticated'
,
'rest_framework.permissions.IsAdminUser'
,
],
'TEST_REQUEST_DEFAULT_FORMAT'
:
'json'
,
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
'rest_framework_jwt.authentication.JSONWebTokenAuthentication'
,
),
}
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES
=
{
"default"
:
{
"ENGINE"
:
env
(
"SQL_ENGINE"
),
"NAME"
:
env
(
"SQL_DATABASE"
),
"USER"
:
env
(
"SQL_USER"
),
"PASSWORD"
:
env
(
"SQL_PASSWORD"
),
"HOST"
:
env
(
"SQL_HOST"
),
"PORT"
:
env
(
"SQL_PORT"
),
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS
=
[
{
'NAME'
:
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.MinimumLengthValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.CommonPasswordValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.NumericPasswordValidator'
,
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE
=
'en-us'
TIME_ZONE
=
'Asia/Jakarta'
USE_I18N
=
True
USE_L10N
=
True
USE_TZ
=
True
PROJECT_ROOT
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
AWS_ACCESS_KEY_ID
=
env
(
'AWS_ACCESS_KEY_ID'
)
AWS_SECRET_ACCESS_KEY
=
env
(
'AWS_SECRET_ACCESS_KEY'
)
AWS_STORAGE_BUCKET_NAME
=
env
(
'AWS_STORAGE_BUCKET_NAME'
)
AWS_S3_OBJECT_PARAMETERS
=
{
'CacheControl'
:
'max-age=86400'
,
}
AWS_S3_CUSTOM_DOMAIN
=
'%s.s3.amazonaws.com'
%
env
(
'AWS_STORAGE_BUCKET_NAME'
)
AWS_LOCATION
=
'static'
STATIC_URL
=
'https://%s/%s/'
%
(
AWS_S3_CUSTOM_DOMAIN
,
AWS_LOCATION
)
STATICFILES_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
"static"
),
]
STATICFILES_STORAGE
=
'storages.backends.s3boto3.S3Boto3Storage'
# Ini buat media aws
DEFAULT_FILE_STORAGE
=
'sip.settings.storage_backends.MediaStorage'
# Authentication backends
# https://docs.djangoproject.com/en/2.1/topics/auth/customizing/#specifying-authentication-backends
AUTHENTICATION_BACKENDS
=
(
'django.contrib.auth.backends.ModelBackend'
,
'django_cas_ng.backends.CASBackend'
,
)
# Django CAS-NG configuration
CAS_SERVER_URL
=
os
.
getenv
(
"CAS_SERVER_URL"
,
'https://sso.ui.ac.id/cas2/'
)
CAS_LOGIN_URL_NAME
=
'authentication:login-sivitas'
CAS_FORCE_CHANGE_USERNAME_CASE
=
'lower'
# SSO-UI configuration
SSO_UI_ORG_DETAIL_FILE_PATH
=
"authentication/static/sso/kodoru.json"
SSO_UI_ORG_DETAIL_LANG
=
"id"
JWT_AUTH
=
{
'JWT_ENCODE_HANDLER'
:
'rest_framework_jwt.utils.jwt_encode_handler'
,
'JWT_DECODE_HANDLER'
:
'rest_framework_jwt.utils.jwt_decode_handler'
,
'JWT_PAYLOAD_HANDLER'
:
'rest_framework_jwt.utils.jwt_payload_handler'
,
'JWT_PAYLOAD_GET_USER_ID_HANDLER'
:
'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler'
,
'JWT_RESPONSE_PAYLOAD_HANDLER'
:
'rest_framework_jwt.utils.jwt_response_payload_handler'
,
'JWT_SECRET_KEY'
:
'SECRET_KEY'
,
'JWT_GET_USER_SECRET_KEY'
:
None
,
'JWT_PUBLIC_KEY'
:
None
,
'JWT_PRIVATE_KEY'
:
None
,
'JWT_ALGORITHM'
:
'HS256'
,
'JWT_VERIFY'
:
True
,
'JWT_VERIFY_EXPIRATION'
:
True
,
'JWT_LEEWAY'
:
0
,
'JWT_EXPIRATION_DELTA'
:
timedelta
(
days
=
30
),
'JWT_AUDIENCE'
:
None
,
'JWT_ISSUER'
:
None
,
'JWT_ALLOW_REFRESH'
:
False
,
'JWT_REFRESH_EXPIRATION_DELTA'
:
timedelta
(
days
=
30
),
'JWT_AUTH_HEADER_PREFIX'
:
'Bearer'
,
'JWT_AUTH_COOKIE'
:
None
,
}
SUCCESS_SSO_AUTH_REDIRECT
=
"http://sipraktikum-frontend-2020-a.herokuapp.com/"
CORS_ORIGIN_WHITELIST
=
[
"http://sipraktikum-frontend-2020-a.herokuapp.com"
,
"http://localhost:8000"
,
"http://127.0.0.1:8000"
,
]
# flake8: noqa
def
CAS_CHECK_NEXT
(
_
):
return
True
sip-old/settings/staging.py
0 → 100644
View file @
63a67299
"""
Django settings for sip project.
Generated by 'django-admin startproject' using Django 3.0.3.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import
environ
import
os
# import sys
import
dj_database_url
from
datetime
import
timedelta
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
os
.
environ
.
get
(
"DJANGO_SECRET_KEY"
)
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
False
# HOST_URL = os.getenv('HOST_URL')
ALLOWED_HOSTS
=
[
'*'
]
# Application definition
INSTALLED_APPS
=
[
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'rest_framework'
,
'drf_yasg'
,
'lembaga'
,
'laporan_praktikum'
,
'django_cas_ng'
,
'corsheaders'
,
'authentication'
,
'storages'
]
MIDDLEWARE
=
[
'corsheaders.middleware.CorsMiddleware'
,
'django.middleware.security.SecurityMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
'django.contrib.messages.middleware.MessageMiddleware'
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
'django.middleware.common.CommonMiddleware'
,
'whitenoise.middleware.WhiteNoiseMiddleware'
,
]
ROOT_URLCONF
=
'sip.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'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'
,
],
},
},
]
WSGI_APPLICATION
=
'sip.wsgi.application'
# Rest Framework configuration settings
REST_FRAMEWORK
=
{
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES'
:
[
'rest_framework.permissions.IsAuthenticated'
,
'rest_framework.permissions.IsAdminUser'
,
],
'TEST_REQUEST_DEFAULT_FORMAT'
:
'json'
,
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
'rest_framework_jwt.authentication.JSONWebTokenAuthentication'
,
),
}
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
'NAME'
:
os
.
path
.
join
(
BASE_DIR
,
'db.sqlite3'
),
}
}
# Switch between sqlite for Gitlab Runner and PostgreSQL for Heroku
if
os
.
environ
.
get
(
'DATABASE_URL'
)
is
not
None
:
DATABASES
[
'default'
]
=
dj_database_url
.
config
(
conn_max_age
=
600
,
ssl_require
=
True
)
# if os.environ.get('https_proxy') == 'http://proxy.cs.ui.ac.id:8080/'
# DOMAIN='https://ppl2020a1.cs.ui.ac.id'
# else:
# DOMAIN='http://si-praktikum-backend.herokuapp.com'