{ "info": { "author": "Jim Pruyne", "author_email": "pruyne@globus.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: Free To Use But Restricted", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Action Provider Tools\n=====================\n\nThis is an experimental and unsupported toolkit to help developers build Action Providers for use in Globus Automate Flows.\n\nAs this is experimental, no support is implied or provided for any sort of use of this package. It is published for ease of distribution among those planning to use it for its intended, experimental, purpose.\n\n\nToolkit Components\n------------------\n\nThis toolkit provides two main components:\n\n1. Authentication helpers that make it easier to validate Globus Auth tokens and determine if a given request should be authorized\n\n2. An `OpenAPI v3 specification `_ and associated helpers that can be used to validate incoming requests and verify the responses your Action Provider generates. This document also defines the interface which must be supported by your REST API to have it function as an Action Provider.\n\n\nInstallation\n------------\n\nInstallation is via PyPi using, for example: ``pip install globus-action-provider-tools``.\n\n\nUsage\n-----\n\n\nAuthentication\n---------------\n\nThe authentication helpers can be used in your action provider as follows:\n\n.. code-block:: python\n\n from globus_action_provider_tools.authentication import TokenChecker\n # You will need to register a client and scope(s) in Globus Auth\n # Then initialize a TokenChecker instance for your provider:\n checker = TokenChecker(\n client_id='YOUR_CLIENT_ID',\n client_secret='YOUR_CLIENT_SECRET',\n expected_scopes=['https://auth.globus.org/scopes/YOUR_SCOPES_HERE'],\n expected_audience='YOUR_CLIENT_NAME',\n )\n\n\n(expected_audience should be unnecessary in the near future)\n\nWhen a request comes in, use your TokenChecker to validate the access token from the HTTP Authorization header.\n\n.. code-block:: python\n\n access_token = request.headers['Authorization'].replace('Bearer ', '')\n auth_state = checker.check_token(access_token)\n\n\nThe AuthState has several properties and methods that will make it easier for you to decide whether or not to allow a request to proceed:\n\n.. code-block:: python\n\n # This user's Globus identities:\n auth_state.identities\n # frozenset({'urn:globus:auth:identity:9d437146-f150-42c2-be88-9d625d9e7cf9',\n # 'urn:globus:auth:identity:c38f015b-8ad9-4004-9160-754b309b5b33',\n # 'urn:globus:auth:identity:ffb5652b-d418-4849-9b57-556656706970'})\n # Groups this user is a member of:\n auth_state.groups\n # frozenset({'urn:globus:groups:id:606dbaa9-3d57-44b8-a33e-422a9de0c712',\n # 'urn:globus:groups:id:d2ff42bc-c708-460f-9e9b-b535c3776bdd'})\n\n\nYou'll notice that both groups and identities are represented as strings that unambiguously signal what type of entity they represent. This makes it easy to merge the two sets without conflict, for situations where you'd like to work with a single set containing all authentications:\n\n.. code-block:: python\n\n all_principals = auth_state.identities.union(auth_state.groups)\n\n\nThe AuthState object also offers a helper method, `check_authorization()` that is designed to help you test whether a request should be authorized:\n\n.. code-block:: python\n\n resource_allows = ['urn:globus:auth:identity:c38f015b-8ad9-4004-9160-754b309b5b33']\n auth_state.check_authorization(resource_allows)\n # True\n\n\nThis method also accepts two special string values, ``'public'`` and ``'all_authenticated_users'``, together with keyword arguments that enable their use:\n\n.. code-block:: python\n\n resource_allows = ['public']\n auth_state.check_authorization(resource_allows, allow_public=True)\n # True\n resource_allows = ['all_authenticated_users']\n auth_state.check_authorization(resource_allows, allow_all_authenticated_users=True)\n # True\n\n\nCaching\n-------\n\nTo avoid excessively taxing Globus Auth, the ``AuthState`` will, by default, cache identities and group memberships for 30 seconds.\n\nThe cache is initialized when you first instantiate your ``TokenChecker()``. You should only need to create one TokenChecker instance for your application, and then you can re-use it to check each new token. If you do try to make multiple instances, you may get an exception:\n\n> ``dogpile.cache.exception.RegionAlreadyConfigured: This region is already configured``\n\nbecause it's trying to re-initialize a cache that's already been set up.\n\n\nValidation\n----------\n\nThere is an OpenAPI v3 specification for the Action Provider API available as described above. You can use any tools that accept OpenAPI v3 to validate requests to and responses from your service, but this toolkit offers some pre-configured validators using the openapi-core library.\n\n.. code-block:: python\n\n from globus_action_provider_tools.validation import request_validator, response_validator\n # Validating a request\n result = request_validator.validate(request)\n # Or a response:\n result = response_validator.validate(request, response)\n # raise errors if invalid\n result.raise_for_errors()\n # or get list of errors\n errors = result.errors\n\n\nNote that the ``request`` and ``response`` objects passed to the validators must conform to the `BaseOpenAPI `_ request and response interfaces. If you're using Flask, you can use the `provided wrappers `_, but if you're using a different web framework, you'll need to write your own small wrapper class.\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "globus,automation,workflow,action_provider", "license": "", "maintainer": "Jim Pruyne", "maintainer_email": "pruyne@globus.org", "name": "globus-action-provider-tools", "package_url": "https://pypi.org/project/globus-action-provider-tools/", "platform": "", "project_url": "https://pypi.org/project/globus-action-provider-tools/", "project_urls": null, "release_url": "https://pypi.org/project/globus-action-provider-tools/0.6/", "requires_dist": [ "dogpile.cache (>=0.7.1,<0.8.0)", "globus-sdk (>=1.7.1,<2.0.0)", "globus-nexus-client (>=0.2.8,<0.3.0)", "openapi-core (>=0.11.0,<0.12.0)" ], "requires_python": ">=3.6,<4.0", "summary": "Tools to help developers build services that implement the Action Provider specification.", "version": "0.6" }, "last_serial": 5494359, "releases": { "0.6": [ { "comment_text": "", "digests": { "md5": "6545e2d578e95c6ffb7b47fa4c266bf2", "sha256": "d1351cac32b3247fa5ccb5bb7e9ba39f9341371ad9152a5d4fd195a42bb8a4c7" }, "downloads": -1, "filename": "globus_action_provider_tools-0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "6545e2d578e95c6ffb7b47fa4c266bf2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 13012, "upload_time": "2019-07-06T08:49:53", "url": "https://files.pythonhosted.org/packages/a6/7f/9c45ffd1029347adc429d3f3c70dce5f7b2adf1c9ce88d0f012421b88cd8/globus_action_provider_tools-0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c65cba8c944597d053dd93c568b6a8ca", "sha256": "e44830920a82415c80ab77ef1146d7c6207ea798a044e9e858049fe8afb2ddb9" }, "downloads": -1, "filename": "globus-action-provider-tools-0.6.tar.gz", "has_sig": false, "md5_digest": "c65cba8c944597d053dd93c568b6a8ca", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 13613, "upload_time": "2019-07-06T08:49:50", "url": "https://files.pythonhosted.org/packages/96/46/e6e803e09fc0f096dc71abc07a410ca1fc60839d2c0ae550a4b21941f0a4/globus-action-provider-tools-0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6545e2d578e95c6ffb7b47fa4c266bf2", "sha256": "d1351cac32b3247fa5ccb5bb7e9ba39f9341371ad9152a5d4fd195a42bb8a4c7" }, "downloads": -1, "filename": "globus_action_provider_tools-0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "6545e2d578e95c6ffb7b47fa4c266bf2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 13012, "upload_time": "2019-07-06T08:49:53", "url": "https://files.pythonhosted.org/packages/a6/7f/9c45ffd1029347adc429d3f3c70dce5f7b2adf1c9ce88d0f012421b88cd8/globus_action_provider_tools-0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c65cba8c944597d053dd93c568b6a8ca", "sha256": "e44830920a82415c80ab77ef1146d7c6207ea798a044e9e858049fe8afb2ddb9" }, "downloads": -1, "filename": "globus-action-provider-tools-0.6.tar.gz", "has_sig": false, "md5_digest": "c65cba8c944597d053dd93c568b6a8ca", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 13613, "upload_time": "2019-07-06T08:49:50", "url": "https://files.pythonhosted.org/packages/96/46/e6e803e09fc0f096dc71abc07a410ca1fc60839d2c0ae550a4b21941f0a4/globus-action-provider-tools-0.6.tar.gz" } ] }