Skip to content

Commit 7c6def5

Browse files
added license. avaialbe for public release
1 parent a2c8062 commit 7c6def5

13 files changed

+856
-1
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

core/__init__.py

Whitespace-only changes.

core/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

core/migrations/__init__.py

Whitespace-only changes.

core/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

core/notifications.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import smtplib
2+
from django.core.mail.backends.smtp import EmailBackend
3+
from django.core.mail.utils import DNS_NAME
4+
5+
6+
class IITBEmailBackend(EmailBackend):
7+
8+
def open(self):
9+
"""
10+
Ensures we have a connection to the email server. Returns whether or
11+
not a new connection was required (True or False).
12+
"""
13+
if self.connection:
14+
# Nothing to do if the connection is already open.
15+
return False
16+
17+
connection_class = smtplib.SMTP_SSL if self.use_ssl else smtplib.SMTP
18+
# If local_hostname is not specified, socket.getfqdn() gets used.
19+
# For performance, we use the cached FQDN for local_hostname.
20+
connection_params = {'local_hostname': DNS_NAME.get_fqdn()}
21+
if self.timeout is not None:
22+
connection_params['timeout'] = self.timeout
23+
if self.use_ssl:
24+
connection_params.update({
25+
'keyfile': self.ssl_keyfile,
26+
'certfile': self.ssl_certfile,
27+
})
28+
try:
29+
self.connection = connection_class(self.host, self.port, **connection_params)
30+
31+
# TLS/SSL are mutually exclusive, so only attempt TLS over
32+
# non-secure connections.
33+
self.connection.starttls()
34+
self.connection.ehlo()
35+
self.connection.esmtp_features['auth'] = 'LOGIN PLAIN'
36+
if self.username and self.password:
37+
self.connection.login(self.username, self.password)
38+
return True
39+
except smtplib.SMTPException:
40+
if not self.fail_silently:
41+
raise

core/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

core/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

gunicorn_conf.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""gunicorn WSGI server configuration."""
2+
from multiprocessing import cpu_count
3+
4+
5+
def max_workers():
6+
return 2 * cpu_count() + 1
7+
8+
9+
workers = max_workers()
10+
worker_class = 'gevent'
11+
accesslog = "logs/gunicorn_access.log"
12+
access_log_format = "%(h)s %({X-Real-IP}i)s %(D)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s %(f)s %(a)s"
13+
errorlog = "logs/gunicorn_error.log"

scripts/dev.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/
3+
4+
PORT_DEV=
5+
ROOT=
6+
KILL=
7+
8+
source $ABSOLUTE_PATH/settings.sh
9+
10+
PORT=$PORT_DEV
11+
KILL=$KILL
12+
13+
cd $ROOT
14+
15+
# Kill network process on port $PORT
16+
fuser -k $PORT/tcp
17+
18+
# Exit after killing by fuser if KILL is true
19+
if [ "$KILL" = true ] ; then
20+
exit 1
21+
fi
22+
23+
gunicorn iitbapp.wsgi \
24+
--bind=0.0.0.0:$PORT \
25+
-c gunicorn_conf.py \
26+
--log-level=info \
27+
--reload \
28+
--log-file "logs/gunicorn_logs.log" &

scripts/prod.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/
3+
4+
PORT_PROD=
5+
ROOT=
6+
KILL=
7+
8+
source $ABSOLUTE_PATH/settings.sh
9+
10+
PORT=$PORT_PROD
11+
KILL=$KILL
12+
13+
cd $ROOT
14+
15+
# Kill network process on port $PORT
16+
fuser -k $PORT/tcp
17+
18+
# Exit after killing by fuser if KILL is true
19+
if [ "$KILL" = true ] ; then
20+
exit 1
21+
fi
22+
23+
gunicorn iitbapp.wsgi \
24+
--bind=0.0.0.0:$PORT \
25+
-c gunicorn_conf.py \
26+
--log-level=info \
27+
--reload \
28+
--log-file "logs/gunicorn_logs.log" &

scripts/settings.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
PORT_PROD=7070
3+
PORT_DEV=7071
4+
KILL=false
5+
6+
if git rev-parse --git-dir > /dev/null 2>&1; then
7+
: #Valid git repo
8+
else
9+
>&2 echo "Run this command under git repository"
10+
exit 1
11+
: # this is not a git repository
12+
fi
13+
14+
# Get Project root
15+
ROOT="`git rev-parse --show-toplevel`"
16+
17+
while getopts p:s opt; do
18+
case $opt in
19+
p)
20+
PORT_PROD=$OPTARG
21+
PORT_DEV=$OPTARG
22+
;;
23+
s)
24+
KILL=true
25+
;;
26+
esac
27+
done

sso/settings_user.py.sample

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,36 @@ NOCAPTCHA = True
99

1010
RECAPTCHA_USE_SSL = True
1111

12-
DEBUG = False
12+
DEBUG = False
13+
14+
CORS_ORIGIN_ALLOW_ALL = True
15+
16+
ALLOWED_HOSTS = ['*']
17+
18+
# Email server settings
19+
EMAIL_HOST = "smtp-auth.iitb.ac.in"
20+
EMAIL_PORT = 25
21+
22+
EMAIL_HOST_USER = ""
23+
24+
EMAIL_HOST_PASSWORD = ""
25+
26+
EMAIL_FROM = ""
27+
28+
EMAIL_BACKEND = "core.notification.IITBEmailBackend"
29+
30+
SERVER_EMAIL = ""
31+
32+
EMAIL_SUBJECT_PREFIX = '[LDAPSSO] '
33+
34+
ADMINS = (
35+
('Dheerendra Rathor', '[email protected]'),
36+
)
37+
38+
MEDIA_URL = "http://gymkhana.iitb.ac.in/ldapsso/media/"
39+
40+
STATIC_URL = "/static/"
41+
42+
SESSION_COOKIE_PATH = "/ldapsso/"
43+
44+
CSRF_COOKIE_PATH = "/ldapsso/"

0 commit comments

Comments
 (0)