supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.02k stars 201 forks source link

How to signout from CLI #1688

Closed iammohan01 closed 9 months ago

iammohan01 commented 10 months ago

How can i signout supabse account from cli ?

kamilogorek commented 10 months ago

Remove access token from the default keyring of your operating system. For OSX it's Keychain, for Windows it's "Accessing Credential Manager" and most linux distros have their own "Passwords and Keys" apps. See https://pkg.go.dev/github.com/zalando/go-keyring@v0.2.3#section-readme for implementation details.

If not supported, it fallbacks to $HOME/.supabase/access-token file.

iammohan01 commented 10 months ago

Thanks man, fixed. but why don't we have command like supabase logout ?

kamilogorek commented 9 months ago

That sounds like a good addition. PRs welcome :)

iammohan01 commented 9 months ago

@kamilogorek is there anything contains other than access token in this file ~/.supabase/access-token ?

Is it safe to delete this file while logout ?

S96EA commented 9 months ago

I added code regarding logout command, but when I am not in a logged-in state, I get a panic when using supabase projects list. It seems like another issue. Because we didn't pass Encryption when prompt login: root.go

owen@vm:~/goproject/src/github.com/supabase/cli|main⚡ ⇒  ./main projects list
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1243b1c]

goroutine 1 [running]:
github.com/supabase/cli/internal/login.Run({0x180a0b8, 0x21e3f00}, 0x126d5c5?, {{0x0, 0x0}, {0x0, 0x0}, 0x0, {0x0, 0x0}, ...})
        /home/owen/goproject/src/github.com/supabase/cli/internal/login/login.go:186 +0x1dc
github.com/supabase/cli/cmd.PromptLogin({0x180a0b8, 0x21e3f00}, {0x1810ac0, 0x21e3f00})
        /home/owen/goproject/src/github.com/supabase/cli/cmd/root.go:41 +0xe5
github.com/supabase/cli/cmd.glob..func91(0x21827a0, {0x14a0e2f?, 0x4?, 0x14a0e33?})
        /home/owen/goproject/src/github.com/supabase/cli/cmd/root.go:87 +0x11c
github.com/spf13/cobra.(*Command).execute(0x21827a0, {0x21e3f00, 0x0, 0x0})
        /home/owen/goproject/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:954 +0x94b
github.com/spf13/cobra.(*Command).ExecuteC(0x2189200)
        /home/owen/goproject/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        /home/owen/goproject/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/supabase/cli/cmd.Execute()
        /home/owen/goproject/src/github.com/supabase/cli/cmd/root.go:115 +0x1e
main.main()
        /home/owen/goproject/src/github.com/supabase/cli/main.go:8 +0xf
kamilogorek commented 9 months ago

Good catch, thanks! Fixed in #1700

@kamilogorek is there anything contains other than access token in this file ~/.supabase/access-token ? Is it safe to delete this file while logout ?

No, just a token. And in keyring its scoped to a predefined key, so you don't need to do any existence checks if someone calls logout multiple times (other than standard go errors for removing missing file).