diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..894a44c --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4be3b53 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/home/akashdesai/.local/share/virtualenvs/StudentManagementSystem-RZkPelyf/bin/python" +} \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..42aee27 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at vaibhav.joshi231@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..65fa42d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +Teammate Contributions. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b7940f5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Tejas Arya, Vaibhav Joshi, Ninad Godambe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..9315f13 --- /dev/null +++ b/Pipfile @@ -0,0 +1,13 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +flask = "*" +flask-mysqldb = "*" + +[requires] +python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..8093bb3 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,102 @@ +{ + "_meta": { + "hash": { + "sha256": "89d3a1a78476f130134b1ff64c45d9b101fb153dbf2c69827e0c9522f0fbef04" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.6" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "click": { + "hashes": [ + "sha256:8a18b4ea89d8820c5d0c7da8a64b2c324b4dabb695804dbfea19b9be9d88c0cc", + "sha256:e345d143d80bf5ee7534056164e5e112ea5e22716bbb1ce727941f4c8b471b9a" + ], + "version": "==7.1.1" + }, + "flask": { + "hashes": [ + "sha256:4efa1ae2d7c9865af48986de8aeb8504bf32c7f3d6fdc9353d34b21f4b127060", + "sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557" + ], + "index": "pypi", + "version": "==1.1.2" + }, + "flask-mysqldb": { + "hashes": [ + "sha256:1003c3d72d61a34f1ce5b1cbe427f31816f0c561cee5cd60d8158431381c37d7" + ], + "index": "pypi", + "version": "==0.2.0" + }, + "itsdangerous": { + "hashes": [ + "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19", + "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749" + ], + "version": "==1.1.0" + }, + "jinja2": { + "hashes": [ + "sha256:93187ffbc7808079673ef52771baa950426fd664d3aad1d0fa3e95644360e250", + "sha256:b0eaf100007721b5c16c1fc1eecb87409464edc10469ddc9a22a27a99123be49" + ], + "version": "==2.11.1" + }, + "markupsafe": { + "hashes": [ + "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", + "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", + "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", + "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", + "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42", + "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", + "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", + "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", + "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", + "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", + "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", + "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b", + "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", + "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15", + "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", + "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", + "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", + "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", + "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", + "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", + "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", + "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", + "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", + "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", + "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", + "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", + "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", + "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", + "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", + "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", + "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2", + "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7", + "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be" + ], + "version": "==1.1.1" + }, + "werkzeug": { + "hashes": [ + "sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43", + "sha256:6c80b1e5ad3665290ea39320b91e1be1e0d5f60652b964a3070216de83d2e47c" + ], + "version": "==1.0.1" + } + }, + "develop": {} +} diff --git a/app.py b/app.py new file mode 100644 index 0000000..6cc9ed5 --- /dev/null +++ b/app.py @@ -0,0 +1,94 @@ +""" +File Name : app.py +Date : 03/04/2020 +Version : 1.0 +Revisions : + +This file contains the driver code to run the flask web application. It is responsible for processing the input from the +web page, firing the SQL query and rendering the appropriate output +""" + +# importing the required libraries +from flask import Flask, request +from flask import render_template +from flask_mysqldb import MySQL +import hashlib +import os +import binascii + +# initializing the webapp +app = Flask(__name__) + +# MySQL Database Connection configurations. +app.config['MYSQL_HOST'] = 'dspinstance.cu7xxjgzv7fk.us-east-2.rds.amazonaws.com' +app.config['MYSQL_USER'] = 'root' +app.config['MYSQL_PASSWORD'] = '12345678' +app.config['MYSQL_DB'] = 'dsp' + +mysql = MySQL(app) + + +# The route for the home page. This block of code handles all home-page related operations. +@app.route('/', methods=['GET', 'POST']) +def login(): + """ + This method runs whenever appropriate action happens on the home page. It has the code for processing the input, + executing the SQL query, fetching the results and rendering them to another web page. + + :return: Appropriate template as per the method (GET/POST) + """ + if request.method == "POST": + + username = request.form.get("uname", False) + password = request.form.get("passwd", False) + cur = mysql.connection.cursor() + cur.execute("SELECT * FROM authentication WHERE user_id = %s AND password = %s", + (username, hash_password(password))) + result = cur.fetchall() + print(len(result)) + print(hash_password(password)) + if len(result) == 1: + cur.execute("select * from student") + result = cur.fetchall() + return render_template('home.html',data=result) + cur.close() + + return render_template('login.html') + + +@app.route('/register.html', methods=['GET', 'POST']) +def register(): + """ + This method is called when the registration page in the web application is rendered. This method contains code + for registering a user + :return: appropriate template as per the method ( GET/POST ) + """ + if request.method == "POST": + + firstname = request.form.get("fname", False) + lastname = request.form.get("lname", False) + dob = request.form.get("dob", False) + email = request.form.get("email", False) + password = request.form.get("passwd", False) + ssn = request.form.get("ssn", False) + department = request.form.get("dpt", False) + cur = mysql.connection.cursor() + cur.execute("insert into authentication values(%s, %s)",(firstname[0:1]+lastname, hash_password(password))) + print(hash_password(password)) + cur.execute("insert into student(ssn, first_name, last_name, birth_date, email_id, department_id) values(%s, %s, %s, %s, %s, %s)",(maskSSN(ssn), firstname, lastname, dob, email, department)) + result = cur.fetchall() + mysql.connection.commit() + cur.close() + return render_template('home.html',data=result) + return render_template('register.html') + +def hash_password(password): + """Hash a password for storing.""" + return hashlib.sha256(password.encode()).hexdigest() + +def maskSSN(SSN): + return '#' * (len(SSN) - 4) + SSN[-4:] + +# main method +if __name__ == '__main__': + app.run() \ No newline at end of file diff --git a/kerberos.py b/kerberos.py new file mode 100644 index 0000000..ff0a293 --- /dev/null +++ b/kerberos.py @@ -0,0 +1,20 @@ +from flask import Flask +from flask import render_template +from flask_kerberos import init_kerberos +from flask_kerberos import requires_authentication + +DEBUG=True + +app = Flask(__name__) +app.config.from_object(__name__) + + +@app.route("/") +@requires_authentication +def index(user): + return render_template('index.html', user=user) + + +if __name__ == '__main__': + init_kerberos(app) + app.run() \ No newline at end of file diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..7d3856b --- /dev/null +++ b/templates/home.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + {% for item in data %} + + + + + + + + + + {% endfor %} + + +
IDSSNFirst NameLast NameBirthdateEmailDepartment
{{item[0]}}{{item[1]}}{{item[2]}}{{item[3]}}{{item[4]}}{{item[5]}}{{item[6]}}
+ + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..4794bfa --- /dev/null +++ b/templates/index.html @@ -0,0 +1,17 @@ + + + + + Welcome {{ user }} Flask Kerberos Example + + + +

Flask Kerberos Example

+

Authenticaed {{ user }} with Kerberos Ticket

+ + + + + + + \ No newline at end of file diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..5ecab70 --- /dev/null +++ b/templates/login.html @@ -0,0 +1,71 @@ + + + + + + + + + + + + +

Student Management Portal

+ +
+

Enter Details

+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+ +
+ + +
+
+
+ + + + diff --git a/templates/register.html b/templates/register.html new file mode 100644 index 0000000..e97fba5 --- /dev/null +++ b/templates/register.html @@ -0,0 +1,83 @@ + + + + + + + + + + + +
+

New User Registration

+

+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + + +