././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.2183352 oslo_context-6.5.0/0000775000175000017500000000000015224173771013075 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/.coveragerc0000664000175000017500000000016315224173710015207 0ustar00zuulzuul[run] branch = True source = oslo_context omit = oslo_context/tests/* [report] ignore_errors = True precision = 2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/.mailmap0000664000175000017500000000013115224173710014502 0ustar00zuulzuul# Format is: # # ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/.pre-commit-config.yaml0000664000175000017500000000136115224173710017350 0ustar00zuulzuulrepos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - id: trailing-whitespace - id: mixed-line-ending args: ['--fix', 'lf'] exclude: '.*\.(svg)$' - id: fix-byte-order-marker - id: check-executables-have-shebangs - id: check-merge-conflict - id: debug-statements - id: check-yaml files: .*\.(yaml|yml)$ - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.15.19 hooks: - id: ruff-check args: ['--fix', '--unsafe-fixes'] - id: ruff-format - repo: https://opendev.org/openstack/hacking rev: 8.1.0 hooks: - id: hacking additional_dependencies: [] exclude: '^(doc|releasenotes)/.*$' ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/.stestr.conf0000664000175000017500000000006515224173710015340 0ustar00zuulzuul[DEFAULT] test_path=./oslo_context/tests top_path=./ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/.zuul.yaml0000664000175000017500000000040415224173710015025 0ustar00zuulzuul--- - project: templates: - check-requirements - lib-forward-testing-python3 - openstack-python3-jobs - openstack-python3-next-jobs - periodic-stable-jobs - publish-openstack-docs-pti - release-notes-jobs-python3 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/AUTHORS0000664000175000017500000000535615224173771014156 0ustar00zuulzuulAkihiro Motoki Alexander Gorodnev Andreas Jaeger Andrew Bogott Anusree Atsushi SAKAI Ben Nemec ChangBo Guo(gcb) Corey Bryant Cyril Roelandt Daniel Bengtsson Davanum Srinivas (dims) Davanum Srinivas Davanum Srinivas Dina Belova Doug Hellmann Eric Brown Flavio Percoco Flavio Percoco Ghanshyam Ghanshyam Mann Han Guangyu Hervé Beraud James Carey Jamie Lennox Jason Kölker Jay Faulkner Jay Pipes Jeremy Stanley Joe Gordon Joshua Harlow Joshua Harlow Juan Antonio Osorio Robles Kenneth Giusti Kirill Bespalov Lance Bragstad Michael Basnight Michael Johnson Moisés Guimarães de Medeiros Monty Taylor Morgan Fainberg OpenStack Release Bot Pierre Riteau Q.hongtao Ronald Bradford Sean Dague Sean McGinnis Stephen Finucane Steve Martinelli Takashi Kajinami Thomas Herve Tony Breeds Tovin Seven Van Hung Pham Victor Sergeyev Victor Stinner Vu Cong Tuan Wei Li ZhijunWei ZhongShengping Zhongyue Luo caoyuan dengzhaosen jacky06 lingyongxu malei melissaml niuke pengyuesheng ricolin songwenping wangqi wu.shiming yangyawei yanheven zhangboye ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/CONTRIBUTING.rst0000664000175000017500000000133315224173710015527 0ustar00zuulzuulIf you would like to contribute to the development of oslo's libraries, first you must take a look to this page: https://specs.openstack.org/openstack/oslo-specs/specs/policy/contributing.html If you would like to contribute to the development of OpenStack, you must follow the steps in this page: https://docs.openstack.org/infra/manual/developers.html Once those steps have been completed, changes to OpenStack should be submitted for review via the Gerrit tool, following the workflow documented at: https://docs.openstack.org/infra/manual/developers.html#development-workflow Pull requests submitted through GitHub will be ignored. Bugs should be filed on Launchpad, not GitHub: https://bugs.launchpad.net/oslo.context ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/ChangeLog0000664000175000017500000003113615224173771014653 0ustar00zuulzuulCHANGES ======= 6.5.0 ----- * zuul: Use openstack-python3-next-jobs template * pre-commit: Bump versions * Do not install code to build release notes * Remove Python 3.10 support * Deprecate version module 6.4.0 ----- * tox: Use new constraints option * Update packaging configuration * ruff: Configure hacking as external linter * Re-implement the interface to override is\_admin check * Update master for stable/2026.1 * Ignore errant warning * Parse domain\_name header 6.3.0 ----- * Add interface to override is\_admin check * Add link for governance badges * Add typing badge * Add typing classifier * Enable logging related ruff checks * ruff: Enable missing E5 check * typing: Simplify return type of RequestContext.to\_policy\_values * Run mypy from tox * Delay string interpolations at logging calls * Remove reference to tag framework 6.2.0 ----- * Add missing py.typed file * ruff: Use more specific name to enable pyupgrade rule * reno: Update master for unmaintained/2024.1 * Add repository URL * pre-commit: Bump dependencies * Migrate setup configuration to pyproject.toml * Drop Python 3.9 support * Update master for stable/2025.2 6.1.0 ----- * Add build-system to pyproject.toml 6.0.0 ----- * pre-commit: Add ruff * Move mypy configuration to pyproject.toml * Enable strict typing * Remove support for deprecated settings * Fix outdated argument in doc examples * Update master for stable/2025.1 5.7.1 ----- * Skip installation to speed up pep8 * reno: Update master for unmaintained/2023.1 5.7.0 ----- * Stop setting deprecated fields in redacted\_copy * Add note about requirements lower bounds * Run pyupgrade to clean up Python 2 syntaxes * Remove Python 3.8 support * Fix outdated tox minversion * Declare Python 3.12 support * Drop SETUPTOOLS\_USE\_DISTUTILS * Update master for stable/2024.2 5.6.0 ----- * reno: Update master for unmaintained/zed * Remove old excludes * pre-commit: Remove outdated comment * Update master for stable/2024.1 * reno: Update master for unmaintained/xena * reno: Update master for unmaintained/wallaby * reno: Update master for unmaintained/victoria 5.5.0 ----- * Add is\_admin to redacted context 5.4.0 ----- * reno: Update master for unmaintained/yoga * tox: Drop envdir * Bump hacking * Update python classifier in setup.cfg 5.3.0 ----- * pre-commit: Integrate bandit, mypy * pre-commit: Bump dependencies * Add method for getting redacted copy of context * Update master for stable/2023.2 * Bump bandit 5.2.0 ----- * Revert "Moves supported python runtimes from version 3.8 to 3.10" * Moves supported python runtimes from version 3.8 to 3.10 * Update master for stable/2023.1 5.1.1 ----- * Fix the docs job 5.1.0 ----- * Add Python3 antelope unit tests * Update master for stable/zed * Cleanup py27 support 5.0.0 ----- * Drop python3.6/3.7 support in testing runtime * Remove unnecessary unicode prefixes * Add Python3 zed unit tests * Update master for stable/yoga 4.1.0 ----- * Integrate mypy 4.0.0 ----- * Don't test with setuptools local distutils * Remove the deprecated argument tenant from RequestContext 3.4.0 ----- * Add Python3 yoga unit tests * Update master for stable/xena * Fix context from\_dict() for system\_scope 3.3.1 ----- 3.3.0 ----- * setup.cfg: Replace dashes with underscores * Ussuri+ is python3 only and update python to python3 * Fix formatting of release list * Move flake8 as a pre-commit local target * Add Python3 xena unit tests * Update master for stable/wallaby * Remove lower-constraints remnants * Drop use of deprecated collections classes 3.2.0 ----- * Switch to collections.abc.MutableMapping * Dropping lower constraints testing * Use TOX\_CONSTRAINTS\_FILE * Use py3 as the default runtime for tox * Add Python3 wallaby unit tests * Update master for stable/victoria * Adding pre-commit 3.1.1 ----- * Bump bandit version * drop mock from lower-constraints * Fix pygments style 3.1.0 ----- * Remove translation sections from setup.cfg * Fix hacking min version to 3.0.1 * Switch to newer openstackdocstheme and reno versions * Remove the unused coding style modules * Align contributing doc with oslo's policy * Bump default tox env from py37 to py38 * Add py38 package metadata * Add release notes links to doc index * Add Python3 victoria unit tests * Update master for stable/ussuri 3.0.2 ----- * Don't build universal wheel 3.0.1 ----- * Update hacking for Python3 * Filter out auth\_token\_info from logging values * trivial: Cleanup tox.ini * remove outdated header * reword releasenote for py27 support dropping 3.0.0 ----- * Drop python 2.7 support and testing * tox: Trivial cleanup * tox: Trivial cleanup * Bump the openstackdocstheme extension to 1.20 * gitignore: Hide reno cache files * tox: Stop using 'python setup.py test' * Switch to Ussuri jobs * tox: Keeping going with docs * Switch to Ussuri jobs * Update the constraints url * Update master for stable/train 2.23.0 ------ * Add Python 3 Train unit tests * Cap Bandit below 1.6.0 and update Sphinx requirement * Replace git.openstack.org URLs with opendev.org URLs * OpenDev Migration Patch * Dropping the py35 testing * Update master for stable/stein 2.22.1 ------ * add python 3.7 unit test job * Update hacking version * Use template for lower-constraints * Update mailinglist from dev to discuss 2.22.0 ------ * Implement domain-scope for context objects * Clean up .gitignore references to personal tools * Always build universal wheels * add lib-forward-testing-python3 test job * add python 3.6 unit test job * import zuul job settings from project-config * import zuul job settings from project-config * Update reno for stable/rocky * Switch to stestr * Add release notes link to README * fix tox python3 overrides 2.21.0 ------ * Implement system-scope * Remove stale pip-missing-reqs tox test * Trivial: Update pypi url to new url * Switch pep8 job to python 3 * add lower-constraints job * pypy not checked at gate * Updated from global requirements * Update links in README * Add -W for document build * Update reno for stable/queens * Updated from global requirements * Updated from global requirements * Updated from global requirements * Updated from global requirements 2.20.0 ------ * Updated from global requirements * Follow the new PTI for document build * Remove -U from pip install * Avoid tox\_install.sh for constraints support * add bandit to pep8 job * Remove setting of version/release from releasenotes 2.19.3 ------ * Ouput a placeholder instead of the auth\_token 2.19.2 ------ * Make from\_dict extensible 2.19.1 ------ * Output 'project' key in context's to\_dict function * Rename deprecated context params 2.19.0 ------ * Updated from global requirements 2.18.1 ------ * Update the documentation link for doc migration * Revert "Postpone deprecation warnings to Pike" 2.18.0 ------ * Updated from global requirements * Remove use of positional decorator * Update reno for stable/pike * Updated from global requirements 2.17.0 ------ * Fix URLs according to document migration * Cleanup document formatting * rearrange the documentation to fit into the new standard layout 2.16.0 ------ * Switch from oslosphinx to openstackdocstheme * Updated from global requirements 2.15.0 ------ * Optimize the link address * Remove pbr warnerrors in favor of sphinx check * Updated from global requirements 2.14.0 ------ * Provide unified calling interface for global\_id * Add global\_request\_id to context * Updated from global requirements * Updated from global requirements * Updated from global requirements 2.13.0 ------ * Updated from global requirements * [Fix gate]Update test requirement * Updated from global requirements * pbr.version.VersionInfo needs package name (oslo.xyz and not oslo\_xyz) * Postpone deprecation warnings to Pike * Update reno for stable/ocata 2.12.0 ------ * Updated from global requirements * Remove references to Python 3.4 * Add Constraints support * Show team and repo badges on README * Add the service token details to context * Reformat the Context.\_\_init\_\_ arguments * Move existing attributes to \_id suffixed attributes 2.11.0 ------ * Updated from global requirements * Revert "Fix X-User and X-Tenant deprecated headers in from\_environ" * Updated from global requirements * Updated from global requirements * Changed the home-page link 2.10.0 ------ * Enable release notes translation * Updated from global requirements * Provide a way to deprecate policy values * Update reno for stable/newton * Fix typos * Fix X-User and X-Tenant deprecated headers in from\_environ 2.9.0 ----- * Updated from global requirements 2.8.0 ----- * Delete H803 in flake8 ignore list * Fix parameters of assertEqual are misplaced * Manually specify from\_dict parameters 2.7.0 ----- * Add Python 3.5 classifier and venv * Emit deprecation warnings when positional args passed 2.6.0 ----- * Allow deprecated X-Tenant-Name in from\_environ * Handle openstack.request\_id in from\_environ * Add is\_admin\_project to context * Updated from global requirements 2.5.0 ----- * Add reno for releasenotes management * Add oslo.context name attributes matching ids 2.4.0 ----- * Trivial: ignore openstack/common in flake8 exclude list * Strip roles in from\_environ * Allow deprecated headers in from\_environ 2.3.0 ----- * Drop babel as requirement since its not used * Updated from global requirements * Ensure to\_dict() supports unicode 2.2.0 ----- * Standardize an oslo.policy credentials dictionary * Revert "Add common oslo.log format parameters" * Add roles to context 2.1.0 ----- * Agnostic approach to construct context from\_dict * Add common oslo.log format parameters 2.0.0 ----- * Improve Context docs with example syntax * Define method for oslo.log context parameters * Add additional unit tests * Fix request\_id type on Python 3: use text (Unicode) * Updated from global requirements * Provide a helper to load a context from environment 1.0.1 ----- * Revert "Add properties for id attributes" * Add properties for id attributes * Trival: Remove 'MANIFEST.in' 1.0.0 ----- * Updated from global requirements * Remove python 2.6 classifier * Remove python 2.6 and cleanup tox.ini 0.9.0 ----- * Remove reference to undefined attributes 0.8.0 ----- * Fix coverage configuration and execution 0.7.0 ----- * Add shields.io version/downloads links/badges into README.rst * Change ignore-errors to ignore\_errors * Updated from global requirements 0.6.0 ----- * Updated from global requirements * Updated from global requirements * Updated from global requirements 0.5.0 ----- * Updated from global requirements * Updated from global requirements * Add tox target to find missing requirements * Updated from global requirements * Updated from global requirements 0.4.0 ----- * Remove support for Python 3.3 * Do not sync run\_cross\_tests.sh * Updated from global requirements 0.3.0 ----- * Uncap library requirements for liberty * Standardize setup.cfg summary for oslo libs * Update to latest hacking * Updated from global requirements * fix bug tracker link 0.2.0 ----- * ensure we reset contexts when fixture is used * Activate pep8 check that \_ is imported 0.1.0 ----- * Workflow documentation is now in infra-manual * Documentation cleanup * Add ClearRequestContext fixture * Cache the current context for the thread * Add docstring to get\_admin\_context() * Change instance\_uuid to resource\_uuid * Better information in the README * Generate better documentation for the module * Move out of the oslo namespace package * get test to actually run * fix links and requirements to latest versions * Make the unit test run properly - fix import * exported from oslo-incubator by graduate.sh * Add a RequestContext.from\_dict method * Use oslotest instead of common test module * Python 3: enable tests/unit/middleware/test\_request\_id.py * Add model\_query() to db.sqlalchemy.utils module * Adding domain to context and log * Remove vim header * Remove uuidutils imports in oslo modules * Revert "Removes generate\_uuid from uuidutils" * Removes generate\_uuid from uuidutils * Adding instance\_uuid to context and log * Replace using tests.utils with openstack.common.test * Fix bad default for show\_deleted * Enable hacking H404 test * Replaces the standard uuid with common in the context module * Fix Copyright Headers - Rename LLC to Foundation * Fix inconsistency with auth\_tok/auth\_token * Replace direct use of testtools BaseTestCase * Use testtools as test base class * Move get\_context\_from\_function\_and\_args() to context.py * Added dictify() and uuids to the common request context * add context 'tests' * make the skeleton project a template * reog from import merge * Add some more generic middleware, request context, utils, and versioning. Add basic template for server binary * Initial skeleton project ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/HACKING.rst0000664000175000017500000000022215224173710014660 0ustar00zuulzuuloslo.context Style Commandments =============================== Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/LICENSE0000664000175000017500000002363715224173710014106 0ustar00zuulzuul Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.2183352 oslo_context-6.5.0/PKG-INFO0000644000175000017500000000430115224173771014166 0ustar00zuulzuulMetadata-Version: 2.4 Name: oslo.context Version: 6.5.0 Summary: Oslo Context library Author-email: OpenStack License-Expression: Apache-2.0 Project-URL: Homepage, https://docs.openstack.org/oslo.context Project-URL: Repository, https://opendev.org/openstack/oslo.context Classifier: Environment :: OpenStack Classifier: Intended Audience :: Information Technology Classifier: Intended Audience :: System Administrators Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: 3.14 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Typing :: Typed Requires-Python: >=3.11 Description-Content-Type: text/x-rst License-File: LICENSE Requires-Dist: pbr>=2.0.0 Requires-Dist: typing-extensions>=4.12.0 Dynamic: license-file Dynamic: requires-dist ==================== Oslo Context Library ==================== .. image:: https://governance.openstack.org/tc/badges/oslo.context.svg :target: https://governance.openstack.org/tc/reference/projects/oslo.html .. image:: https://img.shields.io/pypi/v/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Latest Version .. image:: https://img.shields.io/pypi/dm/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Downloads .. image:: https://img.shields.io/pypi/types/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Typing Status The oslo.context library has helpers to maintain useful information about a request context. The request context is usually populated in the WSGI pipeline and used by various modules such as logging. * License: Apache License, Version 2.0 * Documentation: https://docs.openstack.org/oslo.context/latest/ * Source: https://opendev.org/openstack/oslo.context * Bugs: https://bugs.launchpad.net/oslo.context * Release notes: https://docs.openstack.org/releasenotes/oslo.context/ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/README.rst0000664000175000017500000000207715224173710014563 0ustar00zuulzuul==================== Oslo Context Library ==================== .. image:: https://governance.openstack.org/tc/badges/oslo.context.svg :target: https://governance.openstack.org/tc/reference/projects/oslo.html .. image:: https://img.shields.io/pypi/v/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Latest Version .. image:: https://img.shields.io/pypi/dm/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Downloads .. image:: https://img.shields.io/pypi/types/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Typing Status The oslo.context library has helpers to maintain useful information about a request context. The request context is usually populated in the WSGI pipeline and used by various modules such as logging. * License: Apache License, Version 2.0 * Documentation: https://docs.openstack.org/oslo.context/latest/ * Source: https://opendev.org/openstack/oslo.context * Bugs: https://bugs.launchpad.net/oslo.context * Release notes: https://docs.openstack.org/releasenotes/oslo.context/ ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.1993332 oslo_context-6.5.0/doc/0000775000175000017500000000000015224173771013642 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/requirements.txt0000664000175000017500000000023415224173710017116 0ustar00zuulzuul# These are needed for docs generation openstackdocstheme>=2.2.0 # Apache-2.0 sphinx>=2.0.0 # BSD reno>=3.1.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1783691257.200333 oslo_context-6.5.0/doc/source/0000775000175000017500000000000015224173771015142 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/conf.py0000664000175000017500000000467415224173710016445 0ustar00zuulzuul# Copyright (C) 2020 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys sys.path.insert(0, os.path.abspath('../..')) # -- General configuration ---------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'openstackdocstheme', ] # autodoc generation is a bit aggressive and a nuisance when doing heavy # text edit cycles. # execute "export SPHINX_DEBUG=1" in your terminal to disable # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = 'oslo.context' copyright = '2016, OpenStack Foundation' # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). add_module_names = True # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'native' # -- Options for HTML output -------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. # html_theme_path = ["."] # html_static_path = ['static'] html_theme = 'openstackdocs' # Output file base name for HTML help builder. htmlhelp_basename = f'{project}doc' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ ( 'index', f'{project}.tex', f'{project} Documentation', 'OpenStack Foundation', 'manual', ), ] # openstackdocstheme options openstackdocs_repo_name = 'openstack/oslo.context' openstackdocs_bug_project = 'oslo.context' openstackdocs_bug_tag = '' ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1783691257.200333 oslo_context-6.5.0/doc/source/contributor/0000775000175000017500000000000015224173771017514 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/contributor/index.rst0000664000175000017500000000012415224173710021343 0ustar00zuulzuul============== Contributing ============== .. include:: ../../../CONTRIBUTING.rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/index.rst0000664000175000017500000000067415224173710017003 0ustar00zuulzuul.. include:: ../../README.rst Contents ======== .. toctree:: :maxdepth: 2 install/index user/index contributor/index Code Documentation ================== .. toctree:: :maxdepth: 1 reference/index Release Notes ============= Read also the `oslo.context Release Notes `_. Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1783691257.200333 oslo_context-6.5.0/doc/source/install/0000775000175000017500000000000015224173771016610 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/install/index.rst0000664000175000017500000000013615224173710020442 0ustar00zuulzuul============ Installation ============ At the command line:: $ pip install oslo.context ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.2013333 oslo_context-6.5.0/doc/source/reference/0000775000175000017500000000000015224173771017100 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/reference/context.rst0000664000175000017500000000024715224173710021312 0ustar00zuulzuulThe :mod:`oslo_context.context` Module ====================================== .. automodule:: oslo_context.context :members: :undoc-members: :show-inheritance: ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/reference/fixture.rst0000664000175000017500000000024715224173710021314 0ustar00zuulzuulThe :mod:`oslo_context.fixture` Module ====================================== .. automodule:: oslo_context.fixture :members: :undoc-members: :show-inheritance: ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/reference/index.rst0000664000175000017500000000014715224173710020734 0ustar00zuulzuul============= API reference ============= .. toctree:: :maxdepth: 1 context.rst fixture.rst ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.2023335 oslo_context-6.5.0/doc/source/user/0000775000175000017500000000000015224173771016120 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.2033336 oslo_context-6.5.0/doc/source/user/examples/0000775000175000017500000000000015224173771017736 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/user/examples/usage.py0000664000175000017500000000276115224173710021413 0ustar00zuulzuul#!/usr/bin/env python3 # # Copyright (c) 2015 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """A representative usage example of Oslo Context This example requires the following modules to be installed. $ pip install oslo.context oslo.log More information can be found at: https://docs.openstack.org/oslo.context/latest/user/usage.html """ from oslo_config import cfg from oslo_context import context from oslo_log import log as logging CONF = cfg.CONF DOMAIN = "demo" logging.register_options(CONF) logging.setup(CONF, DOMAIN) LOG = logging.getLogger(__name__) LOG.info("Message without context") # ids in Openstack are 32 characters long # For readability a shorter id value is used context.RequestContext( user_id='6ce90b4d', project_id='d6134462', project_domain_id='a6b9360e' ) LOG.info("Message with context") context = context.RequestContext( user_id='ace90b4d', project_id='b6134462', project_domain_id='c6b9360e' ) LOG.info("Message with passed context", context=context) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/user/examples/usage_simple.py0000664000175000017500000000223315224173710022756 0ustar00zuulzuul#!/usr/bin/env python3 # # Copyright (c) 2015 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """A simple usage example of Oslo Context This example requires the following modules to be installed. $ pip install oslo.context oslo.log More information can be found at: https://docs.openstack.org/oslo.context/latest/user/usage.html """ from oslo_config import cfg from oslo_context import context from oslo_log import log as logging CONF = cfg.CONF DOMAIN = "demo" logging.register_options(CONF) logging.setup(CONF, DOMAIN) LOG = logging.getLogger(__name__) LOG.info("Message without context") context.RequestContext() LOG.info("Message with context") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/user/examples/usage_user_identity.py0000664000175000017500000000271215224173710024356 0ustar00zuulzuul#!/usr/bin/env python3 # # Copyright (c) 2015 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """A usage example of Oslo Context with user_identity This example requires the following modules to be installed. $ pip install oslo.context oslo.log More information can be found at: https://docs.openstack.org/oslo.context/latest/user/index.html """ from oslo_config import cfg from oslo_context import context from oslo_log import log as logging CONF = cfg.CONF DOMAIN = "demo" logging.register_options(CONF) CONF.logging_user_identity_format = ( "%(user_id)s/%(project_id)s@%(project_domain)s" ) logging.setup(CONF, DOMAIN) LOG = logging.getLogger(__name__) LOG.info("Message without context") # ids in Openstack are 32 characters long # For readability a shorter id value is used context.RequestContext( request_id='req-abc', user_id='6ce90b4d', project_id='d6134462', project_domain_id='a6b9360e', ) LOG.info("Message with context") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/user/examples.rst0000664000175000017500000000132115224173710020456 0ustar00zuulzuul========== Examples ========== .. _examples: These files can be found in the doc/source/examples directory of the git source of this project. They can also be found at the `online git repository`_ of this project. .. _online git repository: https://opendev.org/openstack/oslo.context/src/branch/master/doc/source/user/examples .. _example_usage_simple.py: usage_simple.py --------------- .. highlight:: python .. literalinclude:: examples/usage_simple.py :linenos: .. _example_usage.py: usage.py -------- .. literalinclude:: examples/usage.py :linenos: .. _example_usage_user_identity.py: usage_user_identity.py ---------------------- .. literalinclude:: examples/usage_user_identity.py :linenos: ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/user/history.rst0000664000175000017500000000004015224173710020336 0ustar00zuulzuul.. include:: ../../../ChangeLog ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/user/index.rst0000664000175000017500000000033715224173710017755 0ustar00zuulzuul================== Using oslo.context ================== .. toctree:: :maxdepth: 2 usage examples .. history contains a lot of sections, toctree with maxdepth 1 is used. .. toctree:: :maxdepth: 1 history ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/doc/source/user/usage.rst0000664000175000017500000001066615224173710017760 0ustar00zuulzuul======= Usage ======= oslo.context is used in conjunction with `oslo.log`_ to provide context aware log records when specifying a :class:`~oslo_context.context.RequestContext` object. This code example demonstrates two INFO log records with varying output format due to the use of RequestContext. .. _oslo.log: https://docs.openstack.org/oslo.log/latest/ .. highlight:: python .. literalinclude:: examples/usage_simple.py :linenos: :lines: 28-42 :emphasize-lines: 2,14 Source: :ref:`example_usage_simple.py` **Example Logging Output:** .. code-block:: none 2016-01-20 21:56:29.283 8428 INFO __main__ [-] Message without context 2016-01-20 21:56:29.284 8428 INFO __main__ [req-929d23e9-f50e-46ae-a8a7-02bc8c3fd2c8 - - - - -] Message with context The format of these log records are defined by the `logging_default_format_string`_ and `logging_context_format_string`_ configuration options respectively. The `logging_user_identity_format`_ option also provides further context aware definition flexibility. .. _logging_default_format_string: https://docs.openstack.org/oslo.log/latest/configuration/index.html#DEFAULT.logging_default_format_string .. _logging_context_format_string: https://docs.openstack.org/oslo.log/latest/configuration/index.html#DEFAULT.logging_context_format_string .. _logging_user_identity_format: https://docs.openstack.org/oslo.log/latest/configuration/index.html#DEFAULT.logging_user_identity_format ----------------- Context Variables ----------------- The oslo.context variables used in the **logging_context_format_string** and **logging_user_identity_format** configuration options include: * global_request_id - A request id (e.g. req-9f2c484a-b504-4fd9-b44c-4357544cca50) which may have been sent in from another service to indicate this is part of a chain of requests. * request_id - A request id (e.g. req-9f2c484a-b504-4fd9-b44c-4357544cca50) * user - A user id (e.g. e5bc7033e6b7473c9fe8ee1bd4df79a3) * tenant - A tenant/project id (e.g. 79e338475db84f7c91ee4e86b79b34c1) * domain - A domain id * user_domain - A user domain id * project_domain - A project domain id This code example demonstrates defining a context with specific attributes that are presented in the output log record. .. literalinclude:: examples/usage.py :linenos: :lines: 28-46 :emphasize-lines: 2,16-18 Source: :ref:`example_usage.py` **Example Logging Output:** .. code-block:: none 2016-01-21 17:30:50.263 12201 INFO __main__ [-] Message without context 2016-01-21 17:30:50.264 12201 INFO __main__ [req-e591e881-36c3-4627-a5d8-54df200168ef 6ce90b4d d6134462 - - a6b9360e] Message with context A context object can also be passed as an argument to any logging level message. .. literalinclude:: examples/usage.py :linenos: :lines: 48-51 :emphasize-lines: 4 **Example Logging Output:** .. code-block:: none 2016-01-21 22:43:55.621 17295 INFO __main__ [req-ac2d4a3a-ff3c-4c2b-97a0-2b76b33d9e72 ace90b4d b6134462 - - c6b9360e] Message with passed context .. note:: To maintain consistent log messages for operators across multiple OpenStack projects it is highly recommended that **logging_default_format_string** and **logging_context_format_string** are not modified from oslo.log default values. -------------------------- Project Specific Variables -------------------------- Individual projects can also subclass :class:`~oslo_context.context.RequestContext` to provide additional attributes that can be using with oslo.log. The Nova `RequestContext`_ class for example provides additional variables including user_name and project_name. .. _RequestContext: https://opendev.org/openstack/nova/src/branch/master/nova/context.py This can for example enable the defining of **logging_user_identity_format = %(user_name)s %(project_name)s** which would produce a log record containing a context portion using names instead of ids such as **[req-e4b9a194-a9b1-4829-b7d0-35226fc101fc admin demo]** This following code example shows how a modified **logging_user_identity_format** configuration alters the context portion of the log record. .. literalinclude:: examples/usage_user_identity.py :linenos: :lines: 28-48 :emphasize-lines: 9 Source: :ref:`example_usage_user_identity.py` **Example Logging Output:** .. code-block:: none 2016-01-21 20:56:43.964 14816 INFO __main__ [-] Message without context 2016-01-21 20:56:43.965 14816 INFO __main__ [req-abc 6ce90b4d/d6134462@a6b9360e] Message with context ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1783691257.217335 oslo_context-6.5.0/oslo.context.egg-info/0000775000175000017500000000000015224173771017226 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/oslo.context.egg-info/PKG-INFO0000644000175000017500000000430115224173771020317 0ustar00zuulzuulMetadata-Version: 2.4 Name: oslo.context Version: 6.5.0 Summary: Oslo Context library Author-email: OpenStack License-Expression: Apache-2.0 Project-URL: Homepage, https://docs.openstack.org/oslo.context Project-URL: Repository, https://opendev.org/openstack/oslo.context Classifier: Environment :: OpenStack Classifier: Intended Audience :: Information Technology Classifier: Intended Audience :: System Administrators Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: 3.14 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Typing :: Typed Requires-Python: >=3.11 Description-Content-Type: text/x-rst License-File: LICENSE Requires-Dist: pbr>=2.0.0 Requires-Dist: typing-extensions>=4.12.0 Dynamic: license-file Dynamic: requires-dist ==================== Oslo Context Library ==================== .. image:: https://governance.openstack.org/tc/badges/oslo.context.svg :target: https://governance.openstack.org/tc/reference/projects/oslo.html .. image:: https://img.shields.io/pypi/v/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Latest Version .. image:: https://img.shields.io/pypi/dm/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Downloads .. image:: https://img.shields.io/pypi/types/oslo.context :target: https://pypi.org/project/oslo.context/ :alt: Typing Status The oslo.context library has helpers to maintain useful information about a request context. The request context is usually populated in the WSGI pipeline and used by various modules such as logging. * License: Apache License, Version 2.0 * Documentation: https://docs.openstack.org/oslo.context/latest/ * Source: https://opendev.org/openstack/oslo.context * Bugs: https://bugs.launchpad.net/oslo.context * Release notes: https://docs.openstack.org/releasenotes/oslo.context/ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/oslo.context.egg-info/SOURCES.txt0000664000175000017500000000502315224173771021112 0ustar00zuulzuul.coveragerc .mailmap .pre-commit-config.yaml .stestr.conf .zuul.yaml AUTHORS CONTRIBUTING.rst ChangeLog HACKING.rst LICENSE README.rst pyproject.toml requirements.txt setup.cfg setup.py test-requirements.txt tox.ini doc/requirements.txt doc/source/conf.py doc/source/index.rst doc/source/contributor/index.rst doc/source/install/index.rst doc/source/reference/context.rst doc/source/reference/fixture.rst doc/source/reference/index.rst doc/source/user/examples.rst doc/source/user/history.rst doc/source/user/index.rst doc/source/user/usage.rst doc/source/user/examples/usage.py doc/source/user/examples/usage_simple.py doc/source/user/examples/usage_user_identity.py oslo.context.egg-info/PKG-INFO oslo.context.egg-info/SOURCES.txt oslo.context.egg-info/dependency_links.txt oslo.context.egg-info/not-zip-safe oslo.context.egg-info/pbr.json oslo.context.egg-info/requires.txt oslo.context.egg-info/top_level.txt oslo_context/__init__.py oslo_context/context.py oslo_context/fixture.py oslo_context/py.typed oslo_context/version.py oslo_context/tests/__init__.py oslo_context/tests/test_context.py oslo_context/tests/test_fixture.py releasenotes/notes/Fix-system-scope-from_dict-29615af90723ba4d.yaml releasenotes/notes/add_reno-3b4ae0789e9c45b4.yaml releasenotes/notes/deprecate-version-module-b47fc41720b5b49f.yaml releasenotes/notes/dont-leak-auth-token-fb7075316cf87b7c.yaml releasenotes/notes/drop-python27-support-b421329839e69d41.yaml releasenotes/notes/redacted-copy-efd02c83c287451f.yaml releasenotes/notes/remove-deprecated-args-044bc6bd79638988.yaml releasenotes/notes/remove-py310-7a3e24d4c60d5485.yaml releasenotes/notes/remove-py38-f21fbda6dac198c4.yaml releasenotes/notes/remove-py39-643032e829d29b78.yaml releasenotes/notes/remove_deprecated_args_tenant-77724de1422f46d9.yaml releasenotes/source/2023.1.rst releasenotes/source/2023.2.rst releasenotes/source/2024.1.rst releasenotes/source/2024.2.rst releasenotes/source/2025.1.rst releasenotes/source/2025.2.rst releasenotes/source/2026.1.rst releasenotes/source/conf.py releasenotes/source/index.rst releasenotes/source/newton.rst releasenotes/source/ocata.rst releasenotes/source/pike.rst releasenotes/source/queens.rst releasenotes/source/rocky.rst releasenotes/source/stein.rst releasenotes/source/train.rst releasenotes/source/unreleased.rst releasenotes/source/ussuri.rst releasenotes/source/victoria.rst releasenotes/source/wallaby.rst releasenotes/source/xena.rst releasenotes/source/yoga.rst releasenotes/source/zed.rst releasenotes/source/_static/.placeholder releasenotes/source/_templates/.placeholder././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/oslo.context.egg-info/dependency_links.txt0000664000175000017500000000000115224173771023274 0ustar00zuulzuul ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/oslo.context.egg-info/not-zip-safe0000664000175000017500000000000115224173771021454 0ustar00zuulzuul ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/oslo.context.egg-info/pbr.json0000664000175000017500000000005615224173771020705 0ustar00zuulzuul{"git_version": "6cd5aaa", "is_release": true}././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/oslo.context.egg-info/requires.txt0000664000175000017500000000004515224173771021625 0ustar00zuulzuulpbr>=2.0.0 typing-extensions>=4.12.0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691257.0 oslo_context-6.5.0/oslo.context.egg-info/top_level.txt0000664000175000017500000000001515224173771021754 0ustar00zuulzuuloslo_context ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1783691257.207334 oslo_context-6.5.0/oslo_context/0000775000175000017500000000000015224173771015615 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/oslo_context/__init__.py0000664000175000017500000000000015224173710017705 0ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/oslo_context/context.py0000664000175000017500000004711315224173710017652 0ustar00zuulzuul# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Base class for holding contextual information of a request This class has several uses: * Used for storing security information in a web request. * Used for passing contextual details to oslo.log. Projects should subclass this class if they wish to enhance the request context or provide additional information in their specific WSGI pipeline or logging context. """ import collections.abc import itertools import threading import typing as ty import uuid import warnings import typing_extensions as ty_ext if ty.TYPE_CHECKING: _MutableMapping = collections.abc.MutableMapping[str, ty.Any] else: _MutableMapping = collections.abc.MutableMapping _request_store = threading.local() # These arguments will be passed to a new context from the first available # header to support backwards compatibility. _ENVIRON_HEADERS: dict[str, list[str]] = { 'auth_token': ['HTTP_X_AUTH_TOKEN', 'HTTP_X_STORAGE_TOKEN'], 'user_id': ['HTTP_X_USER_ID', 'HTTP_X_USER'], 'project_id': ['HTTP_X_PROJECT_ID', 'HTTP_X_TENANT_ID', 'HTTP_X_TENANT'], 'domain_id': ['HTTP_X_DOMAIN_ID'], 'domain_name': ['HTTP_X_DOMAIN_NAME'], 'system_scope': ['HTTP_OPENSTACK_SYSTEM_SCOPE'], 'user_domain_id': ['HTTP_X_USER_DOMAIN_ID'], 'project_domain_id': ['HTTP_X_PROJECT_DOMAIN_ID'], 'user_name': ['HTTP_X_USER_NAME'], 'project_name': ['HTTP_X_PROJECT_NAME', 'HTTP_X_TENANT_NAME'], 'user_domain_name': ['HTTP_X_USER_DOMAIN_NAME'], 'project_domain_name': ['HTTP_X_PROJECT_DOMAIN_NAME'], 'request_id': ['openstack.request_id'], 'global_request_id': ['openstack.global_request_id'], 'service_token': ['HTTP_X_SERVICE_TOKEN'], 'service_user_id': ['HTTP_X_SERVICE_USER_ID'], 'service_user_name': ['HTTP_X_SERVICE_USER_NAME'], 'service_user_domain_id': ['HTTP_X_SERVICE_USER_DOMAIN_ID'], 'service_user_domain_name': ['HTTP_X_SERVICE_USER_DOMAIN_NAME'], 'service_project_id': ['HTTP_X_SERVICE_PROJECT_ID'], 'service_project_name': ['HTTP_X_SERVICE_PROJECT_NAME'], 'service_project_domain_id': ['HTTP_X_SERVICE_PROJECT_DOMAIN_ID'], 'service_project_domain_name': ['HTTP_X_SERVICE_PROJECT_DOMAIN_NAME'], } def generate_request_id() -> str: """Generate a unique request id.""" return f'req-{uuid.uuid4()}' class _DeprecatedPolicyValues(_MutableMapping): """A Dictionary that manages current and deprecated policy values. Anything added to this dictionary after initial creation is considered a deprecated key that we are trying to move services away from. Accessing these values as oslo.policy will do will trigger a DeprecationWarning. """ def __init__(self, data: dict[str, ty.Any]): self._data = data self._deprecated: dict[str, ty.Any] = {} def __getitem__(self, k: str) -> ty.Any: try: return self._data[k] except KeyError: pass try: val = self._deprecated[k] except KeyError: pass else: warnings.warn( 'Policy enforcement is depending on the value of ' f'{k}. This key is deprecated. Please update your ' 'policy file to use the standard policy values.', DeprecationWarning, ) return val raise KeyError(k) def __setitem__(self, k: str, v: ty.Any) -> None: self._deprecated[k] = v def __delitem__(self, k: str) -> None: del self._deprecated[k] def __iter__(self) -> ty.Iterator[ty.Any]: return iter(self._dict) def __len__(self) -> int: return len(self._dict) def __str__(self) -> str: return self._dict.__str__() def __repr__(self) -> str: return self._dict.__repr__() @property def _dict(self) -> dict[str, ty.Any]: d = self._deprecated.copy() d.update(self._data) return d class RequestContext: """Helper class to represent useful information about a request context. Stores information about the security context under which the user accesses the system, as well as additional request information. """ user_idt_format = '{user} {project_id} {domain} {user_domain} {p_domain}' # Can be overridden in subclasses to specify extra keys that should be # read when constructing a context using from_dict. FROM_DICT_EXTRA_KEYS: list[str] = [] def __init__( self, auth_token: str | None = None, user_id: str | None = None, project_id: str | None = None, domain_id: str | None = None, user_domain_id: str | None = None, project_domain_id: str | None = None, is_admin: bool | None = False, read_only: bool = False, show_deleted: bool = False, request_id: str | None = None, resource_uuid: str | None = None, overwrite: bool = True, roles: list[str] | None = None, user_name: str | None = None, project_name: str | None = None, domain_name: str | None = None, user_domain_name: str | None = None, project_domain_name: str | None = None, is_admin_project: bool = True, service_token: str | None = None, service_user_id: str | None = None, service_user_name: str | None = None, service_user_domain_id: str | None = None, service_user_domain_name: str | None = None, service_project_id: str | None = None, service_project_name: str | None = None, service_project_domain_id: str | None = None, service_project_domain_name: str | None = None, service_roles: list[str] | None = None, global_request_id: str | None = None, system_scope: str | None = None, ): """Initialize the RequestContext :param overwrite: Set to False to ensure that the greenthread local copy of the index is not overwritten. :param is_admin_project: Whether the specified project is specified in the token as the admin project. Defaults to True for backwards compatibility. :param system_scope: The system scope of a token. The value ``all`` represents the entire deployment system. A service ID represents a specific service within the deployment system. """ # setting to private variables to avoid triggering subclass properties self.user_id = user_id self.project_id = project_id self.domain_id = domain_id self.user_domain_id = user_domain_id self.project_domain_id = project_domain_id self.auth_token = auth_token self.user_name = user_name self.project_name = project_name self.domain_name = domain_name self.system_scope = system_scope self.user_domain_name = user_domain_name self.project_domain_name = project_domain_name self._is_admin = is_admin self.is_admin_project = is_admin_project self.read_only = read_only self.show_deleted = show_deleted self.resource_uuid = resource_uuid self.roles = roles or [] self.service_token = service_token self.service_user_id = service_user_id self.service_user_name = service_user_name self.service_user_domain_id = service_user_domain_id self.service_user_domain_name = service_user_domain_name self.service_project_id = service_project_id self.service_project_name = service_project_name self.service_project_domain_id = service_project_domain_id self.service_project_domain_name = service_project_domain_name self.service_roles = service_roles or [] if not request_id: request_id = generate_request_id() self.request_id = request_id self.global_request_id = global_request_id if overwrite or not get_current(): self.update_store() def check_is_admin(self) -> bool | None: """The interface to implement is_admin check according to policy.""" return self._is_admin @property def is_admin(self) -> bool | None: if self._is_admin is None: self._is_admin = self.check_is_admin() return self._is_admin @is_admin.setter def is_admin(self, value: bool | None) -> None: self._is_admin = value def update_store(self) -> None: """Store the context in the current thread.""" _request_store.context = self def to_policy_values(self) -> _MutableMapping: """A dictionary of context attributes to enforce policy with. oslo.policy enforcement requires a dictionary of attributes representing the current logged in user on which it applies policy enforcement. This dictionary defines a standard list of attributes that should be available for enforcement across services. It is expected that services will often have to override this method with either deprecated values or additional attributes used by that service specific policy. """ # NOTE(jamielennox): We need a way to allow projects to provide old # deprecated policy values that trigger a warning when used in favour # of our standard ones. This object acts like a dict but only values # from oslo.policy don't show a warning. return _DeprecatedPolicyValues( { 'user_id': self.user_id, 'user_domain_id': self.user_domain_id, 'system_scope': self.system_scope, 'domain_id': self.domain_id, 'project_id': self.project_id, 'project_domain_id': self.project_domain_id, 'roles': self.roles, 'is_admin_project': self.is_admin_project, 'service_user_id': self.service_user_id, 'service_user_domain_id': self.service_user_domain_id, 'service_project_id': self.service_project_id, 'service_project_domain_id': self.service_project_domain_id, 'service_roles': self.service_roles, } ) def to_dict(self) -> dict[str, ty.Any]: """Return a dictionary of context attributes.""" user_idt = self.user_idt_format.format( user=self.user_id or '-', project_id=self.project_id or '-', domain=self.domain_id or '-', user_domain=self.user_domain_id or '-', p_domain=self.project_domain_id or '-', ) return { 'user': self.user_id, 'project_id': self.project_id, 'system_scope': self.system_scope, 'project': self.project_id, 'domain': self.domain_id, 'user_domain': self.user_domain_id, 'project_domain': self.project_domain_id, 'is_admin': self.is_admin, 'read_only': self.read_only, 'show_deleted': self.show_deleted, 'auth_token': self.auth_token, 'request_id': self.request_id, 'global_request_id': self.global_request_id, 'resource_uuid': self.resource_uuid, 'roles': self.roles, 'user_identity': user_idt, 'is_admin_project': self.is_admin_project, } def get_logging_values(self) -> dict[str, ty.Any]: """Return a dictionary of logging specific context attributes.""" values = { 'user_name': self.user_name, 'project_name': self.project_name, 'domain_name': self.domain_name, 'user_domain_name': self.user_domain_name, 'project_domain_name': self.project_domain_name, } values.update(self.to_dict()) if self.auth_token: # NOTE(jaosorior): Gotta obfuscate the token since this dict is # meant for logging and we shouldn't leak it. values['auth_token'] = '***' # noqa: S105 else: values['auth_token'] = None # NOTE(bnemec: auth_token_info isn't defined in oslo.context, but it's # a common pattern in project context subclasses so we handle it here. # It largely contains things that we don't want logged, like the token # itself (which needs to be removed for security) and the catalog # (which needs to be removed because it bloats the logs terribly). values.pop('auth_token_info', None) return values @property def global_id(self) -> str: """Return a sensible value for global_id to pass on. When we want to make a call with to another service, it's important that we try to use global_request_id if available, and fall back to the locally generated request_id if not. """ return self.global_request_id or self.request_id def redacted_copy(self, **kwargs: ty.Any) -> ty_ext.Self: """Return a copy of the context with sensitive fields redacted. This is useful for creating a context that can be safely logged. :returns: A copy of the context with sensitive fields redacted. """ return self.__class__( user_id=self.user_id, project_id=self.project_id, domain_id=self.domain_id, user_domain_id=self.user_domain_id, project_domain_id=self.project_domain_id, request_id=self.request_id, roles=self.roles, user_name=self.user_name, project_name=self.project_name, domain_name=self.domain_name, user_domain_name=self.user_domain_name, project_domain_name=self.project_domain_name, service_user_id=self.service_user_id, service_user_domain_id=self.service_user_domain_id, service_user_domain_name=self.service_user_domain_name, service_project_id=self.service_project_id, service_project_name=self.service_project_name, service_project_domain_id=self.service_project_domain_id, service_project_domain_name=self.service_project_domain_name, service_roles=self.service_roles, global_request_id=self.global_request_id, system_scope=self.system_scope, is_admin=self.is_admin, **kwargs, ) @classmethod def from_dict( cls, values: dict[str, ty.Any], **kwargs: ty.Any ) -> ty_ext.Self: """Construct a context object from a provided dictionary.""" kwargs.setdefault('auth_token', values.get('auth_token')) kwargs.setdefault('user_id', values.get('user')) kwargs.setdefault('project_id', values.get('project_id')) kwargs.setdefault('domain_id', values.get('domain')) kwargs.setdefault('user_domain_id', values.get('user_domain')) kwargs.setdefault('project_domain_id', values.get('project_domain')) kwargs.setdefault('is_admin', values.get('is_admin', False)) kwargs.setdefault('read_only', values.get('read_only', False)) kwargs.setdefault('show_deleted', values.get('show_deleted', False)) kwargs.setdefault('request_id', values.get('request_id')) kwargs.setdefault('global_request_id', values.get('global_request_id')) kwargs.setdefault('resource_uuid', values.get('resource_uuid')) kwargs.setdefault('roles', values.get('roles')) kwargs.setdefault('user_name', values.get('user_name')) kwargs.setdefault('project_name', values.get('project_name')) kwargs.setdefault('domain_name', values.get('domain_name')) kwargs.setdefault('user_domain_name', values.get('user_domain_name')) kwargs.setdefault( 'project_domain_name', values.get('project_domain_name') ) kwargs.setdefault( 'is_admin_project', values.get('is_admin_project', True) ) kwargs.setdefault('system_scope', values.get('system_scope')) for key in cls.FROM_DICT_EXTRA_KEYS: kwargs.setdefault(key, values.get(key)) return cls(**kwargs) @classmethod def from_environ( cls, environ: dict[str, ty.Any], **kwargs: ty.Any ) -> ty_ext.Self: """Load a context object from a request environment. If keyword arguments are provided then they override the values in the request environment. :param environ: The environment dictionary associated with a request. :type environ: dict """ # Load a new context object from the environment variables set by # auth_token middleware. See: # https://docs.openstack.org/keystonemiddleware/latest/api/keystonemiddleware.auth_token.html#what-auth-token-adds-to-the-request-for-use-by-the-openstack-service # add kwarg if not specified by user from a list of possible headers for k, v_list in _ENVIRON_HEADERS.items(): if k in kwargs: continue for v in v_list: if v in environ: kwargs[k] = environ[v] break if 'roles' not in kwargs: roles = environ.get('HTTP_X_ROLES', environ.get('HTTP_X_ROLE')) roles = [r.strip() for r in roles.split(',')] if roles else [] kwargs['roles'] = roles if 'service_roles' not in kwargs: roles = environ.get('HTTP_X_SERVICE_ROLES') roles = [r.strip() for r in roles.split(',')] if roles else [] kwargs['service_roles'] = roles if 'is_admin_project' not in kwargs: # NOTE(jamielennox): we default is_admin_project to true because if # nothing is provided we have to assume it is the admin project to # make old policy continue to work. is_admin_proj_str = environ.get('HTTP_X_IS_ADMIN_PROJECT', 'true') kwargs['is_admin_project'] = is_admin_proj_str.lower() == 'true' return cls(**kwargs) def get_admin_context(show_deleted: bool = False) -> RequestContext: """Create an administrator context.""" context = RequestContext( None, project_id=None, is_admin=True, show_deleted=show_deleted, overwrite=False, ) return context def get_context_from_function_and_args( function: ty.Callable[..., ty.Any], args: list[ty.Any], kwargs: dict[str, ty.Any], ) -> RequestContext | None: """Find an arg of type RequestContext and return it. This is useful in a couple of decorators where we don't know much about the function we're wrapping. """ for arg in itertools.chain(kwargs.values(), args): if isinstance(arg, RequestContext): return arg return None def is_user_context(context: ty.Any) -> bool: """Indicates if the request context is a normal user.""" if not context or not isinstance(context, RequestContext): return False if context.is_admin: return False return True def get_current() -> RequestContext | None: """Return this thread's current context If no context is set, returns None """ return getattr(_request_store, 'context', None) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/oslo_context/fixture.py0000664000175000017500000000273015224173710017650 0ustar00zuulzuul# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import fixtures from oslo_context import context class ClearRequestContext(fixtures.Fixture): """Clears any cached RequestContext This resets RequestContext at the beginning and end of tests that use this fixture to ensure that we have a clean slate for running tests, and that we leave a clean slate for other tests that might run later in the same process. """ def setUp(self) -> None: super().setUp() # we need to clear both when we start, and when we finish, # because there might be other tests running that don't handle # this correctly. self._remove_cached_context() self.addCleanup(self._remove_cached_context) def _remove_cached_context(self) -> None: """Remove the thread-local context stored in the module.""" try: del context._request_store.context except AttributeError: pass ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/oslo_context/py.typed0000664000175000017500000000000015224173710017273 0ustar00zuulzuul././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1783691257.208334 oslo_context-6.5.0/oslo_context/tests/0000775000175000017500000000000015224173771016757 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/oslo_context/tests/__init__.py0000664000175000017500000000000015224173710021047 0ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/oslo_context/tests/test_context.py0000664000175000017500000006534115224173710022056 0ustar00zuulzuul# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import hashlib import uuid import warnings import fixtures from oslotest import base as test_base from oslo_context import context from oslo_context import fixture def generate_id(name): return hashlib.md5(name.encode('utf-8')).hexdigest() class WarningsFixture(fixtures.Fixture): def __init__(self, action="always", category=DeprecationWarning): super().__init__() self.action = action self.category = category def setUp(self): super().setUp() self._w = warnings.catch_warnings(record=True) self.log = self._w.__enter__() self.addCleanup(self._w.__exit__) # type: ignore warnings.simplefilter(self.action, self.category) def __len__(self): return len(self.log) def __getitem__(self, item): return self.log[item] class Object: pass class TestContext(context.RequestContext): """A test context with additional members This is representative of how at least some of our consumers use the RequestContext class in their projects. """ FROM_DICT_EXTRA_KEYS = ['auth_token_info'] def __init__(self, auth_token_info=None, **kwargs): super().__init__(**kwargs) self.auth_token_info = auth_token_info def to_dict(self): d = super().to_dict() d['auth_token_info'] = self.auth_token_info return d class ContextTest(test_base.BaseTestCase): def setUp(self): super().setUp() self.warnings = self.useFixture(WarningsFixture()) self.useFixture(fixture.ClearRequestContext()) def test_context(self): ctx = context.RequestContext() self.assertTrue(ctx) def test_store_when_no_overwrite(self): # If no context exists we store one even if overwrite is false # (since we are not overwriting anything). ctx = context.RequestContext(overwrite=False) self.assertIs(context.get_current(), ctx) def test_no_overwrite(self): # If there is already a context in the cache a new one will # not overwrite it if overwrite=False. ctx1 = context.RequestContext(overwrite=True) context.RequestContext(overwrite=False) self.assertIs(context.get_current(), ctx1) def test_admin_no_overwrite(self): # If there is already a context in the cache creating an admin # context will not overwrite it. ctx1 = context.RequestContext(overwrite=True) context.get_admin_context() self.assertIs(context.get_current(), ctx1) self.assertFalse(ctx1.is_admin) def test_store_current(self): # By default a new context is stored. ctx = context.RequestContext() self.assertIs(context.get_current(), ctx) def test_no_context(self): self.assertIsNone(context.get_current()) def test_admin_context_show_deleted_flag_default(self): ctx = context.get_admin_context() self.assertIsInstance(ctx, context.RequestContext) self.assertTrue(ctx.is_admin) self.assertFalse(ctx.show_deleted) self.assertIsNone(ctx.project_id) def test_admin_context_show_deleted_flag_set(self): ctx = context.get_admin_context(show_deleted=True) self.assertTrue(ctx.is_admin) self.assertTrue(ctx.show_deleted) def test_from_dict(self): dct = { "auth_token": "token1", "user": "user1", "user_name": "user1_name", "project_id": "tenant1", "project_name": "tenant1_name", "domain": "domain1", "domain_name": "domain1_name", "user_domain": "user_domain1", "user_domain_name": "user_domain1_name", "project_domain": "project_domain1", "project_domain_name": "project_domain1_name", "is_admin": True, "read_only": True, "show_deleted": True, "request_id": "request1", "global_request_id": "req-uuid", "resource_uuid": "instance1", "extra_data": "foo", "system_scope": "all", } ctx = context.RequestContext.from_dict(dct) self.assertEqual(dct['auth_token'], ctx.auth_token) self.assertEqual(dct['user'], ctx.user_id) self.assertEqual(dct['project_id'], ctx.project_id) self.assertEqual(dct['domain'], ctx.domain_id) self.assertEqual(dct['user_domain'], ctx.user_domain_id) self.assertEqual(dct['project_domain'], ctx.project_domain_id) self.assertTrue(ctx.is_admin) self.assertTrue(ctx.read_only) self.assertTrue(ctx.show_deleted) self.assertEqual(dct['request_id'], ctx.request_id) self.assertEqual(dct['global_request_id'], ctx.global_request_id) self.assertEqual(dct['resource_uuid'], ctx.resource_uuid) self.assertEqual(dct['user_name'], ctx.user_name) self.assertEqual(dct['project_name'], ctx.project_name) self.assertEqual(dct['domain_name'], ctx.domain_name) self.assertEqual(dct['user_domain_name'], ctx.user_domain_name) self.assertEqual(dct['project_domain_name'], ctx.project_domain_name) self.assertEqual(dct['system_scope'], ctx.system_scope) def test_from_dict_unknown_keys(self): dct = { "auth_token": "token1", "user": "user1", "read_only": True, "roles": "role1,role2,role3", # future review provides this "color": "red", "unknown": "", } ctx = context.RequestContext.from_dict(dct) self.assertEqual("token1", ctx.auth_token) self.assertEqual("user1", ctx.user_id) self.assertIsNone(ctx.project_id) self.assertFalse(ctx.is_admin) self.assertTrue(ctx.read_only) self.assertRaises(KeyError, lambda: ctx.__dict__['color']) def test_from_dict_overrides(self): dct = { "auth_token": "token1", "user_id": "user1", "read_only": True, "roles": "role1,role2,role3", "color": "red", "unknown": "", } ctx = context.RequestContext.from_dict( dct, user_id="user2", project_name="project1", ) self.assertEqual("token1", ctx.auth_token) self.assertEqual("user2", ctx.user_id) self.assertEqual("project1", ctx.project_name) self.assertIsNone(ctx.project_id) self.assertFalse(ctx.is_admin) self.assertTrue(ctx.read_only) def test_from_dict_extended(self): initial = TestContext(auth_token_info='foo') dct = initial.to_dict() final = TestContext.from_dict(dct) self.assertEqual('foo', final.auth_token_info) self.assertEqual(dct, final.to_dict()) def test_is_user_context(self): self.assertFalse(context.is_user_context(None)) ctx = context.RequestContext(is_admin=True) self.assertFalse(context.is_user_context(ctx)) ctx = context.RequestContext(is_admin=False) self.assertTrue(context.is_user_context(ctx)) self.assertFalse(context.is_user_context("non context object")) def test_from_environ_variables(self): auth_token = uuid.uuid4().hex user_name = uuid.uuid4().hex user_id = generate_id(user_name) project_name = uuid.uuid4().hex project_id = generate_id(project_name) domain_name = uuid.uuid4().hex domain_id = generate_id(domain_name) user_domain_name = uuid.uuid4().hex user_domain_id = generate_id(user_domain_name) project_domain_name = uuid.uuid4().hex project_domain_id = generate_id(project_domain_name) roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex] request_id = uuid.uuid4().hex global_request_id = uuid.uuid4().hex service_token = uuid.uuid4().hex service_user_id = uuid.uuid4().hex service_user_name = uuid.uuid4().hex service_user_domain_id = uuid.uuid4().hex service_user_domain_name = uuid.uuid4().hex service_project_id = uuid.uuid4().hex service_project_name = uuid.uuid4().hex service_project_domain_id = uuid.uuid4().hex service_project_domain_name = uuid.uuid4().hex service_roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex] environ = { 'HTTP_X_AUTH_TOKEN': auth_token, 'HTTP_X_USER_ID': user_id, 'HTTP_X_PROJECT_ID': project_id, 'HTTP_X_DOMAIN_ID': domain_id, 'HTTP_X_DOMAIN_NAME': domain_name, 'HTTP_X_USER_DOMAIN_ID': user_domain_id, 'HTTP_X_PROJECT_DOMAIN_ID': project_domain_id, 'HTTP_X_ROLES': ','.join(roles), 'HTTP_X_USER_NAME': user_name, 'HTTP_X_PROJECT_NAME': project_name, 'HTTP_X_USER_DOMAIN_NAME': user_domain_name, 'HTTP_X_PROJECT_DOMAIN_NAME': project_domain_name, 'HTTP_X_SERVICE_TOKEN': service_token, 'HTTP_X_SERVICE_USER_ID': service_user_id, 'HTTP_X_SERVICE_USER_NAME': service_user_name, 'HTTP_X_SERVICE_USER_DOMAIN_ID': service_user_domain_id, 'HTTP_X_SERVICE_USER_DOMAIN_NAME': service_user_domain_name, 'HTTP_X_SERVICE_PROJECT_ID': service_project_id, 'HTTP_X_SERVICE_PROJECT_NAME': service_project_name, 'HTTP_X_SERVICE_PROJECT_DOMAIN_ID': service_project_domain_id, 'HTTP_X_SERVICE_PROJECT_DOMAIN_NAME': service_project_domain_name, 'HTTP_X_SERVICE_ROLES': ','.join(service_roles), 'openstack.request_id': request_id, 'openstack.global_request_id': global_request_id, } ctx = context.RequestContext.from_environ(environ) self.assertEqual(auth_token, ctx.auth_token) self.assertEqual(user_id, ctx.user_id) self.assertEqual(user_name, ctx.user_name) self.assertEqual(project_id, ctx.project_id) self.assertEqual(project_name, ctx.project_name) self.assertEqual(domain_id, ctx.domain_id) self.assertEqual(domain_name, ctx.domain_name) self.assertEqual(user_domain_id, ctx.user_domain_id) self.assertEqual(user_domain_name, ctx.user_domain_name) self.assertEqual(project_domain_id, ctx.project_domain_id) self.assertEqual(project_domain_name, ctx.project_domain_name) self.assertEqual(roles, ctx.roles) self.assertEqual(request_id, ctx.request_id) self.assertEqual(global_request_id, ctx.global_request_id) self.assertEqual(service_token, ctx.service_token) self.assertEqual(service_user_id, ctx.service_user_id) self.assertEqual(service_user_name, ctx.service_user_name) self.assertEqual(service_user_domain_id, ctx.service_user_domain_id) self.assertEqual( service_user_domain_name, ctx.service_user_domain_name ) self.assertEqual(service_project_id, ctx.service_project_id) self.assertEqual(service_project_name, ctx.service_project_name) self.assertEqual( service_project_domain_id, ctx.service_project_domain_id ) self.assertEqual( service_project_domain_name, ctx.service_project_domain_name ) self.assertEqual(service_roles, ctx.service_roles) def test_from_environ_no_roles(self): ctx = context.RequestContext.from_environ(environ={}) self.assertEqual([], ctx.roles) ctx = context.RequestContext.from_environ(environ={'HTTP_X_ROLES': ''}) self.assertEqual([], ctx.roles) def test_from_environ_deprecated_variables(self): value = uuid.uuid4().hex environ = {'HTTP_X_USER': value} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(value, ctx.user_id) environ = {'HTTP_X_TENANT_ID': value} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(value, ctx.project_id) environ = {'HTTP_X_STORAGE_TOKEN': value} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(value, ctx.auth_token) environ = {'HTTP_X_TENANT': value} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(value, ctx.project_id) environ = {'HTTP_X_ROLE': value} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual([value], ctx.roles) environ = {'HTTP_X_TENANT_NAME': value} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(value, ctx.project_name) def test_from_environ_deprecated_precendence(self): old = uuid.uuid4().hex new = uuid.uuid4().hex override = uuid.uuid4().hex environ = {'HTTP_X_USER': old, 'HTTP_X_USER_ID': new} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(new, ctx.user_id) ctx = context.RequestContext.from_environ( environ=environ, user_id=override ) self.assertEqual(override, ctx.user_id) environ = {'HTTP_X_TENANT': old, 'HTTP_X_PROJECT_ID': new} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(new, ctx.project_id) ctx = context.RequestContext.from_environ( environ=environ, project_id=override ) self.assertEqual(override, ctx.project_id) environ = {'HTTP_X_TENANT_NAME': old, 'HTTP_X_PROJECT_NAME': new} ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(new, ctx.project_name) def test_from_environ_strip_roles(self): environ = { 'HTTP_X_ROLES': ' abc\t,\ndef\n,ghi\n\n', 'HTTP_X_SERVICE_ROLES': ' jkl\t,\nmno\n,pqr\n\n', } ctx = context.RequestContext.from_environ(environ=environ) self.assertEqual(['abc', 'def', 'ghi'], ctx.roles) self.assertEqual(['jkl', 'mno', 'pqr'], ctx.service_roles) def test_environ_admin_project(self): ctx = context.RequestContext.from_environ(environ={}) self.assertIs(True, ctx.is_admin_project) self.assertIs(True, ctx.to_policy_values()['is_admin_project']) ctx = context.RequestContext.from_environ( environ={'HTTP_X_IS_ADMIN_PROJECT': 'True'} ) self.assertIs(True, ctx.is_admin_project) self.assertIs(True, ctx.to_policy_values()['is_admin_project']) ctx = context.RequestContext.from_environ( environ={'HTTP_X_IS_ADMIN_PROJECT': 'False'} ) self.assertIs(False, ctx.is_admin_project) self.assertIs(False, ctx.to_policy_values()['is_admin_project']) def test_from_function_and_args(self): ctx = context.RequestContext(user_id="user1") ctx1 = context.get_context_from_function_and_args( context.get_context_from_function_and_args, [], {'c': ctx, 's': 's'}, ) self.assertIs(ctx1, ctx) def test_not_in_from_function_and_args(self): ctx1 = context.get_context_from_function_and_args( context.get_context_from_function_and_args, [], {} ) self.assertIsNone(ctx1) def test_values(self): auth_token = "token1" # test unicode support user_name = "John Gāo" user_id = generate_id(user_name) project_name = 'tenant1' project_id = generate_id(project_name) domain_name = 'domain1' domain_id = generate_id(domain_name) user_domain_name = 'user_domain1' user_domain_id = generate_id(user_domain_name) project_domain_name = 'project_domain1' project_domain_id = generate_id(project_domain_name) is_admin = True read_only = True show_deleted = True request_id = "id1" global_request_id = "req-id1" resource_uuid = "uuid1" ctx = context.RequestContext( auth_token=auth_token, user_id=user_id, user_name=user_name, project_id=project_id, project_name=project_name, domain_id=domain_id, domain_name=domain_name, user_domain_id=user_domain_id, user_domain_name=user_domain_name, project_domain_id=project_domain_id, project_domain_name=project_domain_name, is_admin=is_admin, read_only=read_only, show_deleted=show_deleted, request_id=request_id, global_request_id=global_request_id, resource_uuid=resource_uuid, ) self.assertEqual(auth_token, ctx.auth_token) self.assertEqual(user_id, ctx.user_id) self.assertEqual(user_name, ctx.user_name) self.assertEqual(project_id, ctx.project_id) self.assertEqual(project_name, ctx.project_name) self.assertEqual(domain_id, ctx.domain_id) self.assertEqual(domain_name, ctx.domain_name) self.assertEqual(user_domain_id, ctx.user_domain_id) self.assertEqual(user_domain_name, ctx.user_domain_name) self.assertEqual(project_domain_id, ctx.project_domain_id) self.assertEqual(project_domain_name, ctx.project_domain_name) self.assertEqual(is_admin, ctx.is_admin) self.assertEqual(read_only, ctx.read_only) self.assertEqual(show_deleted, ctx.show_deleted) self.assertEqual(request_id, ctx.request_id) self.assertEqual(resource_uuid, ctx.resource_uuid) d = ctx.to_dict() self.assertIn('auth_token', d) self.assertIn('user', d) self.assertIn('project_id', d) self.assertIn('domain', d) self.assertIn('user_domain', d) self.assertIn('project_domain', d) self.assertIn('is_admin', d) self.assertIn('read_only', d) self.assertIn('show_deleted', d) self.assertIn('request_id', d) self.assertIn('resource_uuid', d) self.assertIn('user_identity', d) self.assertIn('roles', d) self.assertNotIn('user_name', d) self.assertNotIn('project_name', d) self.assertNotIn('domain_name', d) self.assertNotIn('user_domain_name', d) self.assertNotIn('project_domain_name', d) self.assertEqual(auth_token, d['auth_token']) self.assertEqual(project_id, d['project_id']) self.assertEqual(domain_id, d['domain']) self.assertEqual(user_domain_id, d['user_domain']) self.assertEqual(project_domain_id, d['project_domain']) self.assertEqual(is_admin, d['is_admin']) self.assertEqual(read_only, d['read_only']) self.assertEqual(show_deleted, d['show_deleted']) self.assertEqual(request_id, d['request_id']) self.assertEqual(resource_uuid, d['resource_uuid']) user_identity = ( f"{user_id} {project_id} {domain_id} {user_domain_id} " f"{project_domain_id}" ) self.assertEqual(user_identity, d['user_identity']) self.assertEqual([], d['roles']) d = ctx.get_logging_values() self.assertIn('auth_token', d) self.assertEqual(d['auth_token'], '***') self.assertIn('user', d) self.assertIn('project_id', d) self.assertIn('domain', d) self.assertIn('user_domain', d) self.assertIn('project_domain', d) self.assertIn('is_admin', d) self.assertIn('read_only', d) self.assertIn('show_deleted', d) self.assertIn('request_id', d) self.assertIn('global_request_id', d) self.assertIn('resource_uuid', d) self.assertIn('user_identity', d) self.assertIn('roles', d) self.assertIn('user_name', d) self.assertIn('project_name', d) self.assertIn('domain_name', d) self.assertIn('user_domain_name', d) self.assertIn('project_domain_name', d) self.assertEqual(user_name, d['user_name']) self.assertEqual(project_name, d['project_name']) self.assertEqual(domain_name, d['domain_name']) self.assertEqual(user_domain_name, d['user_domain_name']) self.assertEqual(project_domain_name, d['project_domain_name']) def test_auth_token_info_removed_logging_values(self): ctx = TestContext(auth_token_info={'auth_token': 'topsecret'}) d = ctx.get_logging_values() self.assertNotIn('auth_token_info', d) def test_auth_token_info_removed_redacted_context(self): userid = 'foo' ctx = TestContext( auth_token_info={'auth_token': 'topsecret'}, service_token="1234567", auth_token="8901234", user_id=userid, ) safe_ctxt = ctx.redacted_copy() self.assertIsNone(safe_ctxt.auth_token_info) self.assertIsNone(safe_ctxt.service_token) self.assertIsNone(safe_ctxt.auth_token) self.assertEqual(userid, safe_ctxt.user_id) self.assertNotEqual(ctx, safe_ctxt) def test_dict_empty_user_identity(self): ctx = context.RequestContext() d = ctx.to_dict() self.assertEqual("- - - - -", d['user_identity']) def test_generate_request_id(self): id = context.generate_request_id() self.assertEqual("req-", id[:4]) def test_generate_request_id_unique(self): id1 = context.generate_request_id() id2 = context.generate_request_id() self.assertNotEqual(id1, id2) def test_no_global_id_by_default(self): ctx = context.RequestContext() self.assertIsNone(ctx.global_request_id) d = ctx.to_dict() self.assertIsNone(d['global_request_id']) def test_policy_dict(self): user_id = uuid.uuid4().hex user_domain_id = uuid.uuid4().hex project_id = uuid.uuid4().hex project_domain_id = uuid.uuid4().hex roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex] service_user_id = uuid.uuid4().hex service_project_id = uuid.uuid4().hex service_roles = [uuid.uuid4().hex, uuid.uuid4().hex, uuid.uuid4().hex] # default is_admin_project is True ctx = context.RequestContext( user_id=user_id, user_domain_id=user_domain_id, project_id=project_id, project_domain_id=project_domain_id, roles=roles, service_user_id=service_user_id, service_project_id=service_project_id, service_roles=service_roles, ) self.assertEqual( { 'user_id': user_id, 'user_domain_id': user_domain_id, 'system_scope': None, 'domain_id': None, 'project_id': project_id, 'project_domain_id': project_domain_id, 'roles': roles, 'is_admin_project': True, 'service_user_id': service_user_id, 'service_user_domain_id': None, 'service_project_id': service_project_id, 'service_project_domain_id': None, 'service_roles': service_roles, }, ctx.to_policy_values(), ) # NOTE(lbragstad): This string has special meaning in that the value # ``all`` represents the entire deployment system. system_all = 'all' ctx = context.RequestContext( user_id=user_id, user_domain_id=user_domain_id, system_scope=system_all, roles=roles, service_user_id=service_user_id, service_project_id=service_project_id, service_roles=service_roles, ) self.assertEqual( { 'user_id': user_id, 'user_domain_id': user_domain_id, 'system_scope': system_all, 'domain_id': None, 'project_id': None, 'project_domain_id': None, 'roles': roles, 'is_admin_project': True, 'service_user_id': service_user_id, 'service_user_domain_id': None, 'service_project_id': service_project_id, 'service_project_domain_id': None, 'service_roles': service_roles, }, ctx.to_policy_values(), ) # context representing a domain-scoped token. domain_id = uuid.uuid4().hex ctx = context.RequestContext( user_id=user_id, user_domain_id=user_domain_id, domain_id=domain_id, roles=roles, service_user_id=service_user_id, service_project_id=service_project_id, service_roles=service_roles, ) self.assertEqual( { 'user_id': user_id, 'user_domain_id': user_domain_id, 'system_scope': None, 'domain_id': domain_id, 'project_id': None, 'project_domain_id': None, 'roles': roles, 'is_admin_project': True, 'service_user_id': service_user_id, 'service_user_domain_id': None, 'service_project_id': service_project_id, 'service_project_domain_id': None, 'service_roles': service_roles, }, ctx.to_policy_values(), ) ctx = context.RequestContext( user_id=user_id, user_domain_id=user_domain_id, project_id=project_id, project_domain_id=project_domain_id, roles=roles, is_admin_project=False, service_user_id=service_user_id, service_project_id=service_project_id, service_roles=service_roles, ) self.assertEqual( { 'user_id': user_id, 'user_domain_id': user_domain_id, 'system_scope': None, 'domain_id': None, 'project_id': project_id, 'project_domain_id': project_domain_id, 'roles': roles, 'is_admin_project': False, 'service_user_id': service_user_id, 'service_user_domain_id': None, 'service_project_id': service_project_id, 'service_project_domain_id': None, 'service_roles': service_roles, }, ctx.to_policy_values(), ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/oslo_context/tests/test_fixture.py0000664000175000017500000000343015224173710022047 0ustar00zuulzuul# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from oslotest import base as test_base from oslo_context import context from oslo_context import fixture class ClearRequestContextTest(test_base.BaseTestCase): # def setUp(self): # super(ContextTest, self).setUp() # self.useFixture(fixture.ClearRequestContext()) def test_store_current(self): # By default a new context is stored. ctx = context.RequestContext() self.assertIs(context.get_current(), ctx) fixture.ClearRequestContext()._remove_cached_context() self.assertIsNone(context.get_current()) def test_store_current_resets_correctly(self): # By default a new context is stored. ctx = context.RequestContext() # the use of the fixture should put us in a reset state, not # doing so is a bug because when this fixture is consumed by # other test suites there is no guaruntee that all tests use # this fixture. self.useFixture(fixture.ClearRequestContext()) self.assertIsNone(context.get_current()) ctx = context.RequestContext() self.assertIs(context.get_current(), ctx) fixture.ClearRequestContext()._remove_cached_context() self.assertIsNone(context.get_current()) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/oslo_context/version.py0000664000175000017500000000156115224173710017650 0ustar00zuulzuul# Copyright 2016 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import warnings import pbr.version warnings.warn( f'The {__name__} module is deprecated. Prefer use of importlib.metadata ' f'to inspect version information for packages.', DeprecationWarning, ) version_info = pbr.version.VersionInfo('oslo.context') ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/pyproject.toml0000664000175000017500000000334315224173710016005 0ustar00zuulzuul[build-system] requires = ["pbr>=6.1.1"] build-backend = "pbr.build" [project] name = "oslo.context" description = "Oslo Context library" authors = [ {name = "OpenStack", email = "openstack-discuss@lists.openstack.org"}, ] readme = {file = "README.rst", content-type = "text/x-rst"} license = "Apache-2.0" dynamic = ["version", "dependencies"] requires-python = ">=3.11" classifiers = [ "Environment :: OpenStack", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: CPython", "Typing :: Typed", ] [project.urls] Homepage = "https://docs.openstack.org/oslo.context" Repository = "https://opendev.org/openstack/oslo.context" [tool.setuptools.packages.find] include = ["oslo_context"] [tool.mypy] python_version = "3.11" show_column_numbers = true show_error_context = true strict = true disable_error_code = ["import-untyped"] exclude = "(?x)(doc | releasenotes)" [[tool.mypy.overrides]] module = ["oslo_context.tests.*"] disallow_untyped_calls = false disallow_untyped_defs = false disallow_subclassing_any = false [tool.ruff] line-length = 79 [tool.ruff.format] quote-style = "preserve" docstring-code-format = true [tool.ruff.lint] select = ["E4", "E5", "E7", "E9", "F", "G", "LOG", "S", "UP"] external = ["H"] [tool.ruff.lint.per-file-ignores] "oslo_context/tests/*" = ["S"] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.1933324 oslo_context-6.5.0/releasenotes/0000775000175000017500000000000015224173771015566 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.2103343 oslo_context-6.5.0/releasenotes/notes/0000775000175000017500000000000015224173771016716 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/Fix-system-scope-from_dict-29615af90723ba4d.yaml0000664000175000017500000000012015224173710027042 0ustar00zuulzuul--- fixes: - | Fixes context from_dict() to properly handle system_scope. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/add_reno-3b4ae0789e9c45b4.yaml0000664000175000017500000000007115224173710023570 0ustar00zuulzuul--- other: - Switch to reno for managing release notes.././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/deprecate-version-module-b47fc41720b5b49f.yaml0000664000175000017500000000033415224173710026712 0ustar00zuulzuul--- deprecations: - | The ``oslo_context.version`` module and associated objects has been deprecated for removal. Prefer use of ``importlib.metadata`` to inspect version information for installed packages. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/dont-leak-auth-token-fb7075316cf87b7c.yaml0000664000175000017500000000041215224173710025751 0ustar00zuulzuul--- security: - | The ``get_logging_values`` function no longer outputs the auth_token, but instead leaves it as ``***`` instead. As the name suggests, this function is meant for logging, and letting the auth_token there might leak sensitive data. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/drop-python27-support-b421329839e69d41.yaml0000664000175000017500000000017715224173710025753 0ustar00zuulzuul--- upgrade: - | Support for Python 2.7 has been dropped. The minimum version of Python now supported is Python 3.6. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/redacted-copy-efd02c83c287451f.yaml0000664000175000017500000000051615224173710024540 0ustar00zuulzuulfeatures: - | Added ``redacted_copy`` method to ``RequestContext``. This returns a copy of the context with secrets redacted. This will allow downstreams that inherit and enhance the ``RequestContext`` can include the additional data in the redacted copy if they wish by overriding the ``redacted_copy`` method. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/remove-deprecated-args-044bc6bd79638988.yaml0000664000175000017500000000067015224173710026223 0ustar00zuulzuul--- upgrade: - | The following arguments, first deprecated in 2.19.1 (Queens), have now been removed. - `user` (replaced by `user_id`) - `domain` (replaced by `domain_id`) - `user_domain` (replaced by `user_domain_id`) - `project_domain` (replaced by `project_domain_id`) If you are still using the legacy aliases, simply replace e.g. `user` with `user_id` in your calls and `RequestContext` subclasses. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/remove-py310-7a3e24d4c60d5485.yaml0000664000175000017500000000016715224173710024104 0ustar00zuulzuul--- upgrade: - | Support for Python 3.10 has been removed. Now the minimum python version supported is 3.11. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/remove-py38-f21fbda6dac198c4.yaml0000664000175000017500000000016615224173710024326 0ustar00zuulzuul--- upgrade: - | Support for Python 3.8 has been removed. Now the minimum python version supported is 3.9 . ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/remove-py39-643032e829d29b78.yaml0000664000175000017500000000016615224173710023704 0ustar00zuulzuul--- upgrade: - | Support for Python 3.9 has been removed. Now the minimum python version supported is 3.10. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/notes/remove_deprecated_args_tenant-77724de1422f46d9.yaml0000664000175000017500000000017315224173710027725 0ustar00zuulzuul--- upgrade: - | The ``tenant`` argument of ``RequestContext`` that was deprecated for long time is now removed. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.2163348 oslo_context-6.5.0/releasenotes/source/0000775000175000017500000000000015224173771017066 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/2023.1.rst0000664000175000017500000000021015224173710020327 0ustar00zuulzuul=========================== 2023.1 Series Release Notes =========================== .. release-notes:: :branch: unmaintained/2023.1 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/2023.2.rst0000664000175000017500000000020215224173710020331 0ustar00zuulzuul=========================== 2023.2 Series Release Notes =========================== .. release-notes:: :branch: stable/2023.2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/2024.1.rst0000664000175000017500000000021015224173710020330 0ustar00zuulzuul=========================== 2024.1 Series Release Notes =========================== .. release-notes:: :branch: unmaintained/2024.1 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/2024.2.rst0000664000175000017500000000020215224173710020332 0ustar00zuulzuul=========================== 2024.2 Series Release Notes =========================== .. release-notes:: :branch: stable/2024.2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/2025.1.rst0000664000175000017500000000020215224173710020332 0ustar00zuulzuul=========================== 2025.1 Series Release Notes =========================== .. release-notes:: :branch: stable/2025.1 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/2025.2.rst0000664000175000017500000000020215224173710020333 0ustar00zuulzuul=========================== 2025.2 Series Release Notes =========================== .. release-notes:: :branch: stable/2025.2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/2026.1.rst0000664000175000017500000000020215224173710020333 0ustar00zuulzuul=========================== 2026.1 Series Release Notes =========================== .. release-notes:: :branch: stable/2026.1 ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1783691257.217335 oslo_context-6.5.0/releasenotes/source/_static/0000775000175000017500000000000015224173771020514 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/_static/.placeholder0000664000175000017500000000000015224173710022756 0ustar00zuulzuul././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1783691257.217335 oslo_context-6.5.0/releasenotes/source/_templates/0000775000175000017500000000000015224173771021223 5ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/_templates/.placeholder0000664000175000017500000000000015224173710023465 0ustar00zuulzuul././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/conf.py0000664000175000017500000002103115224173710020353 0ustar00zuulzuul# Copyright (C) 2020 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'openstackdocstheme', 'reno.sphinxext', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. copyright = '2016, oslo.context Developers' # Release notes do not need a version in the title, they span # multiple versions. # The full version, including alpha/beta/rc tags. release = '' # The short X.Y version. version = '' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all # documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'native' # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. # keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'openstackdocs' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. # html_extra_path = [] # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. # html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. # html_additional_pages = {} # If false, no module index is generated. # html_domain_indices = True # If false, no index is generated. # html_use_index = True # If true, the index is split into individual pages for each letter. # html_split_index = False # If true, links to the reST sources are added to the pages. # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'oslo.contextReleaseNotesDoc' # -- Options for LaTeX output --------------------------------------------- # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ( 'index', 'oslo.contextReleaseNotes.tex', 'oslo.context Release Notes Documentation', 'oslo.context Developers', 'manual', ), ] # The name of an image file (relative to this directory) to place at the top of # the title page. # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # latex_use_parts = False # If true, show page references after internal links. # latex_show_pagerefs = False # If true, show URL addresses after external links. # latex_show_urls = False # Documents to append as an appendix to all manuals. # latex_appendices = [] # If false, no module index is generated. # latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ( 'index', 'oslo.contextReleaseNotes', 'oslo.context Release Notes Documentation', ['oslo.context Developers'], 1, ) ] # If true, show URL addresses after external links. # man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( 'index', 'oslo.contextReleaseNotes', 'oslo.context Release Notes Documentation', 'oslo.context Developers', 'oslo.contextReleaseNotes', 'One line description of project.', 'Miscellaneous', ), ] # Documents to append as an appendix to all manuals. # texinfo_appendices = [] # If false, no module index is generated. # texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. # texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. # texinfo_no_detailmenu = False # -- Options for Internationalization output ------------------------------ locale_dirs = ['locale/'] # openstackdocstheme options openstackdocs_repo_name = 'openstack/oslo.context' openstackdocs_bug_project = 'oslo.context' openstackdocs_bug_tag = '' ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/index.rst0000664000175000017500000000047715224173710020730 0ustar00zuulzuul=========================== oslo.context Release Notes =========================== .. toctree:: :maxdepth: 1 unreleased 2026.1 2025.2 2025.1 2024.2 2024.1 2023.2 2023.1 zed yoga xena wallaby victoria ussuri train stein rocky queens pike ocata newton ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/newton.rst0000664000175000017500000000021615224173710021122 0ustar00zuulzuul============================= Newton Series Release Notes ============================= .. release-notes:: :branch: origin/stable/newton ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/ocata.rst0000664000175000017500000000023015224173710020673 0ustar00zuulzuul=================================== Ocata Series Release Notes =================================== .. release-notes:: :branch: origin/stable/ocata ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/pike.rst0000664000175000017500000000021715224173710020541 0ustar00zuulzuul=================================== Pike Series Release Notes =================================== .. release-notes:: :branch: stable/pike ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/queens.rst0000664000175000017500000000022315224173710021106 0ustar00zuulzuul=================================== Queens Series Release Notes =================================== .. release-notes:: :branch: stable/queens ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/rocky.rst0000664000175000017500000000022115224173710020733 0ustar00zuulzuul=================================== Rocky Series Release Notes =================================== .. release-notes:: :branch: stable/rocky ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/stein.rst0000664000175000017500000000022115224173710020726 0ustar00zuulzuul=================================== Stein Series Release Notes =================================== .. release-notes:: :branch: stable/stein ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/train.rst0000664000175000017500000000017615224173710020732 0ustar00zuulzuul========================== Train Series Release Notes ========================== .. release-notes:: :branch: stable/train ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/unreleased.rst0000664000175000017500000000014415224173710021737 0ustar00zuulzuul========================== Unreleased Release Notes ========================== .. release-notes:: ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/ussuri.rst0000664000175000017500000000020215224173710021135 0ustar00zuulzuul=========================== Ussuri Series Release Notes =========================== .. release-notes:: :branch: stable/ussuri ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/victoria.rst0000664000175000017500000000022015224173710021423 0ustar00zuulzuul============================= Victoria Series Release Notes ============================= .. release-notes:: :branch: unmaintained/victoria ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/wallaby.rst0000664000175000017500000000021415224173710021241 0ustar00zuulzuul============================ Wallaby Series Release Notes ============================ .. release-notes:: :branch: unmaintained/wallaby ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/xena.rst0000664000175000017500000000020015224173710020534 0ustar00zuulzuul========================= Xena Series Release Notes ========================= .. release-notes:: :branch: unmaintained/xena ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/yoga.rst0000664000175000017500000000020015224173710020540 0ustar00zuulzuul========================= Yoga Series Release Notes ========================= .. release-notes:: :branch: unmaintained/yoga ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/releasenotes/source/zed.rst0000664000175000017500000000017415224173710020375 0ustar00zuulzuul======================== Zed Series Release Notes ======================== .. release-notes:: :branch: unmaintained/zed ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/requirements.txt0000664000175000017500000000043315224173710016352 0ustar00zuulzuul# Requirements lower bounds listed here are our best effort to keep them up to # date but we do not test them so no guarantee of having them all correct. If # you find any incorrect lower bounds, let us know or propose a fix. pbr>=2.0.0 # Apache-2.0 typing-extensions>=4.12.0 # PSF ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1783691257.2183352 oslo_context-6.5.0/setup.cfg0000664000175000017500000000010615224173771014713 0ustar00zuulzuul[metadata] name = oslo.context [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/setup.py0000664000175000017500000000127315224173710014603 0ustar00zuulzuul# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. import setuptools setuptools.setup( setup_requires=['pbr>=2.0.0'], pbr=True, ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/test-requirements.txt0000664000175000017500000000040415224173710017325 0ustar00zuulzuulhacking>=6.1.0,<6.2.0 # Apache-2.0 mypy>=0.761 # MIT fixtures>=3.0.0 # Apache-2.0/BSD oslotest>=3.2.0 # Apache-2.0 coverage>=4.0 # Apache-2.0 stestr>=2.0.0 # Apache-2.0 # Bandit security code scanner bandit>=1.7.0,<1.8.0 # Apache-2.0 pre-commit>=2.6.0 # MIT ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1783691208.0 oslo_context-6.5.0/tox.ini0000664000175000017500000000273715224173710014412 0ustar00zuulzuul[tox] minversion = 4.28.0 envlist = py3,pep8 [testenv] constraints = {env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} deps = -r{toxinidir}/test-requirements.txt commands = stestr run --slowest {posargs} [testenv:pep8] description = Run style checks. deps = pre-commit {[testenv:mypy]deps} commands = pre-commit run -a {[testenv:mypy]commands} [testenv:mypy] description = Run type checks. deps = {[testenv]deps} mypy commands = mypy --cache-dir="{envdir}/mypy_cache" {posargs:oslo_context} [testenv:venv] commands = {posargs} [testenv:docs] deps = -r{toxinidir}/doc/requirements.txt allowlist_externals = rm commands = rm -fr doc/build sphinx-build -W --keep-going -b html doc/source doc/build/html [testenv:releasenotes] skip_install = true allowlist_externals = rm deps = {[testenv:docs]deps} commands = rm -rf releasenotes/build sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html [testenv:cover] setenv = PYTHON=coverage run --source oslo_context --parallel-mode commands = stestr run {posargs} coverage combine coverage html -d cover coverage xml -o cover/coverage.xml [flake8] # We only enable the hacking (H) checks select = H # H301 Black will put commas after imports that can't fit on one line # H404 Docstrings don't always start with a newline # H405 Multiline docstrings are okay ignore = H301,H403,H404,H405 [hacking] import_exceptions =