How to use the eve.auth.requires_auth function in Eve

To help you get started, we’ve selected a few Eve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github claranet / cloud-deploy / ghost_blueprints.py View on Github external
@requires_auth('')
def list_commands(app_id=None):
    """
    Returns a mapping of the available commands and their descriptions:

    >>> from tests.helpers import create_test_app_context; create_test_app_context()
    >>> import json
    >>> config['enable_executescript_command'] = 'true'
    >>> config['blue_green'] = {'enabled': True}

    >>> sorted(json.loads(list_commands().data))
    [[u'buildimage', u'Build Image'], [u'createinstance', u'Create a new instance'], [u'deploy', u'Deploy module(s)'], [u'destroyallinstances', u'Destroy all instances'], [u'executescript', u'Execute a script/commands on every instance'], [u'preparebluegreen', u'Prepare the Blue/Green env before swap'], [u'purgebluegreen', u'Purge the Blue/Green env'], [u'recreateinstances', u'Recreate all the instances, rolling update possible when using an Autoscale'], [u'redeploy', u'Re-deploy an old module package'], [u'swapbluegreen', u'Swap the Blue/Green env'], [u'updateautoscaling', u'Update the autoscaling group and its LaunchConfiguration'], [u'updatelifecyclehooks', u'Update LifeCycle Hooks scripts']]

    >>> config['enable_executescript_command'] = 'false'
    >>> sorted(json.loads(list_commands().data))
    [[u'buildimage', u'Build Image'], [u'createinstance', u'Create a new instance'], [u'deploy', u'Deploy module(s)'], [u'destroyallinstances', u'Destroy all instances'], [u'preparebluegreen', u'Prepare the Blue/Green env before swap'], [u'purgebluegreen', u'Purge the Blue/Green env'], [u'recreateinstances', u'Recreate all the instances, rolling update possible when using an Autoscale'], [u'redeploy', u'Re-deploy an old module package'], [u'swapbluegreen', u'Swap the Blue/Green env'], [u'updateautoscaling', u'Update the autoscaling group and its LaunchConfiguration'], [u'updatelifecyclehooks', u'Update LifeCycle Hooks scripts']]
    """
github pyeve / eve / eve / endpoints.py View on Github external
@requires_auth("home")
def home_endpoint():
    """ Home/API entry point. Will provide links to each available resource

    .. versionchanged:: 0.5
       Resource URLs are relative to API root.
       Don't list internal resources.

    .. versionchanged:: 0.4
       Prevent versioning collections from being added in links.

    .. versionchanged:: 0.2
       Use new 'resource_title' setting for link titles.

    .. versionchanged:: 0.1.0
       Support for optional HATEOAS.
    """
github pyeve / eve / eve / endpoints.py View on Github external
@requires_auth("home")
def schema_collection_endpoint():
    """ This endpoint is active when SCHEMA_ENDPOINT != None. It returns the
    schema definition for all public or request authenticated resources in
    JSON format.
    """
    schemas = {}
    for resource_name, resource_config in app.config["DOMAIN"].items():
        # skip versioned shadow collections
        if resource_name.endswith(config.VERSIONS):
            continue
        # skip internal resources
        internal = resource_config.get("internal_resource", False)
        if internal:
            continue
        # skip resources for which request does not have read authorization
        auth = resource_auth(resource_name)
github claranet / cloud-deploy / run.py View on Github external
@rq_dashboard.blueprint.before_request
@requires_auth('')
def rq_dashboard_before_request():
    pass
github pyeve / eve / eve / methods / post.py View on Github external
@requires_auth("resource")
@pre_event
def post(resource, payl=None):
    """
    Default function for handling POST requests, it has decorators for
    rate limiting, authentication and for raising pre-request events. After the
    decorators are applied forwards to call to :func:`post_internal`

    .. versionchanged:: 0.5
       Split original post() into post/post_internal combo.
    """
    return post_internal(resource, payl, skip_validation=False)
github pyeve / eve / eve / methods / delete.py View on Github external
@requires_auth("resource")
@pre_event
def delete(resource, **lookup):
    """ Deletes all item of a resource (collection in MongoDB terms). Won't
    drop indexes. Use with caution!

    .. versionchanged:: 0.5
       Return 204 NoContent instead of 200.

    .. versionchanged:: 0.4
       Support for document versioning.
       'on_delete_resource' raised before performing the actual delete.
       'on_deleted_resource' raised after performing the delete

    .. versionchanged:: 0.3
       Support for the lookup filter, which allows for develtion of
       sub-resources (only delete documents that match a given condition).
github pyeve / eve / eve / methods / patch.py View on Github external
@requires_auth("item")
@pre_event
def patch(resource, payload=None, **lookup):
    """
    Default function for handling PATCH requests, it has decorators for
    rate limiting, authentication and for raising pre-request events.
    After the decorators are applied forwards to call to :func:`patch_internal`

    .. versionchanged:: 0.5
       Split into patch() and patch_internal().
    """
    return patch_internal(
        resource, payload, concurrency_check=True, skip_validation=False, **lookup
    )
github pyeve / eve / eve / methods / delete.py View on Github external
@requires_auth("item")
@pre_event
def deleteitem(resource, **lookup):
    """
    Default function for handling DELETE requests, it has decorators for
    rate limiting, authentication and for raising pre-request events.
    After the decorators are applied forwards to call to
    :func:`deleteitem_internal`

    .. versionchanged:: 0.5
       Split into deleteitem() and deleteitem_internal().
    """
    return deleteitem_internal(resource, concurrency_check=True, **lookup)
github pyeve / eve / eve / endpoints.py View on Github external
@requires_auth("media")
def media_endpoint(_id):
    """ This endpoint is active when RETURN_MEDIA_AS_URL is True. It retrieves
    a media file and streams it to the client.

    .. versionadded:: 0.6
    """
    if request.method == "OPTIONS":
        return send_response(None, (None))

    file_ = app.media.get(_id)
    if file_ is None:
        return abort(404)

    headers = {
        "Last-Modified": date_to_rfc1123(file_.upload_date),
        "Content-Length": file_.length,
github claranet / cloud-deploy / ghost_blueprints.py View on Github external
@requires_auth('')
def list_commands_app_fields_impact(app_id=None):
    """
    Returns a mapping of the available commands and which App's fields are used:

    >>> from tests.helpers import create_test_app_context; create_test_app_context()
    >>> import json
    >>> config['enable_executescript_command'] = 'true'
    >>> config['blue_green'] = {'enabled': True}

    >>> sorted(json.loads(list_commands_app_fields_impact().data))
    [[u'buildimage', [u'features', u'build_infos']], [u'createinstance', [u'environment_infos']], [u'deploy', [u'modules']], [u'destroyallinstances', []], [u'executescript', []], [u'preparebluegreen', [u'blue_green']], [u'purgebluegreen', [u'blue_green']], [u'recreateinstances', [u'features', u'environment_infos']], [u'redeploy', []], [u'swapbluegreen', [u'blue_green']], [u'updateautoscaling', [u'autoscale', u'environment_infos']], [u'updatelifecyclehooks', [u'lifecycle_hooks']]]

    >>> config['enable_executescript_command'] = 'false'
    >>> sorted(json.loads(list_commands_app_fields_impact().data))
    [[u'buildimage', [u'features', u'build_infos']], [u'createinstance', [u'environment_infos']], [u'deploy', [u'modules']], [u'destroyallinstances', []], [u'preparebluegreen', [u'blue_green']], [u'purgebluegreen', [u'blue_green']], [u'recreateinstances', [u'features', u'environment_infos']], [u'redeploy', []], [u'swapbluegreen', [u'blue_green']], [u'updateautoscaling', [u'autoscale', u'environment_infos']], [u'updatelifecyclehooks', [u'lifecycle_hooks']]]
    """