Skip to content

Commit cad8205

Browse files
committed
Doing work
1 parent 00a9ebf commit cad8205

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed

hello-service/src/main/java/example/service/hello/config/RSocketSecurityConfiguration.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
1010
import org.springframework.security.core.userdetails.User;
1111
import org.springframework.security.core.userdetails.UserDetails;
12+
import org.springframework.security.oauth2.jose.jws.MacAlgorithm;
13+
import org.springframework.security.oauth2.jwt.NimbusReactiveJwtDecoder;
14+
import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder;
1215
import org.springframework.security.rsocket.core.PayloadSocketAcceptorInterceptor;
1316

17+
import javax.crypto.Mac;
18+
import javax.crypto.spec.SecretKeySpec;
19+
1420
@Configuration
1521
@EnableRSocketSecurity
1622
public class RSocketSecurityConfiguration {
@@ -49,4 +55,14 @@ public PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsock
4955

5056
return rsocket.build();
5157
}
58+
59+
@Bean
60+
public ReactiveJwtDecoder reactiveJwtDecoder() throws Exception {
61+
Mac mac = Mac.getInstance(MacAlgorithm.HS256.getName());
62+
SecretKeySpec secretKey = new SecretKeySpec("demosecret".getBytes(), mac.getAlgorithm());
63+
64+
return NimbusReactiveJwtDecoder.withSecretKey(secretKey)
65+
.macAlgorithm(MacAlgorithm.HS256)
66+
.build();
67+
}
5268
}

hello-service/src/main/java/example/service/hello/core/JwtDecoder.java

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
# Properties
22
spring.rsocket.server.port=7000
3-
4-
# Security
5-
example.service.hello.jwt.secret=demosecret

0 commit comments

Comments
 (0)