diff --git a/src/main/java/com/alura/aluraflixapi/infraestructure/security/TokenService.java b/src/main/java/com/alura/aluraflixapi/infraestructure/security/TokenService.java index 8bdc2cd..b43cd43 100644 --- a/src/main/java/com/alura/aluraflixapi/infraestructure/security/TokenService.java +++ b/src/main/java/com/alura/aluraflixapi/infraestructure/security/TokenService.java @@ -19,7 +19,8 @@ @Service public class TokenService { - private static final String ALURA_FLIX_API = "alura-flix-api"; + @Value("${api.security.api-issuer}") + private String apiIssuer; @Value("${api.security.token-jwt-secret}") public String secret; @@ -28,7 +29,7 @@ public String generateTokenJWT(User user) { try { log.info("Generating Token JWT ..."); return JWT.create() - .withIssuer(ALURA_FLIX_API) + .withIssuer(apiIssuer) //owner .withSubject(user.getUsername()) .withClaim("id", user.getUsername()) @@ -50,7 +51,7 @@ public String getSubject(String tokenJWT) { try { var algorithm = Algorithm.HMAC256(secret); return JWT.require(algorithm) - .withIssuer(ALURA_FLIX_API) + .withIssuer(apiIssuer) .build() .verify(tokenJWT) .getSubject(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d876532..a897986 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -15,6 +15,7 @@ spring: api: security: + api-issuer: alura-flix-api # always commit the uri like this: ${JWT_SECRET} token-jwt-secret: ${JWT_SECRET} diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml index 6a6c4a6..517acf5 100644 --- a/src/test/resources/application-test.yml +++ b/src/test/resources/application-test.yml @@ -8,4 +8,4 @@ spring: mongodb: database: alura-flix-test # always commit the uri like this: ${DATABASE_TEST} - uri: ${DATABASE_TEST} \ No newline at end of file + uri: ${DATABASE_TEST:mongodb+srv://laurosilveira:283TlfZiOW4nNOnN@alura-flix-test.qixe2kd.mongodb.net/?retryWrites=true&w=majority&appName=alura-flix-test} \ No newline at end of file