@@ -42,12 +42,12 @@ func resolveAuthKey(ctx context.Context, baseURL, clientID, idToken string, tags
4242 baseURL = ipn .DefaultControlURL
4343 }
4444
45- ephemeral , preauth , err := parseOptionalAttributes (clientID )
45+ strippedID , ephemeral , preauth , err := parseOptionalAttributes (clientID )
4646 if err != nil {
4747 return "" , fmt .Errorf ("failed to parse optional config attributes: %w" , err )
4848 }
4949
50- accessToken , err := exchangeJWTForToken (ctx , baseURL , clientID , idToken )
50+ accessToken , err := exchangeJWTForToken (ctx , baseURL , strippedID , idToken )
5151 if err != nil {
5252 return "" , fmt .Errorf ("failed to exchange JWT for access token: %w" , err )
5353 }
@@ -79,15 +79,15 @@ func resolveAuthKey(ctx context.Context, baseURL, clientID, idToken string, tags
7979 return authkey , nil
8080}
8181
82- func parseOptionalAttributes (clientID string ) (ephemeral bool , preauthorized bool , err error ) {
83- _ , attrs , found := strings .Cut (clientID , "?" )
82+ func parseOptionalAttributes (clientID string ) (strippedID string , ephemeral bool , preauthorized bool , err error ) {
83+ strippedID , attrs , found := strings .Cut (clientID , "?" )
8484 if ! found {
85- return true , false , nil
85+ return clientID , true , false , nil
8686 }
8787
8888 parsed , err := url .ParseQuery (attrs )
8989 if err != nil {
90- return false , false , fmt .Errorf ("failed to parse optional config attributes: %w" , err )
90+ return "" , false , false , fmt .Errorf ("failed to parse optional config attributes: %w" , err )
9191 }
9292
9393 for k := range parsed {
@@ -97,11 +97,14 @@ func parseOptionalAttributes(clientID string) (ephemeral bool, preauthorized boo
9797 case "preauthorized" :
9898 preauthorized , err = strconv .ParseBool (parsed .Get (k ))
9999 default :
100- return false , false , fmt .Errorf ("unknown optional config attribute %q" , k )
100+ return "" , false , false , fmt .Errorf ("unknown optional config attribute %q" , k )
101101 }
102102 }
103+ if err != nil {
104+ return "" , false , false , err
105+ }
103106
104- return ephemeral , preauthorized , err
107+ return strippedID , ephemeral , preauthorized , nil
105108}
106109
107110// exchangeJWTForToken exchanges a JWT for a Tailscale access token.
0 commit comments