Skip to content

Commit

Permalink
Initial python ci (#36)
Browse files Browse the repository at this point in the history
* Initial python ci

* Use python 3.6

* Adding libldap2-dev

* Adding libsasl2-dev

* Only format code

* Fixing naming

* Fixing linting issues
  • Loading branch information
devinmatte authored Nov 2, 2020
1 parent 0e1787b commit d3b7c96
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 12 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:

runs-on: ubuntu-latest

steps:
- name: Install ldap dependencies
run: sudo apt-get install libldap2-dev libsasl2-dev
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with black
run: |
# stop the build if there are Python syntax errors or undefined names
black --check selfservice
- name: Lint with pylint
run: |
pylint selfservice
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ disable=
inconsistent-return-statements,
no-name-in-module,
cyclic-import,
unnecessary-pass,


[REPORTS]
Expand Down
5 changes: 4 additions & 1 deletion selfservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@

@app.errorhandler(500)
def app_error(e):
return render_template("error.html"), 500
"""
Renders an error page.
"""
return render_template("error.html", e=e), 500


@app.route("/")
Expand Down
8 changes: 5 additions & 3 deletions selfservice/blueprints/otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
Flask blueprint for handling creating and removing OTP secrets from accounts.
"""

import logging
import pyotp

from flask import Blueprint, render_template, request, redirect, flash
from flask import session as flask_session
import dill as pickle
import pyotp
import logging


from selfservice.utilities.keycloak import (
OTPConfigError,
Expand Down Expand Up @@ -63,7 +65,7 @@ def enable():
if not secret or not otp_session:
flash("Invalid secret provided. Please try again.")
return redirect("/otp")
elif not otp_code:
if not otp_code:
flash("No one time password provided. Please scan the code and try again.")
return redirect("/otp".format(secret))

Expand Down
10 changes: 4 additions & 6 deletions selfservice/blueprints/recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ def create_session():

# Redirect the user to thier session.
return redirect("/recovery/" + session_id)
else:
flash("Please complete the reCaptcha.")
return redirect("/recovery")
flash("Please complete the reCaptcha.")
return redirect("/recovery")


@recovery_bp.route("/recovery/<recovery_id>")
Expand Down Expand Up @@ -197,9 +196,8 @@ def verify_phone(recovery_id):
if not token:
token = generate_token(session)
return redirect("/reset?token=" + token)
else:
flash("Your verification code did not match, sorry!")
return redirect("/recovery")
flash("Your verification code did not match, sorry!")
return redirect("/recovery")


@recovery_bp.route("/reset", methods=["GET", "POST"])
Expand Down
6 changes: 6 additions & 0 deletions selfservice/utilities/app_passwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,11 @@ def set_app_passwd(username):


def delete_app_passwd(username):
"""
Deletes an existing App Specific Password
Keyword arguments:
username -- User who's app password will be deleted
"""
AppSpecificPassword.query.filter_by(user=username).delete()
db.session.commit()
3 changes: 1 addition & 2 deletions selfservice/utilities/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def valid_token(token_id):
if is_expired(token_data.created, 30):
return False
return True
else:
return False
return False


def passwd_reset(username, password):
Expand Down

0 comments on commit d3b7c96

Please sign in to comment.