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
@Path("/resource") | |
public class ResourceREST { | |
@RolesAllowed("USER") | |
@GET @Path("/user") @Produces(MediaType.APPLICATION_JSON) | |
public Response user() { | |
return Response.ok(new Message("Content for user")).build(); | |
} | |
@RolesAllowed("ADMIN") |
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
@Path("/user") | |
public class AuthenticationREST { | |
@Inject | |
PBKDF2Encoder passwordEncoder; | |
@ConfigProperty(name = "com.ard333.quarkusjwt.jwt.duration") public Long duration; | |
@ConfigProperty(name = "mp.jwt.verify.issuer") public String issuer; | |
@PermitAll |
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
@RequestScoped | |
public class PBKDF2Encoder { | |
@ConfigProperty(name = "com.ard333.quarkusjwt.password.secret") private String secret; | |
@ConfigProperty(name = "com.ard333.quarkusjwt.password.iteration") private Integer iteration; | |
@ConfigProperty(name = "com.ard333.quarkusjwt.password.keylength") private Integer keylength; | |
/** | |
* More info (https://www.owasp.org/index.php/Hashing_Java) 404 :( | |
* @param cs password |
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
//for login endpoint | |
@NoArgsConstructor @AllArgsConstructor @ToString | |
public class AuthRequest { | |
public String username; | |
public String password; | |
} | |
//for login endpoint | |
@NoArgsConstructor @AllArgsConstructor @ToString |
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
@NoArgsConstructor @AllArgsConstructor @ToString @EqualsAndHashCode(callSuper = false) | |
public class User { | |
public String username; | |
public String password; | |
public Set<Role> roles; | |
// this is just an example, you can load the user from the database (via PanacheEntityBase) | |
public static User findByUsername(String username) { |
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
public class TokenUtils { | |
public static String generateToken(String username, Set<Role> roles, Long duration, String issuer) throws Exception { | |
String privateKeyLocation = "/privatekey.pem"; | |
PrivateKey privateKey = readPrivateKey(privateKeyLocation); | |
JwtClaimsBuilder claimsBuilder = Jwt.claims(); | |
long currentTimeInSecs = currentTimeInSecs(); | |
Set<String> groups = new HashSet<>(); |
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
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: spring-kubernetes-example | |
spec: | |
selector: | |
app: spring-kubernetes-example | |
type: NodePort | |
ports: | |
- name: spring-kubernetes-example-port |
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
apiVersion: v1 | |
kind: Secret | |
type: Opaque | |
data: | |
#my-password | |
password: bXktcGFzc3dvcmQ= | |
#ard333 | |
username: YXJkMzMz | |
metadata: | |
name: spring-kubernetes-example |
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
apiVersion: apps/v1 | |
kind: ReplicaSet | |
metadata: | |
name: spring-kubernetes-example | |
labels: | |
app: spring-kubernetes-example | |
tier: backend | |
spec: | |
replicas: 2 | |
selector: |
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
@RestController | |
public class TestHTTPService { | |
@Autowired | |
private Config config; | |
@Value("${myconfig.properties1}") | |
private String properties1; | |
@GetMapping("config-autoreload") |
NewerOlder