1
1
package net .coderic .core .api .config ;
2
2
3
+ import com .nimbusds .jose .JOSEException ;
4
+ import com .nimbusds .jose .jwk .JWK ;
5
+ import com .nimbusds .jose .jwk .JWKSet ;
6
+ import com .nimbusds .jose .jwk .RSAKey ;
3
7
import org .springframework .beans .factory .annotation .Value ;
4
8
import org .springframework .context .annotation .Bean ;
5
9
import org .springframework .context .annotation .Configuration ;
22
26
import org .springframework .web .cors .UrlBasedCorsConfigurationSource ;
23
27
24
28
import javax .crypto .spec .SecretKeySpec ;
29
+ import java .io .IOException ;
30
+ import java .net .URL ;
31
+ import java .security .PublicKey ;
32
+ import java .security .interfaces .RSAPublicKey ;
33
+ import java .text .ParseException ;
25
34
import java .util .Arrays ;
26
35
27
36
@ Configuration
@@ -133,9 +142,20 @@ private JwtAuthenticationConverter jwtAuthenticationConverter() {
133
142
return converter ;
134
143
}
135
144
@ Bean
145
+ public JwtDecoder jwtDecoder () throws IOException , JOSEException , ParseException {
146
+ // URL del JWKS de Auth0
147
+ String jwkSetUri = "https://auth.coderic.org/.well-known/jwks.json" ;
148
+ JWKSet jwkSet = JWKSet .load (new URL (jwkSetUri ));
149
+ JWK jwk = jwkSet .getKeys ().get (0 );
150
+ RSAKey rsaKey = (RSAKey ) jwk ;
151
+ RSAPublicKey publicKey = rsaKey .toRSAPublicKey ();
152
+ return NimbusJwtDecoder .withPublicKey (publicKey ).build ();
153
+ }
154
+ /*
155
+ @Bean
136
156
public JwtDecoder jwtDecoder() {
137
157
// URI del JWKS de Auth0
138
158
String jwkSetUri = "https://auth.coderic.org/.well-known/jwks.json";
139
159
return NimbusJwtDecoder.withJwkSetUri(jwkSetUri).build();
140
- }
160
+ }*/
141
161
}
0 commit comments