File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
config/src/main/java/org/springframework/security/config/annotation/rsocket Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 109109 * @author Manuel Tejeda
110110 * @author Ebert Toribio
111111 * @author Ngoc Nhan
112+ * @author Andrey Litvitski
112113 * @since 5.2
113114 */
114115public class RSocketSecurity {
@@ -119,6 +120,8 @@ public class RSocketSecurity {
119120
120121 private SimpleAuthenticationSpec simpleAuthSpec ;
121122
123+ private boolean disableAnonymous ;
124+
122125 private JwtSpec jwtSpec ;
123126
124127 private AuthorizePayloadsSpec authorizePayload ;
@@ -179,6 +182,15 @@ public RSocketSecurity basicAuthentication(Customizer<BasicAuthenticationSpec> b
179182 return this ;
180183 }
181184
185+ /**
186+ * Disables anonymous authentication.
187+ * @return the builder for additional customizations
188+ */
189+ public RSocketSecurity disableAnonymous () {
190+ this .disableAnonymous = true ;
191+ return this ;
192+ }
193+
182194 public RSocketSecurity jwt (Customizer <JwtSpec > jwt ) {
183195 if (this .jwtSpec == null ) {
184196 this .jwtSpec = new JwtSpec ();
@@ -214,7 +226,9 @@ private List<PayloadInterceptor> payloadInterceptors() {
214226 if (this .jwtSpec != null ) {
215227 result .addAll (this .jwtSpec .build ());
216228 }
217- result .add (anonymous ());
229+ if (!this .disableAnonymous ) {
230+ result .add (anonymous ());
231+ }
218232 if (this .authorizePayload != null ) {
219233 result .add (this .authorizePayload .build ());
220234 }
You can’t perform that action at this time.
0 commit comments