Skip to content

Commit

Permalink
[IMP] auth_api_key: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisb-c01 committed Dec 16, 2023
1 parent 3f79341 commit 8003141
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 69 deletions.
60 changes: 33 additions & 27 deletions auth_api_key/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,29 @@ Auth Api Key
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
:target: https://github.com/OCA/server-auth/tree/16.0/auth_api_key
:target: https://github.com/OCA/server-auth/tree/17.0/auth_api_key
:alt: OCA/server-auth
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-auth-16-0/server-auth-16-0-auth_api_key
:target: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-auth_api_key
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Authenticate http requests from an API key.

API keys are codes passed in (in the http header API-KEY)
by programs calling an API in order to identify -in this case- the calling program's user.
API keys are codes passed in (in the http header API-KEY) by programs
calling an API in order to identify -in this case- the calling program's
user.

Take care while using this kind of mechanism since information into http headers are visible in clear.
Thus, use it only to authenticate requests from known sources.
Take care while using this kind of mechanism since information into http
headers are visible in clear. Thus, use it only to authenticate requests
from known sources.

For unknown sources, it is a good practice to filter out this header at proxy level.
For unknown sources, it is a good practice to filter out this header at
proxy level.

**Table of contents**

Expand All @@ -47,53 +50,56 @@ Configuration
=============

The api key menu is available into Settings > Technical in debug mode.
By default, when you create an API key, the key is saved into the database.
By default, when you create an API key, the key is saved into the
database.

If you want to manage them via serve environment settings use `auth_api_key_server_env`.
If you want to manage them via serve environment settings use
auth_api_key_server_env.

Usage
=====

To apply this authentication system to your http request you must set 'api_key'
as value for the 'auth' parameter of your route definition into your controller.
To apply this authentication system to your http request you must set
'api_key' as value for the 'auth' parameter of your route definition
into your controller.

.. code-block:: python
.. code:: python
class MyController(Controller):
class MyController(Controller):
@route('/my_service', auth='api_key', ...)
def my_service(self, *args, **kwargs):
pass
@route('/my_service', auth='api_key', ...)
def my_service(self, *args, **kwargs):
pass
Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20auth_api_key%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20auth_api_key%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~
-------

* ACSONE SA/NV

Contributors
~~~~~~~~~~~~
------------

* Denis Robinet <[email protected]>
* Laurent Mignon <[email protected]>
* Quentin Groulard <[email protected]>
* Sébastien Beau <[email protected]>
* Chafique Delli <[email protected]>
- Denis Robinet <[email protected]>
- Laurent Mignon <[email protected]>
- Quentin Groulard <[email protected]>
- Sébastien Beau <[email protected]>
- Chafique Delli <[email protected]>

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -105,6 +111,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/16.0/auth_api_key>`_ project on GitHub.
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/17.0/auth_api_key>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions auth_api_key/models/auth_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def _clear_key_cache(self):

@api.model_create_multi
def create(self, vals_list):
records = super(AuthApiKey, self).create(vals_list)
records = super().create(vals_list)
if any(["key" in vals or "user_id" in vals for vals in vals_list]):
self._clear_key_cache()
return records

def write(self, vals):
super(AuthApiKey, self).write(vals)
super().write(vals)
if "key" in vals or "user_id" in vals:
self._clear_key_cache()
return True
3 changes: 3 additions & 0 deletions auth_api_key/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
6 changes: 6 additions & 0 deletions auth_api_key/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The api key menu is available into Settings \> Technical in debug mode.
By default, when you create an API key, the key is saved into the
database.

If you want to manage them via serve environment settings use
auth_api_key_server_env.
4 changes: 0 additions & 4 deletions auth_api_key/readme/CONFIGURE.rst

This file was deleted.

5 changes: 5 additions & 0 deletions auth_api_key/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Denis Robinet \<<[email protected]>\>
- Laurent Mignon \<<[email protected]>\>
- Quentin Groulard \<<[email protected]>\>
- Sébastien Beau \<<[email protected]>\>
- Chafique Delli \<<[email protected]>\>
5 changes: 0 additions & 5 deletions auth_api_key/readme/CONTRIBUTORS.rst

This file was deleted.

12 changes: 12 additions & 0 deletions auth_api_key/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Authenticate http requests from an API key.

API keys are codes passed in (in the http header API-KEY) by programs
calling an API in order to identify -in this case- the calling program's
user.

Take care while using this kind of mechanism since information into http
headers are visible in clear. Thus, use it only to authenticate requests
from known sources.

For unknown sources, it is a good practice to filter out this header at
proxy level.
9 changes: 0 additions & 9 deletions auth_api_key/readme/DESCRIPTION.rst

This file was deleted.

11 changes: 11 additions & 0 deletions auth_api_key/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
To apply this authentication system to your http request you must set
'api_key' as value for the 'auth' parameter of your route definition
into your controller.

``` python
class MyController(Controller):

@route('/my_service', auth='api_key', ...)
def my_service(self, *args, **kwargs):
pass
```
10 changes: 0 additions & 10 deletions auth_api_key/readme/USAGE.rst

This file was deleted.

30 changes: 18 additions & 12 deletions auth_api_key/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,16 @@ <h1 class="title">Auth Api Key</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3adb1ff0898c08651ce6de2c1ee1a91bc08a719dc6411ca880be9598b2f62705
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-auth/tree/16.0/auth_api_key"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-16-0/server-auth-16-0-auth_api_key"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-auth&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-auth/tree/17.0/auth_api_key"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-auth_api_key"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-auth&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Authenticate http requests from an API key.</p>
<p>API keys are codes passed in (in the http header API-KEY)
by programs calling an API in order to identify -in this case- the calling program’s user.</p>
<p>Take care while using this kind of mechanism since information into http headers are visible in clear.
Thus, use it only to authenticate requests from known sources.</p>
<p>For unknown sources, it is a good practice to filter out this header at proxy level.</p>
<p>API keys are codes passed in (in the http header API-KEY) by programs
calling an API in order to identify -in this case- the calling program’s
user.</p>
<p>Take care while using this kind of mechanism since information into http
headers are visible in clear. Thus, use it only to authenticate requests
from known sources.</p>
<p>For unknown sources, it is a good practice to filter out this header at
proxy level.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -393,13 +396,16 @@ <h1 class="title">Auth Api Key</h1>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>The api key menu is available into Settings &gt; Technical in debug mode.
By default, when you create an API key, the key is saved into the database.</p>
<p>If you want to manage them via serve environment settings use <cite>auth_api_key_server_env</cite>.</p>
By default, when you create an API key, the key is saved into the
database.</p>
<p>If you want to manage them via serve environment settings use
auth_api_key_server_env.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>To apply this authentication system to your http request you must set ‘api_key’
as value for the ‘auth’ parameter of your route definition into your controller.</p>
<p>To apply this authentication system to your http request you must set
‘api_key’ as value for the ‘auth’ parameter of your route definition
into your controller.</p>
<pre class="code python literal-block">
<span class="k">class</span> <span class="nc">MyController</span><span class="p">(</span><span class="n">Controller</span><span class="p">):</span><span class="w">

Expand All @@ -413,7 +419,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-auth/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-auth/issues/new?body=module:%20auth_api_key%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/server-auth/issues/new?body=module:%20auth_api_key%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -441,7 +447,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-auth/tree/16.0/auth_api_key">OCA/server-auth</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-auth/tree/17.0/auth_api_key">OCA/server-auth</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down

0 comments on commit 8003141

Please sign in to comment.