Exemplo n.º 1
0
    def get(self):
        cookie = request.cookies.get("oidc-jwt", None)
        if cookie is None:
            return abort(401, self.auth_string)

        if not oidc.validate_token(cookie):
            return abort(401, self.auth_string)

        claims = jwt.get_unverified_claims(cookie)

        if claims["preferred_username"]:
            csr = CSR.find_by_username(claims["preferred_username"])
            if csr:
                if csr.deleted is None:
                    csr.is_active = True
                else:
                    csr.is_active = False

                csr.is_authenticated = False
                csr.is_anonymous = False

                login_user(csr)
                if application.config['USE_HTTPS']:
                    return redirect(
                        url_for(
                            "admin.index",
                            _scheme=application.config['PREFERRED_URL_SCHEME'],
                            _external=application.config['USE_HTTPS']))
                else:
                    return redirect(url_for("admin.index"))
            else:
                return abort(401, self.auth_string)
        else:
            return abort(401, self.auth_string)
Exemplo n.º 2
0
def on_join(message):
    cookie = request.cookies.get("oidc-jwt", None)
    if cookie is None:
        emit('joinRoomFail', {"sucess": False})
        return

    if not oidc.validate_token(cookie):
        print("Cookie failed validation")
        emit('joinRoomFail', {"sucess": False})
        return

    claims = jwt.get_unverified_claims(cookie)

    if claims["preferred_username"]:
        csr = CSR.query.filter_by(
            username=claims["preferred_username"].split("idir/")[-1]).first()
        if csr:
            join_room(csr.office_id)
            emit('joinRoomSuccess', {"sucess": True})
            emit('update_customer_list', {"success": True})
            print("Success")
        else:
            print("Fail")
            emit('joinRoomFail', {"success": False})
    else:
        print("No preferred_username on request")
        emit('joinRoomFail', {"success": False})
Exemplo n.º 3
0
def on_join(message):
    cookie = request.cookies.get("oidc-jwt", None)
    if cookie is None:
        emit('joinRoomFail', {"sucess": False})
        return

    if not oidc.validate_token(cookie):
        print("Cookie failed validation")
        emit('joinRoomFail', {"sucess": False})
        return

    claims = jwt.get_unverified_claims(cookie)

    if claims["preferred_username"]:
        csr = CSR.find_by_username(claims["preferred_username"])
        if csr:
            join_room(csr.office_id)
            emit('joinRoomSuccess', {"sucess": True})
            emit('get_Csr_State_IDs', {"success": True})
            emit('update_customer_list', {"success": True})
        else:
            print("Fail")
            emit('joinRoomFail', {"success": False})
    else:
        print("No preferred_username on request")
        emit('joinRoomFail', {"success": False})
Exemplo n.º 4
0
def on_join(message):
    cookie = request.cookies.get("oidc-jwt", None)
    if cookie is None:
        emit('joinRoomFail', {"sucess": False})
        return

    if not oidc.validate_token(cookie):
        print("Cookie failed validation")
        emit('joinRoomFail', {"sucess": False})
        return

    claims = jwt.get_unverified_claims(cookie)

    if claims["preferred_username"]:
        print(
            "==> In Python, @socketio.on('joinRoom'): claims['preferred_username'] is: "
            + str(claims["preferred_username"]))
        csr = CSR.find_by_username(claims["preferred_username"])
        if csr:
            join_room(csr.office_id)
            print("==> In websocket.py, CSR joinroom, CSR: " + csr.username +
                  "; request sid: " + str(request.sid))
            emit('joinRoomSuccess', {"sucess": True})
            emit('get_Csr_State_IDs', {"success": True})
            emit('update_customer_list', {"success": True})
        else:
            print("Fail")
            emit('joinRoomFail', {"success": False})
    else:
        print("No preferred_username on request")
        emit('joinRoomFail', {"success": False})