Skip to content

Commit

Permalink
WIP on timestamps
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Dec 7, 2023
1 parent c0001c4 commit 2be45c5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,9 @@ protected final ValidationResult<SecurityConfiguration> addEntityToConfig(final
if (configuration.exists(securityConfiguration.entityName())) {
CEntry existingEntry = (CEntry) configuration.getCEntry(securityConfiguration.entityName());
System.out.println("Existing CEntry: " + existingEntry);
System.out.println("centry.getCreatedAt(): " + existingEntry.getCreatedAt());
System.out.println("Setting updatedAt only");
if (centry.getCreatedAt() == null) {
if (existingEntry.getCreatedAt() == null) {
centry.setCreatedAt(Instant.now().getEpochSecond());
} else {
centry.setCreatedAt(existingEntry.getCreatedAt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,16 @@ private void internalUsersApiRequestHandlers(RequestHandler.RequestHandlersBuild
.error((status, toXContent) -> response(channel, status, toXContent))
)
.onChangeRequest(Method.PATCH, this::processPatchRequest)
.onChangeRequest(
Method.PUT,
request -> {
System.out.println("InternalUsers PUT Request");
return endpointValidator.withRequiredEntityName(nameParam(request))
.map(username -> loadConfigurationWithRequestContent(username, request))
.map(endpointValidator::isAllowedToChangeImmutableEntity)
.map(this::validateSecurityRoles)
.map(securityConfiguration -> createOrUpdateAccount(request, securityConfiguration))
.map(this::validateAndUpdatePassword)
.map(this::addEntityToConfig);
});
.onChangeRequest(Method.PUT, request -> {
System.out.println("InternalUsers PUT Request");
return endpointValidator.withRequiredEntityName(nameParam(request))
.map(username -> loadConfigurationWithRequestContent(username, request))
.map(endpointValidator::isAllowedToChangeImmutableEntity)
.map(this::validateSecurityRoles)
.map(securityConfiguration -> createOrUpdateAccount(request, securityConfiguration))
.map(this::validateAndUpdatePassword)
.map(this::addEntityToConfig);
});
}

ValidationResult<String> withAuthTokenPath(final RestRequest request) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
package org.opensearch.security.dlic.rest.api;

import com.fasterxml.jackson.databind.JsonNode;
import org.opensearch.security.securityconf.impl.CEntry;
import org.opensearch.security.securityconf.impl.SecurityDynamicConfiguration;

import javax.swing.*;
import java.time.Instant;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@

import org.opensearch.security.securityconf.Hideable;
import org.opensearch.security.securityconf.StaticDefinable;
import org.opensearch.security.securityconf.impl.CEntry;
import org.opensearch.security.securityconf.impl.v6.RoleV6;

public class RoleV7 implements Hideable, StaticDefinable {
public class RoleV7 extends CEntry implements Hideable, StaticDefinable {

private boolean reserved;
private boolean hidden;
Expand Down Expand Up @@ -299,6 +300,10 @@ public String toString() {
+ index_permissions
+ ", tenant_permissions="
+ tenant_permissions
+ ", created_at="
+ createdAt
+ ", updated_at="
+ updatedAt
+ "]";
}

Expand Down

0 comments on commit 2be45c5

Please sign in to comment.