Skip to content

Commit c5f4a1e

Browse files
ISSUE #390
1 parent 0170855 commit c5f4a1e

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

packages/plugins/minos-discovery-kong/minos/plugins/kong/client.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
from __future__ import (
22
annotations,
33
)
4-
5-
from abc import (
6-
ABC,
7-
)
84
from datetime import (
95
datetime,
106
timedelta,
@@ -22,14 +18,15 @@
2218
from minos.common import (
2319
Config,
2420
SetupMixin,
21+
current_datetime
2522
)
2623

2724

28-
class KongClient(ABC, SetupMixin):
25+
class KongClient(SetupMixin):
2926
"""Kong Client class."""
3027

3128
def __init__(
32-
self, protocol: str = "http", host: str = None, port: str = None, token_expiration_sec: int = None, **kwargs
29+
self, protocol: str = "http", host: str = None, port: int = None, token_expiration_sec: int = None, **kwargs
3330
):
3431
super().__init__(**kwargs)
3532
if host is None:
@@ -46,7 +43,7 @@ def __init__(
4643
def _from_config(cls, config: Config, **kwargs) -> KongClient:
4744
discovery_config = config.get_discovery()
4845

49-
token_expiration_sec = discovery_config.get("token-exp-minutes")
46+
token_expiration_sec = discovery_config.get("token-exp")
5047
host = discovery_config.get("host")
5148
port = discovery_config.get("port")
5249

@@ -187,7 +184,7 @@ async def generate_jwt_token(
187184
) -> str:
188185
payload = {"iss": key, "exp": exp, "nbf": nbf}
189186

190-
current = datetime.now(tz=utc)
187+
current = current_datetime()
191188

192189
if not exp:
193190
payload["exp"] = current + timedelta(seconds=self.token_expiration_sec)

packages/plugins/minos-discovery-kong/minos/plugins/kong/discovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(
5353
)
5454

5555
if client is None:
56-
client = KongClient()
56+
client = KongClient(host=host, port=port)
5757

5858
self.client = client
5959

packages/plugins/minos-discovery-kong/tests/test_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ discovery:
22
connector: minos.networks.DiscoveryConnector
33
client: minos.networks.InMemoryDiscoveryClient
44
auth-type: jwt
5-
token-exp-minutes: 60
5+
token-exp: 60
66
host: localhost
77
port: 8001

0 commit comments

Comments
 (0)