Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use plugin via '-A store', deprecate '-A creds' #29

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Usage
-----

.. note:: Please, do not forget to activate the plugin by invoking
``http`` with ``-A creds`` option.
``http`` with ``-A store`` option.

Once installed, the plugin will look for credentials in the credential
file. The credential file is stored in HTTPie configuration directory.
Expand Down Expand Up @@ -95,19 +95,19 @@ the following credential record:
]

Once the credential store is filled, you're ready to use the plugin at
your will. In order to activate the plugin, you must pass ``-A creds``
or ``-A credential-store`` to ``http`` executable.
your will. In order to activate the plugin, you must pass ``-A store``
to ``http`` executable.

.. code:: bash

$ http -A creds https://api.github.com
$ http -A store https://api.github.com

Optionally, you can provide an ID of the credential record to use by
passing ``-a`` argument.

.. code:: bash

$ http -A creds -a bots https://api.github.com
$ http -A store -a bots https://api.github.com


Authentication providers
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pytest-github-actions-annotate-failures = "*"
httpie-hmac = "*"

[tool.poetry.plugins."httpie.plugins.auth.v1"]
store = "httpie_credential_store:StoreAuthPlugin"
credential-store = "httpie_credential_store:CredentialStoreAuthPlugin"
creds = "httpie_credential_store:CredsAuthPlugin"

Expand Down
4 changes: 2 additions & 2 deletions src/httpie_credential_store/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""HTTPie Credential Store."""

from ._plugin import CredentialStoreAuthPlugin, CredsAuthPlugin
from ._plugin import CredentialStoreAuthPlugin, CredsAuthPlugin, StoreAuthPlugin


__all__ = ["CredentialStoreAuthPlugin", "CredsAuthPlugin"]
__all__ = ["StoreAuthPlugin", "CredentialStoreAuthPlugin", "CredsAuthPlugin"]
16 changes: 11 additions & 5 deletions src/httpie_credential_store/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ._store import get_credential_store


class CredentialStoreAuthPlugin(httpie.plugins.AuthPlugin):
class StoreAuthPlugin(httpie.plugins.AuthPlugin):
"""Attach authentication to ongoing HTTP request.

Usage::
Expand All @@ -15,10 +15,10 @@ class CredentialStoreAuthPlugin(httpie.plugins.AuthPlugin):
$ http -A credential-store -a ihor http://example.com/v1/resource
"""

name = "credential-store"
name = "HTTPie Credential Store"
description = "Retrieve & attach authentication to ongoing HTTP request."

auth_type = "credential-store" # use plugin by passing '-A credential-store'
auth_type = "store" # use plugin by passing '-A store'
auth_require = False # do not require passing '-a' argument
auth_parse = False # do not parse '-a' content

Expand All @@ -36,7 +36,13 @@ def __call__(self, request):
return CredentialStoreAuth()


class CredentialStoreAuthPlugin(StoreAuthPlugin):
"""DEPRECATED: invoke 'store' authentication via '-A credential-store'."""

auth_type = "credential-store"


class CredsAuthPlugin(CredentialStoreAuthPlugin):
"""Nothing more but a convenient alias."""
"""DEPRECATED: invoke 'store' authentication via '-A creds'."""

auth_type = "creds" # use plugin by passing '-A creds'
auth_type = "creds"
2 changes: 1 addition & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def main(args):
return main


@pytest.fixture(params=["credential-store", "creds"])
@pytest.fixture(params=["store", "credential-store", "creds"])
def creds_auth_type(request):
"""All possible aliases."""

Expand Down