mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-19 04:53:32 +00:00
28 lines
526 B
Go
28 lines
526 B
Go
package up9
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
func IsTokenValid(tokenString string, envName string) bool {
|
|
whoAmIUrl, _ := url.Parse(fmt.Sprintf("https://trcc.%s/admin/whoami", envName))
|
|
|
|
req := &http.Request{
|
|
Method: http.MethodGet,
|
|
URL: whoAmIUrl,
|
|
Header: map[string][]string{
|
|
"Authorization": {fmt.Sprintf("bearer %s", tokenString)},
|
|
},
|
|
}
|
|
|
|
response, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
defer response.Body.Close()
|
|
|
|
return response.StatusCode == http.StatusOK
|
|
}
|