Skip to content

Commit bd3d4ae

Browse files
authored
Feature[PAM]: Revoke token functionality
1 parent 6beedc6 commit bd3d4ae

File tree

18 files changed

+324
-177
lines changed

18 files changed

+324
-177
lines changed

.github/workflows/run_acceptance_tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ jobs:
2222
token: ${{ secrets.GH_TOKEN }}
2323
- name: Install Python dependencies and run acceptance tests
2424
run: |
25+
cp sdk-specifications/features/access/authorization-failure-reporting.feature tests/acceptance/pam
2526
cp sdk-specifications/features/access/grant-token.feature tests/acceptance/pam
27+
cp sdk-specifications/features/access/revoke-token.feature tests/acceptance/pam
28+
2629
sudo pip3 install -r requirements-dev.txt
2730
behave --junit tests/acceptance/pam
2831
- name: Expose acceptance tests reports

.pubnub.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: python
2-
version: 5.4.0
2+
version: 5.5.0
33
schema: 1
44
scm: github.com/pubnub/python
55
sdks:
@@ -18,7 +18,7 @@ sdks:
1818
distributions:
1919
- distribution-type: library
2020
distribution-repository: package
21-
package-name: pubnub-5.1.3
21+
package-name: pubnub-5.5.0
2222
location: https://pypi.org/project/pubnub/
2323
supported-platforms:
2424
supported-operating-systems:
@@ -97,8 +97,8 @@ sdks:
9797
-
9898
distribution-type: library
9999
distribution-repository: git release
100-
package-name: pubnub-5.1.3
101-
location: https://github.com/pubnub/python/releases/download/v5.1.3/pubnub-5.1.3.tar.gz
100+
package-name: pubnub-5.5.0
101+
location: https://github.com/pubnub/python/releases/download/v5.5.0/pubnub-5.5.0.tar.gz
102102
supported-platforms:
103103
supported-operating-systems:
104104
Linux:
@@ -169,6 +169,14 @@ sdks:
169169
license-url: https://github.com/aio-libs/aiohttp/blob/master/LICENSE.txt
170170
is-required: Required
171171
changelog:
172+
- date: 2021-12-16
173+
version: v5.5.0
174+
changes:
175+
176+
- date: 2021-12-16
177+
version: v5.4.0
178+
changes:
179+
172180
- version: v5.4.0
173181
date: 2021-10-07
174182
changes:
@@ -479,6 +487,7 @@ features:
479487
- ACCESS-GRANT-TOKEN
480488
- ACCESS-PARSE-TOKEN
481489
- ACCESS-SET-TOKEN
490+
- ACCESS-REVOKE-TOKEN
482491
channel-groups:
483492
- CHANNEL-GROUPS-ADD-CHANNELS
484493
- CHANNEL-GROUPS-REMOVE-CHANNELS

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v5.5.0
2+
December 16 2021
3+
4+
## v5.4.0
5+
December 16 2021
6+
17
## [v5.4.0](https://github.com/pubnub/python/releases/tag/v5.4.0)
28

39
[Full Changelog](https://github.com/pubnub/python/compare/v5.3.1...v5.4.0)

pubnub/endpoints/access/revoke.py

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from pubnub.enums import PNOperationType, HttpMethod
2+
from pubnub.endpoints.endpoint import Endpoint
3+
from pubnub.models.consumer.v3.access_manager import PNRevokeTokenResult
4+
from pubnub import utils
5+
6+
7+
class RevokeToken(Endpoint):
8+
REVOKE_TOKEN_PATH = "/v3/pam/%s/grant/%s"
9+
10+
def __init__(self, pubnub, token):
11+
Endpoint.__init__(self, pubnub)
12+
self.token = token
13+
14+
def validate_params(self):
15+
self.validate_subscribe_key()
16+
self.validate_secret_key()
17+
18+
def create_response(self, envelope):
19+
return PNRevokeTokenResult(envelope)
20+
21+
def is_auth_required(self):
22+
return False
23+
24+
def request_timeout(self):
25+
return self.pubnub.config.non_subscribe_request_timeout
26+
27+
def connect_timeout(self):
28+
return self.pubnub.config.connect_timeout
29+
30+
def http_method(self):
31+
return HttpMethod.DELETE
32+
33+
def custom_params(self):
34+
return {}
35+
36+
def build_path(self):
37+
return RevokeToken.REVOKE_TOKEN_PATH % (self.pubnub.config.subscribe_key, utils.url_encode(self.token))
38+
39+
def operation_type(self):
40+
return PNOperationType.PNAccessManagerRevokeToken
41+
42+
def name(self):
43+
return "RevokeToken"

pubnub/enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ class PNOperationType(object):
6969
PNFireOperation = 25
7070
PNSignalOperation = 26
7171

72+
PNAccessManagerRevokeToken = 40
7273
PNAccessManagerGrantToken = 41
74+
7375
PNAddMessageAction = 42
7476
PNGetMessageActions = 43
7577
PNDeleteMessageAction = 44

pubnub/managers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ def endpoint_name_for_operation(operation_type):
466466
PNOperationType.PNAccessManagerRevoke: 'pam',
467467
PNOperationType.PNTimeOperation: 'pam',
468468

469+
PNOperationType.PNAccessManagerGrantToken: 'pamv3',
470+
PNOperationType.PNAccessManagerRevokeToken: 'pamv3',
471+
469472
PNOperationType.PNSignalOperation: 'sig',
470473

471474
PNOperationType.PNSetUuidMetadataOperation: 'obj',
@@ -488,8 +491,6 @@ def endpoint_name_for_operation(operation_type):
488491
PNOperationType.PNRemoveMembershipsOperation: 'obj',
489492
PNOperationType.PNManageMembershipsOperation: 'obj',
490493

491-
PNOperationType.PNAccessManagerGrantToken: 'pamv3',
492-
493494
PNOperationType.PNAddMessageAction: 'msga',
494495
PNOperationType.PNGetMessageActions: 'msga',
495496
PNOperationType.PNDeleteMessageAction: 'msga',

pubnub/models/consumer/v3/access_manager.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ def __str__(self):
2121

2222
def get_token(self):
2323
return self.token
24+
25+
26+
class PNRevokeTokenResult:
27+
def __init__(self, result):
28+
self.status = result['status']
29+
30+
def __str__(self):
31+
return "Revoke token success with status: %s" % self.status

pubnub/pubnub_core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from .endpoints.access.audit import Audit
2828
from .endpoints.access.grant import Grant
2929
from .endpoints.access.grant_token import GrantToken
30-
from .endpoints.access.revoke import Revoke
30+
from .endpoints.access.revoke_token import RevokeToken
3131
from .endpoints.channel_groups.add_channel_to_channel_group import AddChannelToChannelGroup
3232
from .endpoints.channel_groups.list_channels_in_channel_group import ListChannelsInChannelGroup
3333
from .endpoints.channel_groups.remove_channel_from_channel_group import RemoveChannelFromChannelGroup
@@ -65,7 +65,7 @@
6565

6666
class PubNubCore:
6767
"""A base class for PubNub Python API implementations"""
68-
SDK_VERSION = "5.4.0"
68+
SDK_VERSION = "5.5.0"
6969
SDK_NAME = "PubNub-Python"
7070

7171
TIMESTAMP_DIVIDER = 1000
@@ -170,8 +170,8 @@ def grant(self):
170170
def grant_token(self):
171171
return GrantToken(self)
172172

173-
def revoke(self):
174-
return Revoke(self)
173+
def revoke_token(self, token):
174+
return RevokeToken(self, token)
175175

176176
def audit(self):
177177
return Audit(self)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='pubnub',
5-
version='5.4.0',
5+
version='5.5.0',
66
description='PubNub Real-time push service in the cloud',
77
author='PubNub',
88
author_email='[email protected]',

0 commit comments

Comments
 (0)