// Temporary hack that we use to determine if
// Our CLI needs to use mas-sso token
Temporary hack that we use to determine if
Our CLI needs to use mas-sso token
// Temporary hack that we use to determine if // Our CLI needs to use mas - sso token
func ShouldUseMasSSO(logger logging.Logger, apiUrl string) bool {
	req, err := http.NewRequest("GET", apiUrl+"/api/kafkas_mgmt/v1/sso_providers", nil)
	if err != nil {
		logger.Debug("Error when fetching auth config", err)
		return true
	}
	req = req.WithContext(context.Background())
	req.Header.Set("Accept", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		logger.Debug("Error when fetching auth config", err)
		return true
	}
	defer resp.Body.Close()
	b, err := io.ReadAll(resp.Body)
	if err != nil {
		logger.Debug("Error when fetching auth config", err)
		return true
	}
	response := string(b)
	var provider *kafkamgmtclient.SsoProvider
	responseBytes := []byte(fmt.Sprintf("%v", response))
	err = json.Unmarshal(responseBytes, &provider)
	if err != nil {
		logger.Debug("Error when fetching auth config", err)
		return true
	}
	if provider.GetBaseUrl() == "" {
		logger.Debug("Error when fetching auth config", err)
		return true
	}
	return provider.GetName() == "mas_sso"
}
func ShouldUseMasSSO ( logger logging . Logger , apiUrl string ) bool { req , err := http . NewRequest ( " " , apiUrl + " " , nil ) if err != nil { logger . Debug ( " " , err ) return true } req = req . WithContext ( context . Background ( ) ) req . Header . Set ( " " , " " ) resp , err := http . DefaultClient . Do ( req ) if err != nil { logger . Debug ( " " , err ) return true } defer resp . Body . Close ( ) b , err := io . ReadAll ( resp . Body ) if err != nil { logger . Debug ( " " , err ) return true } response := string ( b ) var provider * kafkamgmtclient . SsoProvider responseBytes := [ ] byte ( fmt . Sprintf ( " " , response ) ) err = json . Unmarshal ( responseBytes , & provider ) if err != nil { logger . Debug ( " " , err ) return true } if provider . GetBaseUrl ( ) == " " { logger . Debug ( " " , err ) return true } return provider . GetName ( ) == " " }
Temporary hack that we use to determine if
Our CLI needs to use mas-sso token
Temporary hack that we use to determine if Our CLI needs to use mas - sso token
// defining a struct instance