diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-04-13 15:25:42 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | f6f4396a81ce662eb5fb50c4f9fef92ffaadb333 (patch) | |
| tree | 3e6b1c3ecc049c1aa377c8ca813f00b96437d2f3 /internal/server/server.go | |
| parent | 5610dca6c5e391ee62874c4d6cb25072d9c3c1d9 (diff) | |
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
Diffstat (limited to 'internal/server/server.go')
| -rw-r--r-- | internal/server/server.go | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/internal/server/server.go b/internal/server/server.go index e7229c5..c34158a 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -108,9 +108,6 @@ type ConfigData struct { // The type of configuration Type string - - // The tokens - Tokens oauth.Token } // Public gets the public data from the types package @@ -120,7 +117,6 @@ func (c *ConfigData) Public(dg bool) srvtypes.Configuration { VPNConfig: c.Config, Protocol: protocol.New(c.Type), DefaultGateway: dg, - Tokens: c.Tokens.Public(), } } @@ -154,13 +150,7 @@ func wireguardGetConfig(ctx context.Context, srv Server, preferTCP bool, openVPN cfg = wireguard.ConfigAddKey(cfg, key) } - t := oauth.Token{} - o := srv.OAuth() - if o != nil { - t = o.Token() - } - - return &ConfigData{Config: cfg, Type: proto, Tokens: t}, nil + return &ConfigData{Config: cfg, Type: proto}, nil } func openVPNGetConfig(ctx context.Context, srv Server, preferTCP bool) (*ConfigData, error) { @@ -178,14 +168,7 @@ func openVPNGetConfig(ctx context.Context, srv Server, preferTCP bool) (*ConfigD b.StartTime = time.Now() b.EndTime = exp - t := oauth.Token{} - - o := srv.OAuth() - if o != nil { - t = o.Token() - } - - return &ConfigData{Config: cfg, Type: "openvpn", Tokens: t}, nil + return &ConfigData{Config: cfg, Type: "openvpn"}, nil } func HasValidProfile(ctx context.Context, srv Server, wireguardSupport bool) (bool, error) { |
