-
Notifications
You must be signed in to change notification settings - Fork 42
Revise and adjust audit logging #1443
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
Merged
+1,041
−236
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...e/src/main/java/org/cloudfoundry/multiapps/controller/core/auditlogging/AuditLogBean.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.impl.AuditLoggingFacadeSLImpl; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| import javax.inject.Inject; | ||
| import javax.sql.DataSource; | ||
|
|
||
| @Configuration | ||
| public class AuditLogBean { | ||
|
|
||
| @Bean | ||
| @Inject | ||
| public AuditLoggingFacade buildAuditLoggingFacade(DataSource dataSource, UserInfoProvider userInfoProvider) { | ||
| return new AuditLoggingFacadeSLImpl(dataSource, userInfoProvider); | ||
| } | ||
|
|
||
| @Bean | ||
| @Inject | ||
| public CsrfTokenApiServiceAuditLog buildCsrfTokenApiServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| return new CsrfTokenApiServiceAuditLog(auditLoggingFacade); | ||
| } | ||
|
|
||
| @Bean | ||
| @Inject | ||
| public FilesApiServiceAuditLog buildFilesApiServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| return new FilesApiServiceAuditLog(auditLoggingFacade); | ||
| } | ||
|
|
||
| @Bean | ||
| @Inject | ||
| public LoginAttemptAuditLog buildLoginAttemptAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| return new LoginAttemptAuditLog(auditLoggingFacade); | ||
| } | ||
|
|
||
| @Bean | ||
| @Inject | ||
| public InfoApiServiceAuditLog buildInfoApiServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| return new InfoApiServiceAuditLog(auditLoggingFacade); | ||
| } | ||
|
|
||
| @Bean | ||
| @Inject | ||
| public MtasApiServiceAuditLog buildMtasApiServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| return new MtasApiServiceAuditLog(auditLoggingFacade); | ||
| } | ||
|
|
||
| @Bean | ||
| @Inject | ||
| public OperationsApiServiceAuditLog buildOperationsApiServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| return new OperationsApiServiceAuditLog(auditLoggingFacade); | ||
| } | ||
|
|
||
| @Bean | ||
| @Inject | ||
| public MtaConfigurationPurgerAuditLog buildMtaConfigurationPurgerAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| return new MtaConfigurationPurgerAuditLog(auditLoggingFacade); | ||
| } | ||
| } | ||
26 changes: 5 additions & 21 deletions
26
...main/java/org/cloudfoundry/multiapps/controller/core/auditlogging/AuditLoggingFacade.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,11 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import org.cloudfoundry.multiapps.mta.model.AuditableConfiguration; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
|
|
||
| public interface AuditLoggingFacade { | ||
|
|
||
| void logSecurityIncident(String message); | ||
|
|
||
| void logAboutToStart(String action); | ||
|
|
||
| void logAboutToStart(String action, Map<String, Object> parameters); | ||
|
|
||
| void logActionStarted(String action, boolean success); | ||
|
|
||
| void logConfig(AuditableConfiguration configuration); | ||
|
|
||
| void logConfigCreate(AuditableConfiguration configuration); | ||
|
|
||
| void logConfigUpdate(AuditableConfiguration configuration); | ||
|
|
||
| void logConfigDelete(AuditableConfiguration configuration); | ||
|
|
||
| void logConfigUpdated(boolean success); | ||
|
|
||
| void logSecurityIncident(AuditLogConfiguration configuration); | ||
| void logDataAccessAuditLog(AuditLogConfiguration configuration); | ||
| void logConfigurationChangeAuditLog(AuditLogConfiguration configuration, ConfigurationChangeActions configurationAction); | ||
| } |
18 changes: 0 additions & 18 deletions
18
...in/java/org/cloudfoundry/multiapps/controller/core/auditlogging/AuditLoggingProvider.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
.../java/org/cloudfoundry/multiapps/controller/core/auditlogging/AuthenticationAuditLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import java.text.MessageFormat; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.Messages; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
|
|
||
|
|
||
| public class AuthenticationAuditLog { | ||
IvanBorislavovDimitrov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private final AuditLoggingFacade auditLoggingFacade; | ||
|
|
||
| public AuthenticationAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| this.auditLoggingFacade = auditLoggingFacade; | ||
| } | ||
|
|
||
| public void logFetchTokenAttempt(String clientId, String spaceId, String serviceName) { | ||
| String actionPerformed = MessageFormat.format(Messages.FETCH_TOKEN_AUDIT_LOG_MESSAGE, clientId, spaceId, serviceName); | ||
| auditLoggingFacade.logSecurityIncident(new AuditLogConfiguration(clientId, | ||
| spaceId, | ||
| actionPerformed, | ||
| Messages.FETCH_TOKEN_AUDIT_LOG_CONFIG)); | ||
| } | ||
|
|
||
| public void logFailedToFetchTokenAttempt(String clientId, String spaceId, String serviceName) { | ||
| String actionPerformed = MessageFormat.format(Messages.FAILED_TO_FETCH_TOKEN_AUDIT_LOG_MESSAGE, clientId, spaceId, serviceName); | ||
| auditLoggingFacade.logSecurityIncident(new AuditLogConfiguration(clientId, | ||
| spaceId, | ||
| actionPerformed, | ||
| Messages.FETCH_TOKEN_AUDIT_LOG_CONFIG)); | ||
| } | ||
| } | ||
21 changes: 21 additions & 0 deletions
21
.../org/cloudfoundry/multiapps/controller/core/auditlogging/CsrfTokenApiServiceAuditLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.Messages; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
|
|
||
| public class CsrfTokenApiServiceAuditLog { | ||
|
|
||
| private final AuditLoggingFacade auditLoggingFacade; | ||
|
|
||
| public CsrfTokenApiServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| this.auditLoggingFacade = auditLoggingFacade; | ||
| } | ||
|
|
||
| public void logGetInfo(String username) { | ||
Yavor16 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| String performedAction = Messages.RETRIEVE_CSRF_TOKEN_AUDIT_LOG_MESSAGE; | ||
| auditLoggingFacade.logDataAccessAuditLog(new AuditLogConfiguration(username, | ||
| "", | ||
| performedAction, | ||
| Messages.GET_CSRF_TOKEN_AUDIT_LOG_CONFIG)); | ||
| } | ||
| } | ||
104 changes: 104 additions & 0 deletions
104
...java/org/cloudfoundry/multiapps/controller/core/auditlogging/FilesApiServiceAuditLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import java.text.MessageFormat; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.api.model.FileMetadata; | ||
| import org.cloudfoundry.multiapps.controller.core.Messages; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions; | ||
|
|
||
| public class FilesApiServiceAuditLog { | ||
|
|
||
| private static final String NAMESPACE_PROPERTY_NAME = "namespace"; | ||
| private static final String FILE_URL_PROPERTY_NAME = "fileUrl"; | ||
| private static final String JOB_ID_PROPERTY_NAME = "jobId"; | ||
| private static final String DIGEST_ALGORITHM_PROPERTY_NAME = "digestAlgorithm"; | ||
| private static final String FILE_ID_PROPERTY_NAME = "fileId"; | ||
| private static final String SIZE_PROPERTY_NAME = "size"; | ||
| private static final String DIGEST_PROPERTY_NAME = "digest"; | ||
|
|
||
| private final AuditLoggingFacade auditLoggingFacade; | ||
|
|
||
| public FilesApiServiceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| this.auditLoggingFacade = auditLoggingFacade; | ||
| } | ||
|
|
||
| public void logGetFiles(String username, String spaceGuid, String namespace) { | ||
| String performedAction = MessageFormat.format(Messages.LIST_FILES_AUDIT_LOG_MESSAGE, spaceGuid); | ||
| auditLoggingFacade.logDataAccessAuditLog(new AuditLogConfiguration(username, | ||
| spaceGuid, | ||
| performedAction, | ||
| Messages.FILE_INFO_AUDIT_LOG_CONFIG, | ||
| createAuditLogGetFilesConfigurationIdentifier(namespace))); | ||
| } | ||
|
|
||
| public void logUploadFile(String username, String spaceGuid, FileMetadata fileMetadata) { | ||
| String performedAction = MessageFormat.format(Messages.UPLOAD_FILE_AUDIT_LOG_MESSAGE, spaceGuid); | ||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceGuid, | ||
| performedAction, | ||
| Messages.FILE_UPLOAD_AUDIT_LOG_CONFIG, | ||
| createFileMetadataConfigurationIdentifier(fileMetadata)), | ||
| ConfigurationChangeActions.CONFIGURATION_CREATE); | ||
| } | ||
|
|
||
| public void logStartUploadFromUrl(String username, String spaceGuid, String fileUrl) { | ||
| String performedAction = MessageFormat.format(Messages.UPLOAD_FILE_FROM_URL_AUDIT_LOG_MESSAGE, spaceGuid); | ||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceGuid, | ||
| performedAction, | ||
| Messages.FILE_UPLOAD_FROM_URL_AUDIT_LOG_CONFIG, | ||
| createAuditLogStartUploadFromUrlConfigurationIdentifier(fileUrl)), | ||
| ConfigurationChangeActions.CONFIGURATION_CREATE); | ||
| } | ||
|
|
||
| public void logGetUploadFromUrlJob(String username, String spaceGuid, String namespace, String jobId) { | ||
| String performedAction = MessageFormat.format(Messages.GET_INFO_FOR_UPLOAD_URL_JOB_AUDIT_LOG_MESSAGE, spaceGuid); | ||
| auditLoggingFacade.logDataAccessAuditLog(new AuditLogConfiguration(username, | ||
| spaceGuid, | ||
| performedAction, | ||
| Messages.UPLOAD_FROM_URL_JOB_INFO_AUDIT_LOG_CONFIG, | ||
| createAuditLogGetUploadFromUrlJobConfigurationIdentifier(namespace, | ||
| jobId))); | ||
| } | ||
|
|
||
| private Map<String, String> createFileMetadataConfigurationIdentifier(FileMetadata fileMetadata) { | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
|
|
||
| identifiers.put(FILE_ID_PROPERTY_NAME, fileMetadata.getId()); | ||
| identifiers.put(DIGEST_PROPERTY_NAME, fileMetadata.getDigest()); | ||
| identifiers.put(DIGEST_ALGORITHM_PROPERTY_NAME, fileMetadata.getDigestAlgorithm()); | ||
| identifiers.put(SIZE_PROPERTY_NAME, Objects.toString(fileMetadata.getSize())); | ||
| identifiers.put(NAMESPACE_PROPERTY_NAME, fileMetadata.getNamespace()); | ||
|
|
||
| return identifiers; | ||
| } | ||
|
|
||
| private Map<String, String> createAuditLogGetFilesConfigurationIdentifier(String namespace) { | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
|
|
||
| identifiers.put(NAMESPACE_PROPERTY_NAME, namespace); | ||
|
|
||
| return identifiers; | ||
| } | ||
|
|
||
| private Map<String, String> createAuditLogGetUploadFromUrlJobConfigurationIdentifier(String namespace, String jobId) { | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
|
|
||
| identifiers.put(NAMESPACE_PROPERTY_NAME, namespace); | ||
| identifiers.put(JOB_ID_PROPERTY_NAME, jobId); | ||
|
|
||
| return identifiers; | ||
| } | ||
|
|
||
| private Map<String, String> createAuditLogStartUploadFromUrlConfigurationIdentifier(String fileUrl) { | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
|
|
||
| identifiers.put(FILE_URL_PROPERTY_NAME, fileUrl); | ||
|
|
||
| return identifiers; | ||
| } | ||
IvanBorislavovDimitrov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
31 changes: 31 additions & 0 deletions
31
...org/cloudfoundry/multiapps/controller/core/auditlogging/FlowableSlmpResourceAuditLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.AuditLoggingFacade; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions; | ||
|
|
||
| public class FlowableSlmpResourceAuditLog { | ||
|
|
||
| private final AuditLoggingFacade auditLoggingFacade; | ||
|
|
||
| public FlowableSlmpResourceAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| this.auditLoggingFacade = auditLoggingFacade; | ||
| } | ||
|
|
||
| public void auditLogConfigurationChange(String username, String spaceId, String action, String configuration, | ||
| ConfigurationChangeActions configurationAction) { | ||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, spaceId, action, configuration), | ||
| configurationAction); | ||
| } | ||
|
|
||
| public void auditLogActionPerformed(String username, String spaceId, String action, String configuration) { | ||
| auditLoggingFacade.logDataAccessAuditLog(new AuditLogConfiguration(username, spaceId, action, configuration)); | ||
| } | ||
|
|
||
| public void auditLogActionPerformed(String username, String spaceId, String action, String configuration, | ||
| Map<String, String> parameters) { | ||
| auditLoggingFacade.logDataAccessAuditLog(new AuditLogConfiguration(username, spaceId, action, configuration, parameters)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.