Skip to content

Commit

Permalink
Merge branch 'j0/pkce' of github.com:supabase-community/gotrue-py int…
Browse files Browse the repository at this point in the history
…o j0/pkce
  • Loading branch information
joel@joellee.org committed Nov 1, 2023
2 parents 3b61aff + 4c44238 commit 1c40ed7
Show file tree
Hide file tree
Showing 9 changed files with 604 additions and 515 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# This action uses Python Semantic Release v8
- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v8.0.8
uses: python-semantic-release/python-semantic-release@v8.3.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude: '^.*\.(md|MD)$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
Expand Down
79 changes: 79 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,51 @@



## v1.2.0 (2023-10-05)

### Feature

* feat: Add exception to handle API errors on signout ([`59b90d5`](https://github.com/supabase-community/gotrue-py/commit/59b90d545f59cb00b08b3a5c02edcd9a4a229538))

### Unknown

* Merge pull request #342 from supabase-community/silentworks/sign-out-exception-handling

feat: Add exception to handle API errors on signout ([`708859c`](https://github.com/supabase-community/gotrue-py/commit/708859c1fe12535910ef5d8385f42a6aabda2613))

* Update to use suppress instead of try except ([`2d964ad`](https://github.com/supabase-community/gotrue-py/commit/2d964ad892e3a40204904319d499f7da9aa9289a))

* Merge pull request #341 from supabase-community/silentworks/add-correct-semantic-release-vars

Add correct variables for semantic release ([`5155312`](https://github.com/supabase-community/gotrue-py/commit/5155312a31fd669a6f62616ea75036386a2fc004))

* Get pre-commit to ignore changelog ([`738602e`](https://github.com/supabase-community/gotrue-py/commit/738602ea6ba013ff9071115ee65842c26f4098cf))

* Add correct variables for semantic release ([`80b0e30`](https://github.com/supabase-community/gotrue-py/commit/80b0e30cc5ddf510f2ea1891aab247bde7c01ccc))

* Merge pull request #330 from supabase-community/dependabot/pip/cryptography-41.0.4

chore(deps-dev): bump cryptography from 41.0.3 to 41.0.4 ([`1bf3e5d`](https://github.com/supabase-community/gotrue-py/commit/1bf3e5dc03f9d0da1f939001ec120e1ef0c69420))


## v1.1.1 (2023-09-22)

### Chore

* chore(deps-dev): bump cryptography from 41.0.3 to 41.0.4

Bumps [cryptography](https://github.com/pyca/cryptography) from 41.0.3 to 41.0.4.
- [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/41.0.3...41.0.4)

---
updated-dependencies:
- dependency-name: cryptography
dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com> ([`4aa7224`](https://github.com/supabase-community/gotrue-py/commit/4aa7224e414df9c7ddc822d29d79e0db777dd7d3))

* chore(deps): bump python-semantic-release/python-semantic-release

Bumps [python-semantic-release/python-semantic-release](https://github.com/python-semantic-release/python-semantic-release) from 8.0.0 to 8.0.8.
Expand Down Expand Up @@ -96,6 +137,10 @@ Signed-off-by: dependabot[bot] <support@github.com> ([`ab39f66`](https://g

### Unknown

* 1.1.1

Automatically generated by python-semantic-release ([`152ed06`](https://github.com/supabase-community/gotrue-py/commit/152ed06f65369ad1f15e6d105bd9d93d1b79da12))

* Merge pull request #328 from supabase-community/feat/add-verify-token-hash

fix: add verify token hash ([`ccb2173`](https://github.com/supabase-community/gotrue-py/commit/ccb2173eb694622be100eec36942ec8a69b151a7))
Expand Down Expand Up @@ -180,6 +225,10 @@ Signed-off-by: dependabot[bot] <support@github.com> ([`7b0fb17`](https://g

### Unknown

* 1.1.0

Automatically generated by python-semantic-release ([`ff35a92`](https://github.com/supabase-community/gotrue-py/commit/ff35a928ef5c5cb8a5559a122fe55a868be0c023))

* Merge pull request #307 from supabase-community/dependabot/github_actions/main/actions/checkout-4

chore(deps): bump actions/checkout from 3 to 4 ([`64c0c66`](https://github.com/supabase-community/gotrue-py/commit/64c0c66f452f5d149fcbe61dc88c74baf9056584))
Expand Down Expand Up @@ -251,6 +300,10 @@ Signed-off-by: dependabot[bot] <support@github.com> ([`0a03065`](https://g

### Unknown

* 1.0.4

Automatically generated by python-semantic-release ([`5cc198b`](https://github.com/supabase-community/gotrue-py/commit/5cc198b631189a0622a23b71e8d5a4acba1de005))

* Merge pull request #299 from supabase-community/j0/fix_version_toml

chore: add contents permission ([`7561df9`](https://github.com/supabase-community/gotrue-py/commit/7561df9a8b7b0279763e318f2a48b54693278c9b))
Expand Down Expand Up @@ -2844,6 +2897,10 @@ chore(deps-dev): bump pytest from 7.0.1 to 7.1.0 ([`657f07b`](https://github.com

### Chore

* chore(release): bump version to v0.5.0

Automatically generated by python-semantic-release ([`888ba1b`](https://github.com/supabase-community/gotrue-py/commit/888ba1b9bcb8c4c89c3910408213053afac8e553))

* chore: set upload_to_repository to true ([`6316827`](https://github.com/supabase-community/gotrue-py/commit/63168276afd5e7786c8c55baadceef6ad60ab14f))

* chore(deps-dev): bump pytest-asyncio from 0.17.1 to 0.17.2 (#73)
Expand Down Expand Up @@ -2923,6 +2980,12 @@ Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.git

## v0.4.0 (2022-01-17)

### Chore

* chore(release): bump version to v0.4.0

Automatically generated by python-semantic-release ([`d2e138c`](https://github.com/supabase-community/gotrue-py/commit/d2e138c8143cceab47dc6cd67089a53c0f259be9))

### Feature

* feat: add notion to enum of providers (#70)
Expand All @@ -2940,6 +3003,10 @@ Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.git

### Chore

* chore(release): bump version to v0.3.5

Automatically generated by python-semantic-release ([`5034285`](https://github.com/supabase-community/gotrue-py/commit/50342856e4823136890b98d38d306cd8a83708c2))

* chore(deps-dev): bump pytest-asyncio from 0.16.0 to 0.17.0 (#67)

Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.16.0 to 0.17.0.
Expand Down Expand Up @@ -2976,6 +3043,10 @@ Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.git

### Chore

* chore(release): bump version to v0.3.4

Automatically generated by python-semantic-release ([`4b5ce2f`](https://github.com/supabase-community/gotrue-py/commit/4b5ce2f583ca84a972445a7cd08ffd44bbbb03c9))

* chore: fix http warning use ([`19005e2`](https://github.com/supabase-community/gotrue-py/commit/19005e2b9715075a9fb9bb0a75b7b786b9710aac))

* chore: fix http warning use (#61)
Expand All @@ -2995,6 +3066,10 @@ because the intention is good but instead receives an annoying print. ([`ae20a8e

### Chore

* chore(release): bump version to v0.3.3

Automatically generated by python-semantic-release ([`d355393`](https://github.com/supabase-community/gotrue-py/commit/d355393bacc339678543b2637dcc9295c41bc8b7))

* chore(deps): upgrade dependencies ([`029bcd4`](https://github.com/supabase-community/gotrue-py/commit/029bcd49c7d986ee2454e8517474f212f996d9c5))

* chore(deps): bump httpx from 0.21.2 to 0.21.3 (#60)
Expand Down Expand Up @@ -3094,6 +3169,10 @@ chore: fix rule in makefile ([`56fd621`](https://github.com/supabase-community/g

### Chore

* chore(release): bump version to v0.3.2

Automatically generated by python-semantic-release ([`4183894`](https://github.com/supabase-community/gotrue-py/commit/41838949e87bd52c9c6a6522f477c93bfa0c21ca))

* chore(deps): bump pydantic from 1.8.2 to 1.9.0

Bumps [pydantic](https://github.com/samuelcolvin/pydantic) from 1.8.2 to 1.9.0.
Expand Down
2 changes: 1 addition & 1 deletion gotrue/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

__version__ = "1.1.0"
__version__ = "1.2.0"

from ._async.gotrue_admin_api import AsyncGoTrueAdminAPI # type: ignore # noqa: F401
from ._async.gotrue_client import AsyncGoTrueClient # type: ignore # noqa: F401
Expand Down
12 changes: 8 additions & 4 deletions gotrue/_async/gotrue_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from contextlib import suppress
from functools import partial
from json import loads
from time import time
Expand All @@ -16,6 +17,7 @@
STORAGE_KEY,
)
from ..errors import (
AuthApiError,
AuthImplicitGrantRedirectError,
AuthInvalidCredentialsError,
AuthRetryableError,
Expand Down Expand Up @@ -489,10 +491,12 @@ async def sign_out(self) -> None:
There is no way to revoke a user's access token jwt until it expires.
It is recommended to set a shorter expiry on the jwt for this reason.
"""
session = await self.get_session()
access_token = session.access_token if session else None
if access_token:
await self.admin.sign_out(access_token)
with suppress(AuthApiError):
session = await self.get_session()
access_token = session.access_token if session else None
if access_token:
await self.admin.sign_out(access_token)

await self._remove_session()
self._notify_all_subscribers("SIGNED_OUT", None)

Expand Down
12 changes: 8 additions & 4 deletions gotrue/_sync/gotrue_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from contextlib import suppress
from functools import partial
from json import loads
from time import time
Expand All @@ -16,6 +17,7 @@
STORAGE_KEY,
)
from ..errors import (
AuthApiError,
AuthImplicitGrantRedirectError,
AuthInvalidCredentialsError,
AuthRetryableError,
Expand Down Expand Up @@ -487,10 +489,12 @@ def sign_out(self) -> None:
There is no way to revoke a user's access token jwt until it expires.
It is recommended to set a shorter expiry on the jwt for this reason.
"""
session = self.get_session()
access_token = session.access_token if session else None
if access_token:
self.admin.sign_out(access_token)
with suppress(AuthApiError):
session = self.get_session()
access_token = session.access_token if session else None
if access_token:
self.admin.sign_out(access_token)

self._remove_session()
self._notify_all_subscribers("SIGNED_OUT", None)

Expand Down
4 changes: 3 additions & 1 deletion gotrue/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import secrets
import string
from base64 import b64decode
from base64 import urlsafe_b64decode, b64decode
from json import loads
from typing import Any, Dict, Type, TypeVar, Union, cast

Expand Down Expand Up @@ -127,7 +128,7 @@ def decode_jwt_payload(token: str) -> Any:
# Addding padding otherwise the following error happens:
# binascii.Error: Incorrect padding
base64UrlWithPadding = base64Url + "=" * (-len(base64Url) % 4)
return loads(b64decode(base64UrlWithPadding).decode("utf-8"))
return loads(urlsafe_b64decode(base64UrlWithPadding).decode("utf-8"))


def generate_pkce_verifier(length=64):
Expand All @@ -148,3 +149,4 @@ def generate_pkce_challenge(code_verifier):
sha256_hash = hashlib.sha256(verifier_bytes).digest()

return base64.urlsafe_b64encode(sha256_hash).rstrip(b"=").decode("utf-8")

0 comments on commit 1c40ed7

Please sign in to comment.