[cli] Improve support handling passkey login for selfhost (#6328)
## Description Removed the need for specifying account's app url as server returns the same in the response to auth challenge. ## Tests
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
|
||||
endpoint:
|
||||
api: "http://localhost:8080"
|
||||
# Endpoint for the account service for passkey
|
||||
accounts: "http://localhost:3001"
|
||||
|
||||
log:
|
||||
http: false # log status code & time taken by requests
|
||||
|
||||
@@ -35,6 +35,7 @@ type AuthorizationResponse struct {
|
||||
ID int64 `json:"id"`
|
||||
KeyAttributes *KeyAttributes `json:"keyAttributes,omitempty"`
|
||||
EncryptedToken string `json:"encryptedToken,omitempty"`
|
||||
AccountsUrl string `json:"accountsUrl"`
|
||||
Token string `json:"token,omitempty"`
|
||||
TwoFactorSessionID string `json:"twoFactorSessionID"`
|
||||
PassKeySessionID string `json:"passkeySessionID"`
|
||||
|
||||
@@ -110,7 +110,6 @@ func initConfig(cliConfigDir string) {
|
||||
viper.AddConfigPath(".") // optionally look for config in the working directory
|
||||
|
||||
viper.SetDefault("endpoint.api", constants.EnteApiUrl)
|
||||
viper.SetDefault("endpoint.accounts", constants.EnteAccountUrl)
|
||||
viper.SetDefault("log.http", false)
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
eCrypto "github.com/ente-io/cli/internal/crypto"
|
||||
"github.com/ente-io/cli/pkg/model"
|
||||
"github.com/ente-io/cli/utils/browser"
|
||||
"github.com/ente-io/cli/utils/constants"
|
||||
"github.com/ente-io/cli/utils/encoding"
|
||||
"github.com/spf13/viper"
|
||||
"log"
|
||||
|
||||
"github.com/kong/go-srp"
|
||||
@@ -145,7 +145,10 @@ func (c *ClICtrl) verifyPassKey(ctx context.Context, authResp *api.Authorization
|
||||
if !authResp.IsPasskeyRequired() {
|
||||
return authResp, nil
|
||||
}
|
||||
baseAccountUrl := viper.GetString("endpoint.accounts")
|
||||
baseAccountUrl := constants.EnteAccountUrl
|
||||
if authResp.AccountsUrl != "" {
|
||||
baseAccountUrl = authResp.AccountsUrl
|
||||
}
|
||||
passkeyAuthUrl := fmt.Sprintf("%s/passkeys/verify?passkeySessionID=%s&redirect=ente-cli://passkey&clientPackage=%s", baseAccountUrl, authResp.PassKeySessionID, app.ClientPkg())
|
||||
fmt.Printf("Open this url in browser to verify passkey: %s\n", passkeyAuthUrl)
|
||||
err := browser.OpenURL(passkeyAuthUrl)
|
||||
|
||||
Reference in New Issue
Block a user