From a84050a5e93f5fb9f5bbb79ca21b37e8359cf289 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 6 Feb 2024 16:27:45 +0100 Subject: Server: Refactor internal server package to use new state file This completely rewrites the internal server package. Some advantages: - Caches less - Uses a callback interface so that the client package does not get so convoluted - Introduce a new API package that only deals with the server API and uses github.com/jwijenbergh/eduoauth-go --- internal/api/redirect.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 internal/api/redirect.go (limited to 'internal/api/redirect.go') diff --git a/internal/api/redirect.go b/internal/api/redirect.go new file mode 100644 index 0000000..5d9e749 --- /dev/null +++ b/internal/api/redirect.go @@ -0,0 +1,23 @@ +package api + +// customRedirects supplies redirect values that should be handled by the app itself +// here we hardcode the redirect values that we should use in the OAuth requests +// these values were taken from https://git.sr.ht/~fkooman/vpn-user-portal/tree/v3/item/src/OAuth/VpnClientDb.php +var customRedirects = map[string]string{ + "org.letsconnect-vpn.app.ios": "org.letsconnect-vpn.app.ios:/api/callback", + "org.letsconnect-vpn.app.android": "org.letsconnect-vpn.app:/api/callback", + "org.eduvpn.app.ios": "org.eduvpn.app.ios:/api/callback", + "org.eduvpn.app.android": "org.eduvpn.app:/api/callback", +} + +// customRedirect returns the custom redirect string for the clientID `cid` +// Empty string if none is defined or one is defined but is empty. +// In both empty string cases, eduvpn-common handles the redirects as 127.0.0.1 local server redirects +// If a non-empty string is returned, the redirect should be handled by the client and we only use the redirect URI value in our OAuth requests +func customRedirect(cid string) string { + v, ok := customRedirects[cid] + if !ok { + return "" + } + return v +} -- cgit v1.2.3