Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epmrpp 87165 logger #323

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies {
api 'com.epam.reportportal:commons-dao'
api 'com.epam.reportportal:commons'
} else {
api 'com.github.reportportal:commons-dao:b0e00d6'
api 'com.github.reportportal:commons-dao:0abcc21'
api 'com.github.reportportal:commons:50a1192'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,30 @@

import static java.util.Collections.singletonList;

import com.epam.reportportal.auth.AdminPasswordInitializer;
import com.epam.reportportal.auth.EnableableAuthProvider;
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.parameter.CustomPasswordEncoderFactory;
import com.epam.reportportal.auth.integration.parameter.LdapParameter;
import com.epam.ta.reportportal.commons.accessible.Accessible;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.reportportal.rules.exception.ReportPortalException;
import java.util.Map;
import org.jasypt.util.text.BasicTextEncryptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configurers.ldap.LdapAuthenticationProviderConfigurer;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder.SecretKeyFactoryAlgorithm;
import org.springframework.security.ldap.DefaultSpringSecurityContextSource;
import org.springframework.security.ldap.authentication.NullLdapAuthoritiesPopulator;

Expand All @@ -44,6 +52,8 @@
*/
public class LdapAuthProvider extends EnableableAuthProvider {

private static final Logger LOGGER = LoggerFactory.getLogger(LdapAuthProvider.class);

private final DetailsContextMapper detailsContextMapper;

@Autowired
Expand Down Expand Up @@ -107,16 +117,23 @@ protected AuthenticationProvider getDelegate() {
* This is why we just wrap old encoder with new one interface
* New encoder cannot be used everywhere since it does not have implementation for LDAP
*/
final PasswordEncoder delegate = PasswordEncoderFactories.createDelegatingPasswordEncoder();
LOGGER.error("PASSWORD_ENCODER_TYPE: " + it);
final PasswordEncoder delegate = CustomPasswordEncoderFactory.createDelegatingPasswordEncoder().get(it.toLowerCase());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 124).


builder.passwordEncoder(new org.springframework.security.crypto.password.PasswordEncoder() {

@Override
public String encode(CharSequence rawPassword) {
return delegate.encode(rawPassword);
LOGGER.error("rawPassword1: " + rawPassword);
String encode = delegate.encode(rawPassword);
LOGGER.error("encodedPassword1: " + encode);
return encode;
}

@Override
public boolean matches(CharSequence rawPassword, String encodedPassword) {
LOGGER.error("rawPassword: " + rawPassword);
LOGGER.error("encodedPassword: " + encodedPassword);
return delegate.matches(rawPassword, encodedPassword);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.epam.reportportal.auth.integration.parameter;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck> reported by reviewdog 🐶
'package' should be separated from previous line.


import java.util.HashMap;
import java.util.Map;
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder.SecretKeyFactoryAlgorithm;
import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder;

/**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck> reported by reviewdog 🐶
Summary javadoc is missing.

* @author <a href="mailto:[email protected]">Andrei Piankouski</a>
*/
public class CustomPasswordEncoderFactory {

public static Map<String, PasswordEncoder> createDelegatingPasswordEncoder() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck> reported by reviewdog 🐶
Missing a Javadoc comment.

Map<String, PasswordEncoder> encoders = new HashMap<>();
encoders.put("bcrypt", new BCryptPasswordEncoder());
encoders.put("ldap", new org.springframework.security.crypto.password.LdapShaPasswordEncoder());

Check failure

Code scanning / SonarCloud

Passwords should not be stored in plaintext or with a fast hashing algorithm High

Use secure "PasswordEncoder" implementation. See more on SonarCloud
encoders.put("md4", new org.springframework.security.crypto.password.Md4PasswordEncoder());

Check failure

Code scanning / SonarCloud

Passwords should not be stored in plaintext or with a fast hashing algorithm High

Use secure "PasswordEncoder" implementation. See more on SonarCloud
encoders.put("md5", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("MD5"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 110).

Check failure

Code scanning / SonarCloud

Passwords should not be stored in plaintext or with a fast hashing algorithm High

Use secure "PasswordEncoder" implementation. See more on SonarCloud
encoders.put("noop", org.springframework.security.crypto.password.NoOpPasswordEncoder.getInstance());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 105).

Check failure

Code scanning / SonarCloud

Passwords should not be stored in plaintext or with a fast hashing algorithm High

Use secure "PasswordEncoder" implementation. See more on SonarCloud
encoders.put("pbkdf2", new Pbkdf2PasswordEncoder());
Pbkdf2PasswordEncoder PBKDF2_SHA256 = new Pbkdf2PasswordEncoder();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck> reported by reviewdog 🐶
Abbreviation in name 'PBKDF2_SHA256' must contain no more than '1' consecutive capital letters.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck> reported by reviewdog 🐶
Local variable name 'PBKDF2_SHA256' must match pattern '^a-z?$'.

PBKDF2_SHA256.setAlgorithm(SecretKeyFactoryAlgorithm.PBKDF2WithHmacSHA256);
encoders.put("pbkdf2_sha256", PBKDF2_SHA256);
Pbkdf2PasswordEncoder PBKDF2_SHA512 = new Pbkdf2PasswordEncoder();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck> reported by reviewdog 🐶
Abbreviation in name 'PBKDF2_SHA512' must contain no more than '1' consecutive capital letters.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck> reported by reviewdog 🐶
Local variable name 'PBKDF2_SHA512' must match pattern '^a-z?$'.

PBKDF2_SHA512.setAlgorithm(SecretKeyFactoryAlgorithm.PBKDF2WithHmacSHA512);
encoders.put("pbkdf2_sha512", new Pbkdf2PasswordEncoder());
encoders.put("scrypt", new SCryptPasswordEncoder());

Check failure

Code scanning / SonarCloud

Passwords should not be stored in plaintext or with a fast hashing algorithm High

Use secure "PasswordEncoder" implementation. See more on SonarCloud
encoders.put("sha-1", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-1"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 114).

Check failure

Code scanning / SonarCloud

Passwords should not be stored in plaintext or with a fast hashing algorithm High

Use secure "PasswordEncoder" implementation. See more on SonarCloud
encoders.put("sha-256",
new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-256"));

Check failure

Code scanning / SonarCloud

Passwords should not be stored in plaintext or with a fast hashing algorithm High

Use secure "PasswordEncoder" implementation. See more on SonarCloud
encoders.put("sha256", new org.springframework.security.crypto.password.StandardPasswordEncoder());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 103).

Check failure

Code scanning / SonarCloud

Passwords should not be stored in plaintext or with a fast hashing algorithm High

Use secure "PasswordEncoder" implementation. See more on SonarCloud
encoders.put("argon2", new Argon2PasswordEncoder());
return encoders;
}

}
Loading