From f6f4396a81ce662eb5fb50c4f9fef92ffaadb333 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Thu, 13 Apr 2023 15:25:42 +0200 Subject: All: Implement a token handler This implements a token handler for OAuth tokens. Clients can use the SetTokenHandler function in exports to set a token handler. It needs two arguments, a getter and a setter. The getter is a callback with three arguments: - The server to get the tokens for, in types.server.current as JSON - The output buffer - The output buffer maximum length The tokens should be written to the output buffer with maximum length. The type should be types.server.Tokens and be marshalled as JSON. If no tokens are available, leave the output buffer intact The token setter is a callback with two arguments: - The server for which to set the tokens for, in types.server.Current as JSON - The tokens, defined in types.server.Tokens as JSON Breaking changes: - No more tokens as arguments, was already deprecated in previous commits - Tokens are no longer returned in types.server.Configuration --- wrappers/python/eduvpn_common/loader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'wrappers/python/eduvpn_common/loader.py') diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py index 961b569..1a172af 100644 --- a/wrappers/python/eduvpn_common/loader.py +++ b/wrappers/python/eduvpn_common/loader.py @@ -4,7 +4,7 @@ from collections import defaultdict from ctypes import CDLL, c_char_p, c_int, c_void_p, cdll from eduvpn_common import __version__ -from eduvpn_common.types import BoolError, DataError, ReadRxBytes, VPNStateChange +from eduvpn_common.types import BoolError, DataError, ReadRxBytes, TokenGetter, TokenSetter, VPNStateChange def load_lib() -> CDLL: @@ -88,6 +88,7 @@ def initialize_functions(lib: CDLL) -> None: c_int, ], c_void_p lib.RenewSession.argtypes, lib.RenewSession.restype = [c_int], c_void_p + lib.SetTokenHandler.argtypes, lib.SetTokenHandler.restype = [TokenGetter, TokenSetter], c_void_p lib.Cleanup.argtypes, lib.Cleanup.restype = [c_int], c_void_p lib.SetProfileID.argtypes, lib.SetProfileID.restype = [c_char_p], c_void_p lib.CookieNew.argtypes, lib.CookieNew.restype = [], c_int -- cgit v1.2.3