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