mirror of https://github.com/portainer/portainer
fix(openamt): fix IsFeatureFlagEnabled, rename MPS Url to MPS Server (#6185)
Co-authored-by: cheloRydel <marcelorydel26@gmail.com>pull/6195/head
parent
f360392d39
commit
ff6185cc81
|
@ -51,7 +51,7 @@ func (service *Service) IsFeatureFlagEnabled(feature portainer.Feature) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
featureFlagSetting, ok := settings.FeatureFlagSettings[portainer.FeatOpenAMT]
|
||||
featureFlagSetting, ok := settings.FeatureFlagSettings[feature]
|
||||
if ok {
|
||||
return featureFlagSetting
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ type authenticationResponse struct {
|
|||
}
|
||||
|
||||
func (service *Service) executeAuthenticationRequest(configuration portainer.OpenAMTConfiguration) (*authenticationResponse, error) {
|
||||
loginURL := fmt.Sprintf("https://%s/mps/login/api/v1/authorize", configuration.MPSURL)
|
||||
loginURL := fmt.Sprintf("https://%s/mps/login/api/v1/authorize", configuration.MPSServer)
|
||||
|
||||
payload := map[string]string{
|
||||
"username": configuration.Credentials.MPSUser,
|
||||
|
|
|
@ -45,7 +45,7 @@ func (service *Service) createOrUpdateCIRAConfig(configuration portainer.OpenAMT
|
|||
}
|
||||
|
||||
func (service *Service) getCIRAConfig(configuration portainer.OpenAMTConfiguration, configName string) (*CIRAConfig, error) {
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/ciraconfigs/%s", configuration.MPSURL, configName)
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/ciraconfigs/%s", configuration.MPSServer, configName)
|
||||
|
||||
responseBody, err := service.executeGetRequest(url, configuration.Credentials.MPSToken)
|
||||
if err != nil {
|
||||
|
@ -64,22 +64,22 @@ func (service *Service) getCIRAConfig(configuration portainer.OpenAMTConfigurati
|
|||
}
|
||||
|
||||
func (service *Service) saveCIRAConfig(method string, configuration portainer.OpenAMTConfiguration, configName string) (*CIRAConfig, error) {
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/ciraconfigs", configuration.MPSURL)
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/ciraconfigs", configuration.MPSServer)
|
||||
|
||||
certificate, err := service.getCIRACertificate(configuration)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
addressFormat, err := addressFormat(configuration.MPSURL)
|
||||
addressFormat, err := addressFormat(configuration.MPSServer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
config := CIRAConfig{
|
||||
ConfigName: configName,
|
||||
MPSServerAddress: configuration.MPSURL,
|
||||
CommonName: configuration.MPSURL,
|
||||
MPSServerAddress: configuration.MPSServer,
|
||||
CommonName: configuration.MPSServer,
|
||||
ServerAddressFormat: addressFormat,
|
||||
MPSPort: 4433,
|
||||
Username: "admin",
|
||||
|
@ -117,7 +117,7 @@ func addressFormat(url string) (int, error) {
|
|||
}
|
||||
|
||||
func (service *Service) getCIRACertificate(configuration portainer.OpenAMTConfiguration) (string, error) {
|
||||
loginURL := fmt.Sprintf("https://%s/mps/api/v1/ciracert", configuration.MPSURL)
|
||||
loginURL := fmt.Sprintf("https://%s/mps/api/v1/ciracert", configuration.MPSServer)
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, loginURL, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -37,7 +37,7 @@ func (service *Service) createOrUpdateDomain(configuration portainer.OpenAMTConf
|
|||
}
|
||||
|
||||
func (service *Service) getDomain(configuration portainer.OpenAMTConfiguration) (*Domain, error) {
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/domains/%s", configuration.MPSURL, configuration.DomainConfiguration.DomainName)
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/domains/%s", configuration.MPSServer, configuration.DomainConfiguration.DomainName)
|
||||
|
||||
responseBody, err := service.executeGetRequest(url, configuration.Credentials.MPSToken)
|
||||
if err != nil {
|
||||
|
@ -56,7 +56,7 @@ func (service *Service) getDomain(configuration portainer.OpenAMTConfiguration)
|
|||
}
|
||||
|
||||
func (service *Service) saveDomain(method string, configuration portainer.OpenAMTConfiguration) (*Domain, error) {
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/domains", configuration.MPSURL)
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/domains", configuration.MPSServer)
|
||||
|
||||
profile := Domain{
|
||||
DomainName: configuration.DomainConfiguration.DomainName,
|
||||
|
|
|
@ -48,7 +48,7 @@ func (service *Service) createOrUpdateAMTProfile(configuration portainer.OpenAMT
|
|||
}
|
||||
|
||||
func (service *Service) getAMTProfile(configuration portainer.OpenAMTConfiguration, profileName string) (*Profile, error) {
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/profiles/%s", configuration.MPSURL, profileName)
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/profiles/%s", configuration.MPSServer, profileName)
|
||||
|
||||
responseBody, err := service.executeGetRequest(url, configuration.Credentials.MPSToken)
|
||||
if err != nil {
|
||||
|
@ -67,7 +67,7 @@ func (service *Service) getAMTProfile(configuration portainer.OpenAMTConfigurati
|
|||
}
|
||||
|
||||
func (service *Service) saveAMTProfile(method string, configuration portainer.OpenAMTConfiguration, profileName string, ciraConfigName string, wirelessConfig string) (*Profile, error) {
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/profiles", configuration.MPSURL)
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/profiles", configuration.MPSServer)
|
||||
|
||||
profile := Profile{
|
||||
ProfileName: profileName,
|
||||
|
|
|
@ -38,7 +38,7 @@ func (service *Service) createOrUpdateWirelessConfig(configuration portainer.Ope
|
|||
}
|
||||
|
||||
func (service *Service) getWirelessConfig(configuration portainer.OpenAMTConfiguration, configName string) (*WirelessProfile, error) {
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/wirelessconfigs/%s", configuration.MPSURL, configName)
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/wirelessconfigs/%s", configuration.MPSServer, configName)
|
||||
|
||||
responseBody, err := service.executeGetRequest(url, configuration.Credentials.MPSToken)
|
||||
if err != nil {
|
||||
|
@ -66,7 +66,7 @@ func (service *Service) saveWirelessConfig(method string, configuration portaine
|
|||
return nil, fmt.Errorf("error parsing wireless encryption method: %s", err.Error())
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/wirelessconfigs", configuration.MPSURL)
|
||||
url := fmt.Sprintf("https://%s/rps/api/v1/admin/wirelessconfigs", configuration.MPSServer)
|
||||
|
||||
config := WirelessProfile{
|
||||
ProfileName: configName,
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
type openAMTConfigureDefaultPayload struct {
|
||||
EnableOpenAMT bool
|
||||
MPSURL string
|
||||
MPSServer string
|
||||
MPSUser string
|
||||
MPSPassword string
|
||||
CertFileText string
|
||||
|
@ -33,8 +33,8 @@ type openAMTConfigureDefaultPayload struct {
|
|||
|
||||
func (payload *openAMTConfigureDefaultPayload) Validate(r *http.Request) error {
|
||||
if payload.EnableOpenAMT {
|
||||
if payload.MPSURL == "" {
|
||||
return errors.New("MPS Url must be provided")
|
||||
if payload.MPSServer == "" {
|
||||
return errors.New("MPS Server must be provided")
|
||||
}
|
||||
if payload.MPSUser == "" {
|
||||
return errors.New("MPS User must be provided")
|
||||
|
@ -145,8 +145,8 @@ func isValidIssuer(issuer string) bool {
|
|||
|
||||
func (handler *Handler) enableOpenAMT(configurationPayload openAMTConfigureDefaultPayload) error {
|
||||
configuration := portainer.OpenAMTConfiguration{
|
||||
Enabled: true,
|
||||
MPSURL: configurationPayload.MPSURL,
|
||||
Enabled: true,
|
||||
MPSServer: configurationPayload.MPSServer,
|
||||
Credentials: portainer.MPSCredentials{
|
||||
MPSUser: configurationPayload.MPSUser,
|
||||
MPSPassword: configurationPayload.MPSPassword,
|
||||
|
|
|
@ -42,7 +42,7 @@ type (
|
|||
// OpenAMTConfiguration represents the credentials and configurations used to connect to an OpenAMT MPS server
|
||||
OpenAMTConfiguration struct {
|
||||
Enabled bool `json:"Enabled"`
|
||||
MPSURL string `json:"MPSURL"`
|
||||
MPSServer string `json:"MPSServer"`
|
||||
Credentials MPSCredentials `json:"Credentials"`
|
||||
DomainConfiguration DomainConfiguration `json:"DomainConfiguration"`
|
||||
WirelessConfiguration *WirelessConfiguration `json:"WirelessConfiguration"`
|
||||
|
|
|
@ -6,7 +6,7 @@ class OpenAmtController {
|
|||
this.originalValues = {};
|
||||
this.formValues = {
|
||||
enableOpenAMT: false,
|
||||
mpsURL: '',
|
||||
mpsServer: '',
|
||||
mpsUser: '',
|
||||
mpsPassword: '',
|
||||
domainName: '',
|
||||
|
@ -85,7 +85,7 @@ class OpenAmtController {
|
|||
this.formValues = {
|
||||
...this.formValues,
|
||||
enableOpenAMT: config.Enabled,
|
||||
mpsURL: config.MPSURL,
|
||||
mpsServer: config.MPSServer,
|
||||
mpsUser: config.Credentials.MPSUser,
|
||||
domainName: config.DomainConfiguration.DomainName,
|
||||
};
|
||||
|
|
|
@ -16,24 +16,24 @@
|
|||
<hr />
|
||||
|
||||
<div class="form-group">
|
||||
<label for="mps_url" class="col-sm-3 control-label text-left">
|
||||
MPS URL
|
||||
<label for="mps_server" class="col-sm-3 control-label text-left">
|
||||
MPS Server
|
||||
</label>
|
||||
<div class="col-sm-8">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
ng-model="$ctrl.formValues.mpsURL"
|
||||
id="mps_url"
|
||||
name="mps_url"
|
||||
placeholder="Enter the MPS URL"
|
||||
ng-model="$ctrl.formValues.mpsServer"
|
||||
id="mps_server"
|
||||
name="mps_server"
|
||||
placeholder="Enter the MPS Server"
|
||||
ng-required="$ctrl.formValues.enableOpenAMT"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12" ng-show="openAMTForm.mps_url.$invalid">
|
||||
<div class="form-group col-md-12" ng-show="openAMTForm.mps_server.$invalid">
|
||||
<div class="small text-warning">
|
||||
<div ng-messages="openAMTForm.mps_url.$error">
|
||||
<div ng-messages="openAMTForm.mps_server.$error">
|
||||
<p ng-message="required"> <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue