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

Implement Service JWT #225

Merged
merged 2 commits into from
Jan 10, 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
1 change: 0 additions & 1 deletion docs/source/atproto/atproto_client.client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Submodules

atproto_client.client.async_client
atproto_client.client.async_raw
atproto_client.client.auth
atproto_client.client.base
atproto_client.client.client
atproto_client.client.raw
15 changes: 15 additions & 0 deletions docs/source/atproto/atproto_crypto.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
atproto\_crypto
===============

.. automodule:: atproto_crypto
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::
:maxdepth: 4

atproto_crypto.verify
7 changes: 7 additions & 0 deletions docs/source/atproto/atproto_crypto.verify.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
atproto\_crypto.verify
======================

.. automodule:: atproto_crypto.verify
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/atproto/atproto_server.auth.jwt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
atproto\_server.auth.jwt
========================

.. automodule:: atproto_server.auth.jwt
:members:
:undoc-members:
:show-inheritance:
16 changes: 16 additions & 0 deletions docs/source/atproto/atproto_server.auth.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
atproto\_server.auth
====================

.. automodule:: atproto_server.auth
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::
:maxdepth: 4

atproto_server.auth.jwt
atproto_server.auth.utils
7 changes: 7 additions & 0 deletions docs/source/atproto/atproto_server.auth.utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
atproto\_server.auth.utils
==========================

.. automodule:: atproto_server.auth.utils
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/atproto/atproto_server.exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
atproto\_server.exceptions
==========================

.. automodule:: atproto_server.exceptions
:members:
:undoc-members:
:show-inheritance:
16 changes: 16 additions & 0 deletions docs/source/atproto/atproto_server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,19 @@ atproto\_server
:members:
:undoc-members:
:show-inheritance:

Subpackages
-----------

.. toctree::
:maxdepth: 4

atproto_server.auth

Submodules
----------

.. toctree::
:maxdepth: 4

atproto_server.exceptions
1 change: 1 addition & 0 deletions docs/source/atproto/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ packages
atproto_client
atproto_codegen
atproto_core
atproto_crypto
atproto_firehose
atproto_identity
atproto_lexicon
Expand Down
7 changes: 7 additions & 0 deletions docs/source/atproto_server/auth.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Auth
====

.. automodule:: atproto_server.auth.jwt
:members:
:undoc-members:
:show-inheritance:
12 changes: 12 additions & 0 deletions docs/source/atproto_server/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Server
======

.. automodule:: atproto_server
:members:
:undoc-members:
:inherited-members:

.. toctree::
:maxdepth: 4

auth
8 changes: 8 additions & 0 deletions docs/source/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ Identity
:show-inheritance:


Server
######

.. automodule:: atproto_server.exceptions
:members:
:undoc-members:
:show-inheritance:

Lexicon
#######

Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Documentation
namespace
models
atproto_identity/identity
atproto_server/index

.. toctree::
:caption: Core
Expand Down
21 changes: 21 additions & 0 deletions packages/atproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,48 @@
from atproto_firehose import models as firehose_models
from atproto_identity.cache.in_memory_cache import AsyncDidInMemoryCache, DidInMemoryCache
from atproto_identity.resolver import AsyncIdResolver, IdResolver
from atproto_server.auth.jwt import (
JwtPayload,
decode_jwt_payload,
get_jwt_payload,
parse_jwt,
validate_jwt_payload,
verify_jwt,
verify_jwt_async,
)

__all__ = [
# client
'AsyncClient',
'Client',
'client_utils',
'models',
# core
'CAR',
'CID',
'CIDType',
'DidDocument',
'NSID',
'AtUri',
# firehose
'AsyncFirehoseSubscribeLabelsClient',
'AsyncFirehoseSubscribeReposClient',
'FirehoseSubscribeLabelsClient',
'FirehoseSubscribeReposClient',
'parse_subscribe_labels_message',
'parse_subscribe_repos_message',
'firehose_models',
# identity
'AsyncDidInMemoryCache',
'DidInMemoryCache',
'AsyncIdResolver',
'IdResolver',
# server jwt
'JwtPayload',
'decode_jwt_payload',
'get_jwt_payload',
'parse_jwt',
'validate_jwt_payload',
'verify_jwt',
'verify_jwt_async',
]
1 change: 1 addition & 0 deletions packages/atproto/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from atproto_firehose.exceptions import *
from atproto_identity.exceptions import *
from atproto_lexicon.exceptions import *
from atproto_server.exceptions import *
19 changes: 0 additions & 19 deletions packages/atproto_client/client/auth.py

This file was deleted.

6 changes: 3 additions & 3 deletions packages/atproto_client/client/methods_mixin/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from datetime import timedelta

import typing_extensions as te

from atproto_client.client.auth import get_jwt_payload
from atproto_server.auth.jwt import get_jwt_payload

if t.TYPE_CHECKING:
from atproto_server.auth.jwt import JwtPayload

from atproto_client import models
from atproto_client.client.auth import JwtPayload


@dataclass
Expand Down
1 change: 1 addition & 0 deletions packages/atproto_core/did_doc/did_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def get_service_endpoint(did_doc: 'DidDocument', id_: str, type_: str) -> t.Opti
"""Returns the service endpoint of the given DID document.

Args:
did_doc: The DID document.
id_: The service ID.
type_: The service type.

Expand Down
Empty file.
13 changes: 13 additions & 0 deletions packages/atproto_crypto/verify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import typing as t
import warnings


def verify_signature(did_key: str, signing_input: t.Union[str, bytes], signature: t.Union[str, bytes]) -> bool:
# TODO(MarshalX): implement
warnings.warn(
'verify_signature is not implemented yet. Do not trust to this signing_input',
RuntimeWarning,
stacklevel=0,
)

return True
1 change: 0 additions & 1 deletion packages/atproto_server/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# TODO(MarshalX): When ATProto will stable
Empty file.
Loading
Loading