This file contains 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
# | |
# Only tested on Kibana 7.1.1 management | |
# | |
import argparse | |
import json | |
import uuid | |
from elasticsearch import Elasticsearch |
This file contains 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
public class Transform | |
{ | |
private ulong instanceId = ulong.MaxValue; | |
public Transform(ulong InstanceId) | |
{ | |
this.instanceId = InstanceId; | |
} | |
public Transform() | |
{ |
This file contains 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
@ExtendWith(SpringExtension.class) | |
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | |
@ActiveProfiles("prod") | |
public class AuthTest { | |
@MockBean | |
private IUserService userService; | |
@MockBean |
This file contains 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
@RestController | |
@RequestMapping("/user") | |
public class UserController { | |
private IUserService userService; | |
@Autowired | |
public UserController(IUserService userService) { | |
this.userService = userService; | |
} |
This file contains 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
@Target(ElementType.METHOD) | |
@Retention(RetentionPolicy.RUNTIME) | |
@PreAuthorize("hasAuthority('" + SecurityResource.Role.ADMIN + "')") | |
public @interface AccessAdmin { | |
} | |
@Target(ElementType.METHOD) | |
@Retention(RetentionPolicy.RUNTIME) | |
@PreAuthorize("hasAnyAuthority('" + SecurityResource.Role.ADMIN + "','" + SecurityResource.Role.USER + "')") |
This file contains 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
public class TokenAuthenticationFilter extends OncePerRequestFilter { | |
private ITokenService tokenService; | |
public TokenAuthenticationFilter(ITokenService tokenService) { | |
Assert.notNull(tokenService, "Can not be null"); | |
this.tokenService = tokenService; | |
} |
This file contains 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
@Data | |
@NoArgsConstructor | |
@Document(collection = "user") | |
public class User extends BaseEntity { | |
@Field("email") | |
@Indexed(unique = true) | |
private String email; | |
@Field("token") |
This file contains 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
package com.codecamos.timetracking.config; | |
import javax.servlet.http.HttpServletResponse; | |
import com.fasterxml.jackson.annotation.JsonInclude; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.core.env.Environment; |
This file contains 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
package com.codecamos.timetracking.config; | |
@ControllerAdvice | |
public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { | |
private Environment env; | |
private static final Logger logger = LogManager.getLogger(RestResponseEntityExceptionHandler.class); | |
public static final HttpStatus DEFAULT_STATUS_CODE = HttpStatus.BAD_REQUEST; |
This file contains 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
package com.codecamos.timetracking.config; | |
public final class Resource { | |
private Resource() { } | |
/** | |
* @param activeProfiles The current active profiles this application was started with, {@link Profile} for available profiles | |
* @return returns true if we are in dev or stage | |
*/ |
NewerOlder