Skip to content

Commit

Permalink
Merge pull request #488 from mozilla-iam/IAM-1256
Browse files Browse the repository at this point in the history
IAM-1256 Remove Alerts and Notifications functions within SSO Dashbord
  • Loading branch information
dividehex committed Feb 5, 2024
2 parents aa90f12 + 372c3d1 commit 1a421fd
Show file tree
Hide file tree
Showing 26 changed files with 45 additions and 1,583 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
venv
dashboard/data/apps.yml-etag
dashboard/data/apps.yml
dump.rdb
.env
env3
Expand Down
90 changes: 0 additions & 90 deletions Makefile

This file was deleted.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ A python flask implementation of an SSO dashboard. OIDC for authentication and
* MUI-CSS Framework
* Docker


# Features


* Server Side Events Security Alerts
* Control over what apps a user sees
* User profile editor
* Global Security Alerts
* IHaveBeenPwned Integration
* User alert acknowledgement/escalation

# Authentication Flow

Expand Down Expand Up @@ -91,8 +92,9 @@ This section gives an overview of the SSO Dashboard deployment, for a more detai

Single Sign On Dashboard (SSO Dashboard) runs in the AWS IAM account (320464205386) inside the production EKS cluster, however it uses resources in the `infosec-prod` and `infosec-dev` AWS accounts.

Currently the application is deployed into 2 different environments: dev and prod, each one running in the correspondent Kubernetes namespaces.
Currently the application is deployed into 3 different environments: dev, staging prod, each one running in the correspondent Kubernetes namespaces.
- Production environment can be reach at https://sso.mozilla.com
- Staging environment can be reached at https://staging.sso.mozilla.com
- Development environment can be reach at https://sso.allizom.org

The application deployment process is performed by AWS Codebuild following the instructions in the [buildspec file](https://github.com/mozilla-iam/sso-dashboard/blob/master/buildspec-k8s.yml), which is heavily dependent in this [Makefile](https://github.com/mozilla-iam/sso-dashboard/blob/master/Makefile).
Expand Down
3 changes: 0 additions & 3 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ services:
env_file: envfile
environment:
- AWS_DEFAULT_REGION=us-west-2
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
- FLASK_DEBUG=True
- FLASK_APP=dashboard/app.py
ports:
Expand Down
71 changes: 7 additions & 64 deletions dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
from dashboard.models.user import User
from dashboard.models.user import FakeUser
from dashboard.op.yaml_loader import Application
from dashboard.models.alert import Alert
from dashboard.models.alert import FakeAlert
from dashboard.models.alert import Rules
from dashboard.models.tile import S3Transfer
from dashboard.models.tile import CDNTransfer


logging.basicConfig(level=logging.INFO)
Expand All @@ -54,7 +51,7 @@
talisman = Talisman(app, content_security_policy=DASHBOARD_CSP, force_https=False)

app.config.from_object(config.Config(app).settings)
app_list = S3Transfer(config.Config(app).settings)
app_list = CDNTransfer(config.Config(app).settings)
app_list.sync_config()

# Activate server-side redis sesssion KV
Expand Down Expand Up @@ -135,6 +132,7 @@ def forbidden():
jws = request.args.get("error").encode()

token_verifier = oidc_auth.tokenVerification(jws=jws, public_key=app.config["FORBIDDEN_PAGE_PUBLIC_KEY"])
"""TODO: add code here to catch when the token is invalid"""
token_verifier.verify

return render_template("forbidden.html", token_verifier=token_verifier)
Expand Down Expand Up @@ -179,24 +177,20 @@ def dashboard():
session["userinfo"]["user_id"] = session.get("id_token")["sub"]

# Transfer any updates in to the app_tiles.
S3Transfer(config.Config(app).settings).sync_config()

# The rule engine has been disabled. See IAM-1256
# Send the user session and browser headers to the alert rules engine.
# Rules(userinfo=session["userinfo"], request=request).run()
CDNTransfer(config.Config(app).settings).sync_config()

user = User(session, config.Config(app).settings)
apps = user.apps(Application(app_list.apps_yml).apps)

return render_template("dashboard.html", config=app.config, user=user, apps=apps, alerts=None)
return render_template("dashboard.html", config=app.config, user=user, apps=apps)


@app.route("/styleguide/dashboard")
def styleguide_dashboard():
user = FakeUser(config.Config(app).settings)
apps = user.apps(Application(app_list.apps_yml).apps)

return render_template("dashboard.html", config=app.config, user=user, apps=apps, alerts=None)
return render_template("dashboard.html", config=app.config, user=user, apps=apps)


@app.route("/styleguide/notifications")
Expand All @@ -206,58 +200,7 @@ def styleguide_notifications():
return render_template("notifications.html", config=app.config, user=user)


@app.route("/notifications")
@oidc.oidc_auth("default")
def notifications():
user = User(session, config.Config(app).settings)
return render_template("notifications.html", config=app.config, user=user)


@oidc.oidc_auth("default")
@app.route("/alert/<alert_id>", methods=["POST"])
def alert_operation(alert_id):
if request.method == "POST":
user = User(session, config.Config(app).settings)
if request.data is not None:
data = json.loads(request.data.decode())
helpfulness = data.get("helpfulness")
alert_action = data.get("alert_action")

result = user.take_alert_action(alert_id, alert_action, helpfulness)

if result["ResponseMetadata"]["HTTPStatusCode"] == 200:
return "200"
else:
return "500"


@oidc.oidc_auth("default")
@app.route("/alert/fake", methods=["GET"])
def alert_faking():
if request.method == "GET":
if app.config.get("SERVER_NAME") != "sso.mozilla.com":
"""Only allow alert faking in non production environment."""
user = User(session, config.Config(app).settings)
fake_alerts = FakeAlert(user_id=user.userinfo.get("sub"))
fake_alerts.create_fake_alerts()

return redirect("/dashboard", code=302)


@app.route("/api/v1/alert", methods=["GET"])
@api.requires_api_auth
def alert_api():
if request.method == "GET" and api.requires_scope("read:alert"):
user_id = request.args.get("user_id")
alerts = Alert().find(user_id)
result = Alert().to_summary(alerts)
return jsonify(result)
raise exceptions.AuthError(
{"code": "Unauthorized", "description": "Scope not matched. Access Denied."},
403,
)


"""useful endpoint for debugging"""
@app.route("/info")
@oidc.oidc_auth("default")
def info():
Expand Down
23 changes: 0 additions & 23 deletions dashboard/data/apps.yml

This file was deleted.

2 changes: 1 addition & 1 deletion dashboard/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__all__ = ["alert", "tile", "user"]
__all__ = ["tile", "user"]
Loading

0 comments on commit 1a421fd

Please sign in to comment.