Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

cli: Improve support handling passkey login for selfhost

Neeraj Guptabc39f601833e
diff --git a/cli/config.yaml.example b/cli/config.yaml.example
index a709e080ed..8a4627d555 100644
--- a/cli/config.yaml.example
+++ b/cli/config.yaml.example
@@ -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
diff --git a/cli/internal/api/login_type.go b/cli/internal/api/login_type.go
index 951e72fcc1..3980ab9d49 100644
--- a/cli/internal/api/login_type.go
+++ b/cli/internal/api/login_type.go
@@ -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"`
diff --git a/cli/main.go b/cli/main.go
index 15dc6ac5a3..013557d1fb 100644
--- a/cli/main.go
+++ b/cli/main.go
@@ -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 {
diff --git a/cli/pkg/sign_in.go b/cli/pkg/sign_in.go
index 7fb54738db..26f3db1f0c 100644
--- a/cli/pkg/sign_in.go
+++ b/cli/pkg/sign_in.go
@@ -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)