mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-11 03:37:42 +00:00
* add login flow * add logout functionality * improve code * implement token and status print * implement status command * add user to login * improve server port management * improve login flow * fix login flow * make insights URL for login configurable * remove comments * fix logrus directive usage * add upload-insights command * remove unnecessary usage of pointer * error when using upload-insights and audit-path simultaneously * upload-insights support * set priority to reports * adds report verification * fix logging to meet expected results * renaming variable name * improve results printing * improve variable naming * remove TODO * Update checks severities (#950) * change all ignore checks to warning * promoting checks initially warning that should be danger. * fixing docs and examples * adds changelog * fix changelog version * improve general error message * update workloads to be able grab its version * print URL on stdout on browser error * use os.WriteFile instead of low-level API * renaming fn params * add insights client * validating token on auth status * minor fix * only query for re-auth if token is still valid * update some dependencies in go and CI (#951) * update some dependencies * update testing requirements * Fix cert-manager * lots of deprecated versions * attempts * review suggestions * avoid nil pointer * fix fixtures * fix test --------- Co-authored-by: Robert Brennan <contact@rbren.io> * update changelog --------- Co-authored-by: Andrew Suderman <andy@fairwinds.com> Co-authored-by: Robert Brennan <contact@rbren.io>
36 lines
620 B
Go
36 lines
620 B
Go
package auth
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func HandleLogout() error {
|
|
if !IsLoggedIn() {
|
|
fmt.Println("not logged in to Fairwinds Insights")
|
|
return nil
|
|
}
|
|
err := performLogout()
|
|
if err != nil {
|
|
return fmt.Errorf("performing logout: %v", err)
|
|
}
|
|
fmt.Println("✓ Logged out of Fairwinds Insights")
|
|
return nil
|
|
}
|
|
|
|
func performLogout() error {
|
|
content, err := readPolarisHostsFile()
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
|
|
if len(content) > 0 {
|
|
err = os.WriteFile(polarisHostsFilepath, []byte("{}"), os.ModePerm)
|
|
if err != nil {
|
|
return fmt.Errorf("writing data to file: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
return nil
|
|
}
|