Skip to content

Commit

Permalink
removed RSA2FA related code
Browse files Browse the repository at this point in the history
removing commented code
  • Loading branch information
sapana05 committed Jan 17, 2025
1 parent 430a3bd commit 03fb2d2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func loadActiveDirectoryAttributesState(service *gofish.Service, d *models.Direc
}

// nolint: gocyclo, gocognit,revive
activeDirectoryAttributes := []string{".CertValidationEnable", ".SSOEnable", ".AuthTimeout", ".DCLookupEnable", ".DCLookupByUserDomain", ".DCLookupDomainName", ".Schema", ".GCLookupEnable", ".GCRootDomain", ".GlobalCatalog1", ".GlobalCatalog2", ".GlobalCatalog3", ".RacName", ".RacDomain" /* , ".RSASecurID2FAAD" */}
activeDirectoryAttributes := []string{".CertValidationEnable", ".SSOEnable", ".AuthTimeout", ".DCLookupEnable", ".DCLookupByUserDomain", ".DCLookupDomainName", ".Schema", ".GCLookupEnable", ".GCRootDomain", ".GlobalCatalog1", ".GlobalCatalog2", ".GlobalCatalog3", ".RacName", ".RacDomain"}
attributesToReturn := make(map[string]attr.Value)
for k, v := range idracAttributesState.Attributes.Elements() {
if strings.HasPrefix(k, "ActiveDirectory.") {
Expand All @@ -180,7 +180,7 @@ func loadActiveDirectoryAttributesState(service *gofish.Service, d *models.Direc
}
}
// nolint: revive
if (strings.HasPrefix(k, "UserDomain.") && strings.HasSuffix(k, ".Name")) || (strings.HasPrefix(k, "ADGroup.") && strings.HasSuffix(k, ".Name")) /* || (strings.HasPrefix(k, "RSASecurID2FA.") && strings.HasSuffix(k, ".RSASecurIDAuthenticationServer")) */ {
if (strings.HasPrefix(k, "UserDomain.") && strings.HasSuffix(k, ".Name")) || (strings.HasPrefix(k, "ADGroup.") && strings.HasSuffix(k, ".Name")) {
attributesToReturn[k] = v
}
}
Expand All @@ -196,7 +196,7 @@ func loadLDAPAttributesState(service *gofish.Service, d *models.DirectoryService
}

// nolint: gocyclo, gocognit,revive
ldapAttributes := []string{".CertValidationEnable", ".GroupAttributeIsDN", ".Port", ".BindDN", ".BindPassword", ".SearchFilter" /* , ".RSASecurID2FALDAP" */}
ldapAttributes := []string{".CertValidationEnable", ".GroupAttributeIsDN", ".Port", ".BindDN", ".BindPassword", ".SearchFilter"}
attributesToReturn := make(map[string]attr.Value)
for k, v := range idracAttributesState.Attributes.Elements() {
if strings.HasPrefix(k, "LDAP.") {
Expand All @@ -206,9 +206,6 @@ func loadLDAPAttributesState(service *gofish.Service, d *models.DirectoryService
}
}
}
/* if strings.HasPrefix(k, "RSASecurID2FA.") && strings.HasSuffix(k, ".RSASecurIDAuthenticationServer") {
attributesToReturn[k] = v
} */
}

d.LDAPAttributes = types.MapValueMust(types.StringType, attributesToReturn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,6 @@ func updateActiveDirectory(ctx context.Context, serviceURI string, service *gofi
return diags
}

/* if authFactorCheck, diags := isValid2FactorAuth(plan.ActiveDirectoryAttributes); diags.HasError() || !authFactorCheck {
return diags
} */

patchBody := make(map[string]interface{})
if patchBody[ActiveDirectory], diags = getActiveDirectoryPatchBody(ctx, plan); diags.HasError() {
return diags
Expand Down Expand Up @@ -395,10 +391,6 @@ func updateActiveDirectory(ctx context.Context, serviceURI string, service *gofi

// nolint: revive
func updateLDAP(ctx context.Context, serviceURI string, service *gofish.Service, plan *models.DirectoryServiceAuthProviderResource) (diags diag.Diagnostics) {
/* if authFactorCheck, diags := isValid2FactorAuth(plan.LDAPAttributes); diags.HasError() || !authFactorCheck {
return diags
} */

patchBody := make(map[string]interface{})
if patchBody["LDAP"], diags = getLDAPPatchBody(ctx, plan); diags.HasError() {
return diags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import (
)

const (
// RSASecurID2FA is rsa Secure Id 2 factor authentication
RSASecurID2FA = "RSASecurID2FA"
// Disabled disable the service
Disabled = "Disabled"
// Enabled enable the service
Expand Down Expand Up @@ -238,27 +236,6 @@ func getkAttributeskeyValue(attributes types.Map, prefix string, suffix string)
return ""
}

/* func isValid2FactorAuth(attributes types.Map) (bool, diag.Diagnostics) {
var diags diag.Diagnostics
// attributes := attrsState.ActiveDirectoryAttributes
checkey2FA := checkAttributeskeyPresent(attributes, RSASecurID2FA, "RSASecurIDAccessKey")
checkID2FA := checkAttributeskeyPresent(attributes, RSASecurID2FA, "RSASecurIDClientID")
checkServer2FA := checkAttributeskeyPresent(attributes, RSASecurID2FA, "RSASecurIDAuthenticationServer")
if checkey2FA || checkID2FA || checkServer2FA {
checkey2FAValue := getkAttributeskeyValue(attributes, RSASecurID2FA, "RSASecurIDAccessKey")
checID2FAValue := getkAttributeskeyValue(attributes, RSASecurID2FA, "RSASecurIDClientID")
checkServer2FAValue := getkAttributeskeyValue(attributes, RSASecurID2FA, "RSASecurIDAuthenticationServer")
if checkey2FAValue == "" || checID2FAValue == "" || checkServer2FAValue == "" {
diags.AddError("Missing RSASecurID2FA required params", "Please provide all the required configuration for 2 factor autentication")
return false, diags
}
}
return true, diags
} */

func isValidAuthTime(prefix string, suffix string, attrsState *models.DirectoryServiceAuthProviderResource) (bool, diag.Diagnostics) {
var diags diag.Diagnostics
attributes := attrsState.ActiveDirectoryAttributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func parseActiveDirectoryIntoState(ctx context.Context, acctService *redfish.Acc

if state.ActiveDirectoryAttributes.IsNull() || state.ActiveDirectoryAttributes.IsUnknown() {
// nolint: gocyclo, gocognit,revive
activeDirectoryAttributes := []string{".CertValidationEnable", ".SSOEnable", ".AuthTimeout", ".DCLookupEnable", ".DCLookupByUserDomain", ".DCLookupDomainName", ".Schema", ".GCLookupEnable", ".GCRootDomain", ".GlobalCatalog1", ".GlobalCatalog2", ".GlobalCatalog3", ".RacName", ".RacDomain" /* , ".RSASecurID2FAAD" */}
activeDirectoryAttributes := []string{".CertValidationEnable", ".SSOEnable", ".AuthTimeout", ".DCLookupEnable", ".DCLookupByUserDomain", ".DCLookupDomainName", ".Schema", ".GCLookupEnable", ".GCRootDomain", ".GlobalCatalog1", ".GlobalCatalog2", ".GlobalCatalog3", ".RacName", ".RacDomain"}

attributesToReturn := make(map[string]attr.Value)
for k, v := range idracAttributesPlan.Attributes.Elements() {
Expand All @@ -390,10 +390,6 @@ func parseActiveDirectoryIntoState(ctx context.Context, acctService *redfish.Acc
if (strings.HasPrefix(k, "UserDomain.") && strings.HasSuffix(k, ".Name")) || (strings.HasPrefix(k, "ADGroup.") && strings.HasSuffix(k, ".Name")) {
attributesToReturn[k] = v
}

/* if strings.HasPrefix(k, "RSASecurID2FA.") && (strings.HasSuffix(k, ".RSASecurIDAuthenticationServer") || strings.HasSuffix(k, ".RSASecurIDAccessKey") || strings.HasSuffix(k, ".RSASecurIDClientID")) {
attributesToReturn[k] = v
}*/
}

activeDirAttributes = types.MapValueMust(types.StringType, attributesToReturn)
Expand Down Expand Up @@ -444,7 +440,7 @@ func parseLDAPIntoState(ctx context.Context, acctService *redfish.AccountService

if state.LDAPAttributes.IsNull() || state.LDAPAttributes.IsUnknown() {
// nolint: gocyclo, gocognit,revive
ldapAttributes := []string{".CertValidationEnable", ".GroupAttributeIsDN", ".Port", ".BindDN", ".BindPassword", ".SearchFilter" /* , ".RSASecurID2FALDAP" */}
ldapAttributes := []string{".CertValidationEnable", ".GroupAttributeIsDN", ".Port", ".BindDN", ".BindPassword", ".SearchFilter"}
attributesToReturn := make(map[string]attr.Value)
for k, v := range idracAttributesPlan.Attributes.Elements() {
if strings.HasPrefix(k, "LDAP.") {
Expand All @@ -454,11 +450,6 @@ func parseLDAPIntoState(ctx context.Context, acctService *redfish.AccountService
}
}
}

/* if strings.HasPrefix(k, "RSASecurID2FA.") && (strings.HasSuffix(k, ".RSASecurIDAuthenticationServer") ||
strings.HasSuffix(k, ".RSASecurIDAccessKey") || strings.HasSuffix(k, ".RSASecurIDClientID")) {
attributesToReturn[k] = v
}*/
}
ldapDirAttributes = types.MapValueMust(types.StringType, attributesToReturn)
}
Expand Down

0 comments on commit 03fb2d2

Please sign in to comment.