oldaplib 0.2.7__py3-none-any.whl → 0.2.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,7 +96,7 @@ class Connection(IConnection):
96
96
  _query_url: str
97
97
  _update_url: str
98
98
  _transaction_url: Optional[str]
99
- __jwtkey: str = os.getenv("OLDAP_JWT_SECRET", "You have to change this!!! +D&RWG+")
99
+ __jwtkey: str
100
100
  _switcher = {
101
101
  SparqlResultFormat.XML: lambda a: a.text,
102
102
  SparqlResultFormat.JSON: lambda a: a.json(),
@@ -140,6 +140,7 @@ class Connection(IConnection):
140
140
  in specific scenarios.
141
141
  """
142
142
  super().__init__(context_name=context_name)
143
+ self.__jwtkey = os.getenv("OLDAP_JWT_SECRET", "You have to change this!!! +D&RWG+")
143
144
  self._server = server or os.getenv("OLDAP_TS_SERVER", "http://localhost:7200")
144
145
  self._repo = repo or os.getenv("OLDAP_TS_REPO", "oldap")
145
146
  self._dbuser = dbuser or os.getenv("OLDAP_TS_USER", "")
@@ -153,7 +154,7 @@ class Connection(IConnection):
153
154
  context = Context(name=context_name)
154
155
  if token is not None:
155
156
  try:
156
- payload = jwt.decode(jwt=token, key=Connection.__jwtkey, algorithms="HS256")
157
+ payload = jwt.decode(jwt=token, key=self.__jwtkey, algorithms="HS256")
157
158
  except InvalidTokenError:
158
159
  logger.error("Connection with invalid token")
159
160
  raise OldapError("Wrong credentials")
@@ -206,7 +207,7 @@ class Connection(IConnection):
206
207
  }
207
208
  self._token = jwt.encode(
208
209
  payload=payload,
209
- key=Connection.__jwtkey,
210
+ key=self.__jwtkey,
210
211
  algorithm="HS256")
211
212
  #
212
213
  # Get projects and add to Context
@@ -252,10 +253,6 @@ class Connection(IConnection):
252
253
  """Getter for the JWT token"""
253
254
  return self.__jwtkey
254
255
 
255
- @jwtkey.setter
256
- def jwtkey(self, value: str) -> None:
257
- self.__jwtkey = value
258
-
259
256
  @property
260
257
  def server(self) -> str:
261
258
  """Getter for server string"""
oldaplib/src/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.7"
1
+ __version__ = "0.2.9"
@@ -1,3 +1,5 @@
1
+ import json
2
+ import os
1
3
  import unittest
2
4
  from datetime import datetime, timezone
3
5
  from pathlib import Path
@@ -11,6 +13,7 @@ from oldaplib.src.enums.sparql_result_format import SparqlResultFormat
11
13
  from oldaplib.src.helpers.context import Context
12
14
  from oldaplib.src.dtypes.bnode import BNode
13
15
  from oldaplib.src.dtypes.namespaceiri import NamespaceIRI
16
+ from oldaplib.src.helpers.serializer import serializer
14
17
  from oldaplib.src.xsd.iri import Iri
15
18
  from oldaplib.src.xsd.xsd_anyuri import Xsd_anyURI
16
19
  from oldaplib.src.xsd.xsd_qname import Xsd_QName
@@ -113,11 +116,15 @@ class TestBasicConnection(unittest.TestCase):
113
116
 
114
117
  #@unittest.skip('No longer used')
115
118
  def test_token(self):
116
- Connection.jwtkey = "This is a very special secret, yeah!"
119
+ os.environ["OLDAP_JWT_SECRET"] = "This is a very special secret, yeah!"
117
120
  con = Connection(userId="rosenth",
118
121
  credentials="RioGrande",
119
122
  context_name="DEFAULT")
120
123
  token = con.token
124
+ tokendata = jwt.decode(jwt=token, key=con.jwtkey, algorithms="HS256")
125
+ userdata = json.loads(tokendata['userdata'], object_hook=serializer.decoder_hook)
126
+ self.assertEqual(userdata.userId, "rosenth")
127
+
121
128
  con = Connection(token=token,
122
129
  context_name="DEFAULT")
123
130
  self.assertEqual(con.userid, Xsd_NCName("rosenth"))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oldaplib
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: Open Media Access Server Library (Linked Open Data middleware/RESTApi)
5
5
  License: GNU Affero General Public License version 3
6
6
  Author: Lukas Rosenthaler
@@ -7,7 +7,7 @@ oldaplib/ontologies/oldap.ttl,sha256=w4q5SX6UIeuYXI2nxNSxzsjZKfR5-mDoLaJXyODBUps
7
7
  oldaplib/ontologies/shared.trig,sha256=Am3_Nrp1j6fr3W0CEns-RczBRX96mQD0T1GgSjdmvDY,17233
8
8
  oldaplib/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  oldaplib/src/cachesingleton.py,sha256=RzQz5-rSAuqgF0TbkdHPwdOjoGxpHFqO8Fpips4AK54,3550
10
- oldaplib/src/connection.py,sha256=EhcohYB6Ktt4NleNKf90GJ-Z9G7afWZZVqrdJXbV9m8,29098
10
+ oldaplib/src/connection.py,sha256=LJMJO65QhSbheIEBnOCphRyAD1STwkO8zfNcYPcKwP8,29016
11
11
  oldaplib/src/datamodel.py,sha256=7jhqiFYT9fkn6cNTCn5Q7QfxSy29QyMrcVferPZLQrE,30309
12
12
  oldaplib/src/dtypes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  oldaplib/src/dtypes/bnode.py,sha256=aPdm6FpqqFXCAtZJtOniLwIUFRcxK4XmwpCcg3PEnGc,1554
@@ -66,7 +66,7 @@ oldaplib/src/propertyclass.py,sha256=sOxK1S5SEGOoUqSKrV4hxWAluNMagnTnPFoo5JuuWEQ
66
66
  oldaplib/src/resourceclass.py,sha256=DSuLMmgWutLUCbC1NuoBVwLHalDakeipMP3-NmnWx_g,98981
67
67
  oldaplib/src/user.py,sha256=Z4GXPRkaHXx3glUpPXQdFqYMxQPOuqayDwkTAE5RGjU,48820
68
68
  oldaplib/src/userdataclass.py,sha256=FbZkcRt0pKbOeqsZ7HbpwoKE-XPWH2AqpHG1GcsrBPo,12364
69
- oldaplib/src/version.py,sha256=LIho7asb0pp1iNbJvXEhRMluyGN4gB4RHIIbAKpROsc,21
69
+ oldaplib/src/version.py,sha256=oVsqrXzR8GvkVDBk6i2YQGHXmKdqeqypnb-K9OFmLlg,21
70
70
  oldaplib/src/xsd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
71
  oldaplib/src/xsd/floatingpoint.py,sha256=rDReKqh0mXyc4F5wslgTUxbeGf3-PGERyughj5_62YI,8852
72
72
  oldaplib/src/xsd/iri.py,sha256=tXOuDASdQ6k9KKp2wTO8H4K8yb-_o8jFPanua7wCHog,8269
@@ -113,7 +113,7 @@ oldaplib/src/xsd/xsd_unsignedlong.py,sha256=5fGH8_SAV1x6b0YGiIR44ZlJXjUiCUW6XHhC
113
113
  oldaplib/src/xsd/xsd_unsignedshort.py,sha256=M1E8SDR33rPJ0jUpRkzcDCcJYg17YfVbaItTuJeEibc,1013
114
114
  oldaplib/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
115
  oldaplib/test/test_cache.py,sha256=6TGukPUruuj5BsZaPGZdIx9L7v39qB9jIKZkg_GkbW4,702
116
- oldaplib/test/test_connection.py,sha256=IxYWM3DAzWQAJPItoCk1HZdrHH0hAG4tbPCSwsGlFZE,13078
116
+ oldaplib/test/test_connection.py,sha256=TM9f17G5RCa2B5gGWVbVhoLL0CUW1JHoM12Brz4P73U,13390
117
117
  oldaplib/test/test_context.py,sha256=cJJWzSiWpKq9UFhbScru_PdOAqaCWKB3f_lRzxcCm10,4939
118
118
  oldaplib/test/test_datamodel.py,sha256=6hE50zzh6tGb2PKQ4sFk-C829OM5qWOdsJKR107dhgw,54377
119
119
  oldaplib/test/test_dtypes.py,sha256=UVdlHNdJrJ5iujMWlwk9tOhRzouJYA8x0E-eLDXPmUo,8583
@@ -152,6 +152,6 @@ oldaplib/testdata/source_type.yaml,sha256=dSihKikw3O-IlGf6anj5KWMoBYLaweLVF1Zojm
152
152
  oldaplib/testdata/test_move_left_of_toL.yaml,sha256=2m1OSQrQFlsCQxeJrjzBAO74LMprNDo_HuyrYGsOeXI,787
153
153
  oldaplib/testdata/testlist.yaml,sha256=AT11nXEG81Sfyb-tr1gQV0H_dZBrOCcFuHf7YtL8P2g,1994
154
154
  oldaplib/testit.http,sha256=qW7mnr6aNLXFG6lQdLgyhXILOPN6qc5iFVZclLyVvkY,303
155
- oldaplib-0.2.7.dist-info/METADATA,sha256=LYvCy8XGpIyQ0EBwjO-20gZUAmGrkZ_6J7yvH5-CRUg,2803
156
- oldaplib-0.2.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
157
- oldaplib-0.2.7.dist-info/RECORD,,
155
+ oldaplib-0.2.9.dist-info/METADATA,sha256=UyG0whMOpshjA9sVHMfqAfqWxqnFcIkHG5jAtLlgcEw,2803
156
+ oldaplib-0.2.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
157
+ oldaplib-0.2.9.dist-info/RECORD,,