{ "info": { "author": "SAP SE", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Operating System :: POSIX :: BSD", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Security" ], "description": "# Description\nThis project is a python client library called *sap_xssec* for validation of *OAuth access tokens* issued by the *XSUAA*. \n\n### OAuth Authorization Code Flow\nThe typical web application use the OAuth authorization code flow for authentication, which is described as follows:\n1. A user accesses the web application using a browser.\n2. The web application (in typical SAP Cloud Platform applications, this is an application router) acts as OAuth client and redirects\nto the OAuth server for authorization.\n3. Upon authentication, the web application uses the code issued by the authorization server to request an access token.\n4. The web application uses the access token to request data from the OAuth resource server.\nThe OAuth resource server validates the token using online or offline validation.\nFor this validation libraries like sap_xssec are used.\n\n\n![alt text](https://raw.githubusercontent.com/SAP/cloud-security-xsuaa-integration/1.4.0/images/oauth.png \"OAuth authorization code flow\")\n\n\n### Usage\n\nFor the usage of this library it is necessary to pass a JWT access token that should be validated to the library.\nThe examples below rely on users and credentials that you should substitute with the ones in your context.\n\nThe typical use case for calling this API lies from within a container when an HTTP request is received and it must \nbe checked if the requester is authorized to execute this method.\nIn this case, the access token is contained in the authorization header (with keyword `bearer`).\nYou can remove the prefix `bearer` and pass the remaining string (just as in the following example as `access_token`) to the API.\n\n```python\nfrom sap import xssec\nfrom cfenv import AppEnv\n\nenv = AppEnv()\nuaa_service = env.get_service(name='').credentials\n\nsecurity_context = xssec.create_security_context(access_token, uaa_service)\n```\n\n**Note:** That the example above uses module [`cfenv`](https://pypi.python.org/pypi/cfenv) to retrieve the configuration of the uaa\nservice instance.\n`uaa_service` is a dict that contains the necessary client information and looks like:\n```\n{\n 'clientid' : 'example_clientid' // the id of the client\n 'clientsecret': 'example_clientsecret' // the secret of the client\n 'url': 'example_url' // the url of the uaa\n 'verificationkey': 'example_verification key' // (optional) the key used for the verfication of the token\n}\n\n```\nIf the `jku` and `kid` are set in the token, the key is requested from the uaa. As a fallback, the key configured in\n`uaa_service` is used. Requested keys are cached for 15 minutes to avoid extensive load on the uaa.\n\nThe creation function `xssec.create_security_context` is to be used for an end-user token (e.g. for grant_type `password`\n or grant_type `authorization_code`) where user information is expected to be available within the token and thus within the security context.\n\n`create_security_context` also accepts a token of grant_type `client_credentials`.\nThis leads to the creation of a limited *SecurityContext* where certain functions are not available.\nFor more details please consult the API description in the wiki.\n\nFor example, the `security_context` object can then be used to check if a user has a required scope:\n\n``` \nsecurity_context.check_scope('uaa.user')\n```\n\nor to receive the client id of a user:\n\n``` \nsecurity_context.get_clientid()\n```\n\nMore details on the API can be found in the [wiki](https://github.com/SAP/cloud-pysec/wiki).\n### Offline Validation\n\nsap_xssec offers offline validation of the access token, which requires no additional call to the UAA.\nThe trust for this offline validation is created by binding the XS UAA service instance to your application.\nInside the credentials section in the environment variable `VCAP_SERVICES`, the key for validation of tokens is included.\nBy default, the offline validation check will only accept tokens intended for the same OAuth2 client in the same UAA identity zone.\nThis makes sense and will cover the vast majority of use cases.\nHowever, if an application absolutely wants to consume token that were issued for either different OAuth2 clients or different identity zones,\n an *Access Control List (ACL)* entry for this can be specified in an environment variable named `SAP_JWT_TRUST_ACL`.\n The name of the OAuth client has then the prefix `sb-`, the content is a JSON String, containing an array of identity zones and OAuth2 clients.\n To trust any OAuth2 client and/or identity zones, an * can be used.\n\nIf you want to enable another (foreign) application to use some of your application's scopes, you can add a ```granted-apps``` marker to your scope in the ```xs-security.json``` file (as in the following example). The value of the marker is a list of applications that is allowed to request a token with the denoted scope.\n\n```JSON\n{\n \"xsappname\" : \"sample-leave-request-app\",\n \"description\" : \"This sample application demos leave requests\",\n \"scopes\" : [ { \"name\" : \"$XSAPPNAME.createLR\",\n \"description\" : \"create leave requests\" },\n { \"name\" : \"$XSAPPNAME.approveLR\",\n \"description\" : \"approve leave requests\",\n \"granted-apps\" : [\"MobileApprovals\"] }\n ],\n \"attributes\" : [ { \"name\" : \"costcenter\",\n \"description\" : \"costcenter\",\n \"valueType\" : \"string\"\n } ],\n \"role-templates\": [ { \"name\" : \"employee\",\n \"description\" : \"Role for creating leave requests\",\n \"scope-references\" : [ \"$XSAPPNAME.createLR\",\"JobScheduler.scheduleJobs\" ],\n \"attribute-references\": [ \"costcenter\"] },\n { \"name\" : \"manager\",\n \"description\" : \"Role for creating and approving leave requests\",\n \"scope-references\" : [ \"$XSAPPNAME.createLR\",\"$XSAPPNAME.approveLR\",\"JobScheduler.scheduleJobs\" ],\n \"attribute-references\": [ \"costcenter\" ] }\n ]\n}\n```\n\n# Configuration\nTo configure whether the *sap-jwt* or the *py-jwt* library should be used for validation of the jwt token, \nchange the `USE_SAP_PY_JWT` environment variable to `true`.\n\n\n# Requirements\n*sap_xssec* requires either *python 2.7* or *python 3.7*.\n\n\n# Download and Installation\nAs this package is deployed to PyPI, you can simply add `sap_xssec` as a dependency to your python project or \ninstall this package by running `pip install sap_xssec`.\n\n# Known Issues\n# How to obtain support\nOpen an issue in GitHub.\n# License\n\nThe following text should appear in the license section.\n\nCopyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.\nThis file is licensed under the Apache Software License, v. 2\nexcept as noted otherwise in the [LICENSE file](https://github.com/SAP/cloud-pysec/blob/master/LICENSE).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SAP/cloud-pysec", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "sap-xssec", "package_url": "https://pypi.org/project/sap-xssec/", "platform": "", "project_url": "https://pypi.org/project/sap-xssec/", "project_urls": { "Homepage": "https://github.com/SAP/cloud-pysec" }, "release_url": "https://pypi.org/project/sap-xssec/2.0.7/", "requires_dist": null, "requires_python": "", "summary": "SAP Python Security Library", "version": "2.0.7" }, "last_serial": 5650651, "releases": { "1.1.8": [ { "comment_text": "", "digests": { "md5": "bcfc200bcece919582b5fab0f9bc643e", "sha256": "d05ad405edaf610040ba7ed3d6643b03ed62ffa4f367431cd737de94a7398bd5" }, "downloads": -1, "filename": "sap_xssec-1.1.8.tar.gz", "has_sig": false, "md5_digest": "bcfc200bcece919582b5fab0f9bc643e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10930, "upload_time": "2019-05-29T09:00:22", "url": "https://files.pythonhosted.org/packages/1c/82/c381f348d9daff1e358f656f5a0977818f0ebf776602768c2dc5c26e7c91/sap_xssec-1.1.8.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "1132bfc95867db3d35daebee54d628dd", "sha256": "ac1c5560962db71034607162f4dbc79401bd2b9510a8756eb3af0d9a2f612853" }, "downloads": -1, "filename": "sap_xssec-2.0.1.tar.gz", "has_sig": false, "md5_digest": "1132bfc95867db3d35daebee54d628dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13614, "upload_time": "2019-05-29T16:28:24", "url": "https://files.pythonhosted.org/packages/c0/b5/336fde783611000bc8d257466348d10900438b83389fa7c5dfc3b868e057/sap_xssec-2.0.1.tar.gz" } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "45e500569c23e7bdf9eb6d6e23b46496", "sha256": "968367c8c6753349f2c20228b02ba3ec1748fe28d1e836e23e653d6ca46e861c" }, "downloads": -1, "filename": "sap_xssec-2.0.2.tar.gz", "has_sig": false, "md5_digest": "45e500569c23e7bdf9eb6d6e23b46496", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15032, "upload_time": "2019-05-31T17:54:22", "url": "https://files.pythonhosted.org/packages/84/7a/4b69d6df7727edc6b8f835f3c8c7f8ac800ac305c46c6b0c61978d8eadc9/sap_xssec-2.0.2.tar.gz" } ], "2.0.3": [ { "comment_text": "", "digests": { "md5": "196254d12d743d1265bac017d035bd32", "sha256": "c77610581f9f90d81bf7492259a7a294fb44eb955d8ebfe0b097ca88d90a5a60" }, "downloads": -1, "filename": "sap_xssec-2.0.3.tar.gz", "has_sig": false, "md5_digest": "196254d12d743d1265bac017d035bd32", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14756, "upload_time": "2019-06-03T10:37:20", "url": "https://files.pythonhosted.org/packages/70/53/40aa55e3cbb0d87d591d3a8bf404223516eb1a08284f31e9e65d67d92256/sap_xssec-2.0.3.tar.gz" } ], "2.0.4": [ { "comment_text": "", "digests": { "md5": "555328d646d9fc0baf496e7d36d7bf3d", "sha256": "df8333ec647d6bf7dc70d88c7b73791449566241909a403453a8a3d5209039c3" }, "downloads": -1, "filename": "sap_xssec-2.0.4.tar.gz", "has_sig": false, "md5_digest": "555328d646d9fc0baf496e7d36d7bf3d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14555, "upload_time": "2019-06-03T13:48:41", "url": "https://files.pythonhosted.org/packages/b0/18/909018bf6a109405763bc308aa5f760f9abccb4f5f40c448e164dd3933f2/sap_xssec-2.0.4.tar.gz" } ], "2.0.5": [ { "comment_text": "", "digests": { "md5": "b4715cca8e9dfc319cd0380caabf4732", "sha256": "d86a0248a5c87a5770b44f34401670a43a27a90bc9ceade66f217b56ca14fc9b" }, "downloads": -1, "filename": "sap_xssec-2.0.5.tar.gz", "has_sig": false, "md5_digest": "b4715cca8e9dfc319cd0380caabf4732", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15059, "upload_time": "2019-06-05T06:22:10", "url": "https://files.pythonhosted.org/packages/01/19/b66da9acff21a1463e9261c7d1cad60f72266cf72e8dcee77545acef0ddb/sap_xssec-2.0.5.tar.gz" } ], "2.0.6": [ { "comment_text": "", "digests": { "md5": "407f406a27cb7b6a6550d602d7bc7176", "sha256": "0947ad15f9221dc0b66ff7fd96fcc3846a8d5e552e4c52701f21f7f45c13ee59" }, "downloads": -1, "filename": "sap_xssec-2.0.6.tar.gz", "has_sig": false, "md5_digest": "407f406a27cb7b6a6550d602d7bc7176", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14691, "upload_time": "2019-06-06T12:28:23", "url": "https://files.pythonhosted.org/packages/76/1e/1894c81207c6bd52536bdc1ae2f2e4112993eba4126ed80876510e74443c/sap_xssec-2.0.6.tar.gz" } ], "2.0.7": [ { "comment_text": "", "digests": { "md5": "367c8971d6687224b28510092c3ed16d", "sha256": "bb9125ee61023d485de0da148367b84fccd83731940d901e4427cc0eb457aa79" }, "downloads": -1, "filename": "sap_xssec-2.0.7.tar.gz", "has_sig": false, "md5_digest": "367c8971d6687224b28510092c3ed16d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12841, "upload_time": "2019-08-08T14:53:56", "url": "https://files.pythonhosted.org/packages/98/61/eea410e0e6731ce1094a19884bd62d26f7084d8a90cdeec146a809eb1f02/sap_xssec-2.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "367c8971d6687224b28510092c3ed16d", "sha256": "bb9125ee61023d485de0da148367b84fccd83731940d901e4427cc0eb457aa79" }, "downloads": -1, "filename": "sap_xssec-2.0.7.tar.gz", "has_sig": false, "md5_digest": "367c8971d6687224b28510092c3ed16d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12841, "upload_time": "2019-08-08T14:53:56", "url": "https://files.pythonhosted.org/packages/98/61/eea410e0e6731ce1094a19884bd62d26f7084d8a90cdeec146a809eb1f02/sap_xssec-2.0.7.tar.gz" } ] }