예제 #1
0
def login():  # pragma: no cover
    """ Login mechanism for this application.
    """
    next_url = flask.url_for("ui_ns.index")
    if "next" in flask.request.values:
        if is_safe_url(flask.request.values["next"]):
            next_url = flask.request.values["next"]

    if next_url == flask.url_for("ui_ns.login"):
        next_url = flask.url_for("ui_ns.index")

    if hasattr(flask.g, "fas_user") and flask.g.fas_user is not None:
        return flask.redirect(next_url)
    else:
        groups = pkgdblib.get_groups(SESSION)
        groups.extend(APP.config["ADMIN_GROUP"])
        groups.append("packager")
        return FAS.login(return_url=next_url, groups=groups)
예제 #2
0
def login():  # pragma: no cover
    """ Login mechanism for this application.
    """
    next_url = flask.url_for('ui_ns.index')
    if 'next' in flask.request.values:
        if is_safe_url(flask.request.values['next']):
            next_url = flask.request.values['next']

    if next_url == flask.url_for('ui_ns.login'):
        next_url = flask.url_for('ui_ns.index')

    if hasattr(flask.g, 'fas_user') and flask.g.fas_user is not None:
        return flask.redirect(next_url)
    else:
        groups = pkgdblib.get_groups(SESSION)
        groups.extend(APP.config['ADMIN_GROUP'])
        groups.append('packager')
        return FAS.login(return_url=next_url, groups=groups)
예제 #3
0
def login():  # pragma: no cover
    """ Login mechanism for this application.
    """
    next_url = flask.url_for('ui_ns.index')
    if 'next' in flask.request.values:
        if is_safe_url(flask.request.values['next']):
            next_url = flask.request.values['next']

    if next_url == flask.url_for('ui_ns.login'):
        next_url = flask.url_for('ui_ns.index')

    if hasattr(flask.g, 'fas_user') and flask.g.fas_user is not None:
        return flask.redirect(next_url)
    else:
        groups = pkgdblib.get_groups(SESSION)
        groups.extend(APP.config['ADMIN_GROUP'])
        groups.append(APP.config.get('PKGER_GROUP', 'packager'))
        return FAS.login(return_url=next_url, groups=groups)
예제 #4
0
파일: extras.py 프로젝트: cverna/pkgdb2
def api_groups():
    '''
    List group maintainer
    ---------------------
    Return the list FAS groups which have ACLs on one or more packages.

    ::

        /api/groups

    :kwarg format: Specify if the output if text or json.

    '''

    out_format = flask.request.args.get('format', 'text')

    if out_format not in ('text', 'json'):
        out_format = 'text'

    if request_wants_json():
        out_format = 'json'

    output = {}

    groups = pkgdblib.get_groups(SESSION)

    if out_format == 'json':
        output = {"groups": groups}
        output['total_groups'] = len(groups)
        return flask.jsonify(output)
    else:
        output = [
            "# Number of groups: %s" % len(groups)]
        for entry in sorted(groups):
            output.append("%s" % (entry))
        return flask.Response(
            '\n'.join(output),
            content_type="text/plain;charset=UTF-8"
        )
예제 #5
0
def api_groups():
    '''
    List group maintainer
    ---------------------
    Return the list FAS groups which have ACLs on one or more packages.

    ::

        /api/groups

    :kwarg format: Specify if the output if text or json.

    '''

    out_format = flask.request.args.get('format', 'text')

    if out_format not in ('text', 'json'):
        out_format = 'text'

    if request_wants_json():
        out_format = 'json'

    output = {}

    groups = pkgdblib.get_groups(SESSION)

    if out_format == 'json':
        output = {"groups": groups}
        output['total_groups'] = len(groups)
        return flask.jsonify(output)
    else:
        output = [
            "# Number of groups: %s" % len(groups)]
        for entry in sorted(groups):
            output.append("%s" % (entry))
        return flask.Response(
            '\n'.join(output),
            content_type="text/plain;charset=UTF-8"
        )