mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-02 18:11:59 +00:00
ipn: add Login backend command for sign-in with token
The StartLoginInteractive command is for delegating the sign-in flow to a browser. The Android Gooogle Sign-In SDK inverts the flow by giving the client ID tokens. Add a new backend command for accepting such tokens by exposing the existing controlclient.Client.Login support for OAuth2 tokens. Introduce a custom TokenType to distinguish ID tokens from other OAuth2 tokens. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
11
ipn/local.go
11
ipn/local.go
@@ -13,6 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/tailscale/wireguard-go/wgcfg"
|
||||
"golang.org/x/oauth2"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/control/controlclient"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
@@ -612,6 +613,16 @@ func (b *LocalBackend) getEngineStatus() EngineStatus {
|
||||
return b.engineStatus
|
||||
}
|
||||
|
||||
// Login implements Backend.
|
||||
func (b *LocalBackend) Login(token *oauth2.Token) {
|
||||
b.mu.Lock()
|
||||
b.assertClientLocked()
|
||||
c := b.c
|
||||
b.mu.Unlock()
|
||||
|
||||
c.Login(token, controlclient.LoginInteractive)
|
||||
}
|
||||
|
||||
// StartLoginInteractive implements Backend. It requests a new
|
||||
// interactive login from controlclient, unless such a flow is already
|
||||
// in progress, in which case StartLoginInteractive attempts to pick
|
||||
|
||||
Reference in New Issue
Block a user