Skip to content

Commit 283ea76

Browse files
committed
Add Decoder
1 parent 0bc4015 commit 283ea76

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/net/coderic/core/api/config/SecurityConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.springframework.security.config.http.SessionCreationPolicy;
1111
import org.springframework.security.oauth2.jwt.JwtDecoder;
1212
import org.springframework.security.oauth2.jwt.JwtDecoders;
13+
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
1314
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
1415
import org.springframework.security.web.SecurityFilterChain;
1516
import org.springframework.security.web.authentication.logout.HeaderWriterLogoutHandler;
@@ -20,6 +21,7 @@
2021
import org.springframework.web.cors.CorsConfigurationSource;
2122
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
2223

24+
import javax.crypto.spec.SecretKeySpec;
2325
import java.util.Arrays;
2426

2527
@Configuration
@@ -130,4 +132,11 @@ private JwtAuthenticationConverter jwtAuthenticationConverter() {
130132
// Configura cómo deseas mapear los claims del token JWT a roles/autorizaciones
131133
return converter;
132134
}
135+
@Bean
136+
public JwtDecoder jwtDecoder() {
137+
// Clave simétrica utilizada para descifrar el token (debe coincidir con la configurada en Auth0)
138+
String secretKey = System.getenv("OKTA_CLIENT_SECRET"); // Sustituye con la clave proporcionada por Auth0
139+
140+
return NimbusJwtDecoder.withSecretKey(new SecretKeySpec(secretKey.getBytes(), "AES")).build();
141+
}
133142
}

0 commit comments

Comments
 (0)