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 109
109
* @author Manuel Tejeda
110
110
* @author Ebert Toribio
111
111
* @author Ngoc Nhan
112
+ * @author Andrey Litvitski
112
113
* @since 5.2
113
114
*/
114
115
public class RSocketSecurity {
@@ -119,6 +120,8 @@ public class RSocketSecurity {
119
120
120
121
private SimpleAuthenticationSpec simpleAuthSpec ;
121
122
123
+ private boolean disableAnonymous ;
124
+
122
125
private JwtSpec jwtSpec ;
123
126
124
127
private AuthorizePayloadsSpec authorizePayload ;
@@ -179,6 +182,15 @@ public RSocketSecurity basicAuthentication(Customizer<BasicAuthenticationSpec> b
179
182
return this ;
180
183
}
181
184
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
+
182
194
public RSocketSecurity jwt (Customizer <JwtSpec > jwt ) {
183
195
if (this .jwtSpec == null ) {
184
196
this .jwtSpec = new JwtSpec ();
@@ -214,7 +226,9 @@ private List<PayloadInterceptor> payloadInterceptors() {
214
226
if (this .jwtSpec != null ) {
215
227
result .addAll (this .jwtSpec .build ());
216
228
}
217
- result .add (anonymous ());
229
+ if (!this .disableAnonymous ) {
230
+ result .add (anonymous ());
231
+ }
218
232
if (this .authorizePayload != null ) {
219
233
result .add (this .authorizePayload .build ());
220
234
}
You can’t perform that action at this time.
0 commit comments