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

Sensors - Team 3 #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added Bootstrapper/IAS_G4.zip
Binary file not shown.
12 changes: 12 additions & 0 deletions Bootstrapper/IAS_G4/ActionManager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
printf "\n\n"
printf \"********************************************************\"; \
echo ---------------------- ActionManager -------------------------; \
printf \"********************************************************\"; \
echo "Deploying ActionManager.........."
printf "\n\n"

path="./ActionManager"
cd ${path}
echo $1 | sudo -S docker build . -t actionmanager:latest;
echo $1 | sudo -S docker run actionmanager

12 changes: 12 additions & 0 deletions Bootstrapper/IAS_G4/ApplicationManager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
printf "\n\n"
printf \"********************************************************\"; \
echo ---------------------- ApplicationManager -------------------------; \
printf \"********************************************************\"; \
echo "Deploying ApplicationManager.........."
printf "\n\n"

path="./ApplicationManager"
cd ${path}
echo $1 | sudo -S docker build . -t applicationmanager:latest;
echo $1 | sudo -S docker run applicationmanager

12 changes: 12 additions & 0 deletions Bootstrapper/IAS_G4/Authentication.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
printf "\n\n"
printf \"********************************************************\n\"; \
echo ---------------------- Authentication -------------------------; \
printf \"********************************************************\"; \
echo "Deploying Authentication.........."
printf "\n\n"

path="./Authentication"
cd ${path}
echo $1 | sudo -S docker build . -t aut:latest;
echo $1 | sudo -S docker run aut

8 changes: 8 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:latest

RUN apk update && apk add python3 py3-pip
# COPY requirements.txt ./ActionManager/requirements.txt
ADD . ./Authentication
RUN cd Authentication && pip install -r /Authentication/requirements.txt

ENTRYPOINT python3 -u /Authentication/app.py
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
48 changes: 48 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from flask import render_template, request, redirect, url_for, flash, session
from views.global_ldap_authentication import *
from forms.LoginForm import *
from flask_cors import CORS, cross_origin
from flask_session import Session
import developer
import authentication
import platformAdmin


app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)

# app.secret_key = "testing"

# client = pymongo.MongoClient(host="localhost", port=27017)

app.register_blueprint(developer.developer)
app.register_blueprint(authentication.authentication)
app.register_blueprint(platformAdmin.platformAdmin)

@app.route('/')
def home():
if not session.get("name"):
return redirect("/login")
if session.get("name") == "developer":
return redirect("/developerHome")
if session.get("name") == "admin":
return redirect("/adminHome")

return "HOME"



# @app.route('/upload', methods=['GET', 'POST'])
# def upload_file():
# if request.method == 'POST':





if __name__ == '__main__':
app.run(host="0.0.0.0",debug=True,port=5005)


import developer
39 changes: 39 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/authentication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from flask import render_template, request, redirect, url_for, flash, session,Blueprint
from views.global_ldap_authentication import *
from forms.LoginForm import *
from flask_cors import CORS, cross_origin
from flask_session import Session

authentication = Blueprint("authentication", __name__)


@authentication.route('/login', methods=['GET','POST'])
def index():

# initiate the form..
form = LoginValidation()

if request.method in ('POST') :
login_id = request.form['user_name_pid']
login_password = request.form['user_pid_Password']

# create a directory to hold the Logs
login_msg = global_ldap_authentication(login_id, login_password)

# validate the connection
if login_msg == "Success":
success_message = f"*** Authentication Success "
session["name"] = request.form.get("user_name_pid")
return redirect("/")

else:
error_message = f"*** Authentication Failed - {login_msg}"
return render_template("error.html", error_message=str(error_message))

return render_template('login.html', form=form)

@authentication.route("/logout")
def logout():
session["name"] = None
return redirect("/")

10 changes: 10 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/developer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask import render_template, request, redirect, url_for, flash, session, Blueprint

developer = Blueprint("developer", __name__)


@developer.route('/developerHome', methods=['GET','POST'])
def developerHome():
# if not session.get("name"):
# return redirect("/login")
return render_template('developerHome.html')
Binary file not shown.
11 changes: 11 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/forms/LoginForm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from main import app
from flask_wtf import Form
from wtforms import StringField, PasswordField, validators


class LoginValidation(Form):
user_name_pid = StringField('', [validators.DataRequired()],
render_kw={'autofocus': True, 'placeholder': 'Enter User'})

user_pid_Password = PasswordField('', [validators.DataRequired()],
render_kw={'autofocus': True, 'placeholder': 'Enter your login Password'})
Binary file not shown.
44 changes: 44 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/main/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os

from flask import Flask
from flask_bootstrap import Bootstrap
from flask_wtf.csrf import CSRFProtect

# import redis
# from flask_session import Session

# -- ---------------------------------------------------------------------------------
# -- Script Name : Ldap Authentication with FLask
# -- Author : *******
# -- Date : *******
# -- ---------------------------------------------------------------------------------
# -- Description : Authenticate users with Flask
# -- ---------------------------------------------------------------------------------
# -- Version History
# -- ===============
# --
# -- Who version Date Description. 3
# -- === ======= ====== ======================
# -- XXXXXXXX 1.0 Jan 21 Initial Version.
# -- ---------------------------------------------------------------------------------


current_path = os.environ['PATH']
print(current_path)

# -- ---------------------------------------------------------------------------------
# -- Function : Initiate the App C:\Users\p784138\AWS\Non-Prod\
# -- ---------------------------------------------------------------------------------
app = Flask(__name__,
template_folder="../templates",static_folder="../static"
)

bootstrap = Bootstrap(app)
app.config.from_object('settings')
app.secret_key = os.urandom(24)
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024


print('Inside __init__py')

from main import app
Binary file not shown.
15 changes: 15 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from flask_script import Server, Manager
import os
from main import app

manager = Manager(app)

manager.add_command("runserver", Server(
use_debugger=True,
use_reloader=True,
host='localhost',
port=5005
))

if __name__ == '__main__':
manager.run()
10 changes: 10 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/platformAdmin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask import render_template, request, redirect, url_for, flash, session, Blueprint

platformAdmin = Blueprint("platformAdmin", __name__)


@platformAdmin.route('/platformAdminHome', methods=['GET','POST'])
def platformAdminHome():
# if not session.get("name"):
# return redirect("/login")
return render_template('platformAdminHome.html')
8 changes: 8 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Flask==2.2.3
Flask-Script==2.0.6
Flask-Cors==3.0.10
Flask-Session==0.4.0
ldap3==2.9.1
Flask-Bootstrap==3.3.7.1
Flask-WTF==1.1.1
WTForms==3.0.1
Empty file.
132 changes: 132 additions & 0 deletions Bootstrapper/IAS_G4/Authentication/static/developerHome.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
body {
background-color: darkslategray;
padding: 0;
display: flex;
justify-content: center;
font-family: 'Roboto', sans-serif;
}
.container {
margin:0;
width: 100%;
}
.card2 {
margin: 0;
margin-top: 1%;
/* min-width: 100em; */
display: flex;
flex-direction: row;
}

.card21 {
display: flex;
flex-direction: row;
justify-content: left;
width: 50%;
padding: 5px;
}

.card22 {
margin-right: auto;
display: flex;
width: 50%;
justify-content: right;
padding: 5px;
}
.card3 {
max-width: 28%;
display: flex;
padding-top: 5%;
}
.card4 {
max-width: 71%;
margin-left: 1%;
padding-top: 2%;
}
.card5 {
max-width: 100%;
padding-top: 2%;
}
.row {
display: flex;
flex-direction: row;
padding: 12px;
min-height: 45vh;
}
.row1 {
display: flex;
flex-direction: row;
padding: 12px;
min-height: 40vh;
}

.uploadHeading{
font-weight: bold;
font-size: 30px;
display: flex;
justify-content: center;
}
div.box2 {
height: 200px;
display: flex;
flex-direction: column;
overflow: auto;
}
.box2::-webkit-scrollbar {
display: none;
}
.permSensorHeading {
font-weight: bold;
font-size: 30px;
display: flex;
justify-content: center;
margin-bottom: 10px;
}

.uploadbtndiv {
display: flex;
justify-content: center;
padding: 30px;
}

.buttonUpload {
background-color: darkslategray;
color: white;
width: 250px;
display: flex;
justify-content: center;
font-weight: bold;
border-radius: 5px;
height: 70px;
padding-top: 3%;
font-size: 20px;
transition: 0.5s;
}
.buttonUpload:hover {
background-color: white;
color: darkslategray;
height: 75px;
width: 260px;
transition: 0.5s;
}

.btn
{
background-color: darkslategray;
color: white;
width: 100%;
}
.heading {
display: flex;
justify-content: center;
}
.card1 {
margin-top: 10%;
}

.welcomeheading{
font-weight: bold;
display: flex;
justify-content: center;
margin: 0;

}
Loading