summaryrefslogtreecommitdiff
path: root/internal/api/redirect.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-02-06 16:27:45 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-02-19 14:15:07 +0100
commita84050a5e93f5fb9f5bbb79ca21b37e8359cf289 (patch)
treeecdf0cea81b0bd6a3cf669f2b31c45a222d1c5f5 /internal/api/redirect.go
parent3152078aec8334357a61171838f664eb03299211 (diff)
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
Diffstat (limited to 'internal/api/redirect.go')
-rw-r--r--internal/api/redirect.go23
1 files changed, 23 insertions, 0 deletions
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
+}