|
49 | 49 | import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpointHandlerMapping;
|
50 | 50 | import org.springframework.security.web.FilterChainProxy;
|
51 | 51 | import org.springframework.security.web.SecurityFilterChain;
|
| 52 | +import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; |
52 | 53 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
53 | 54 | import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
|
54 | 55 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
@@ -133,16 +134,15 @@ OpenApiCustomiser springSecurityLoginEndpointCustomiser(ApplicationContext appli
|
133 | 134 | operation.responses(apiResponses);
|
134 | 135 | operation.addTagsItem("login-endpoint");
|
135 | 136 | PathItem pathItem = new PathItem().post(operation);
|
136 |
| - String loginPath = "/login"; |
137 | 137 | try {
|
138 |
| - Field requestMatcherField = usernamePasswordAuthenticationFilter.getClass().getSuperclass().getDeclaredField("requiresAuthenticationRequestMatcher"); |
| 138 | + Field requestMatcherField = AbstractAuthenticationProcessingFilter.class.getDeclaredField("requiresAuthenticationRequestMatcher"); |
139 | 139 | requestMatcherField.setAccessible(true);
|
140 | 140 | AntPathRequestMatcher requestMatcher = (AntPathRequestMatcher) requestMatcherField.get(usernamePasswordAuthenticationFilter);
|
141 |
| - loginPath = requestMatcher.getPattern(); |
| 141 | + String loginPath = requestMatcher.getPattern(); |
142 | 142 | requestMatcherField.setAccessible(false);
|
143 |
| - } catch (NoSuchFieldException | IllegalAccessException ignored) { |
| 143 | + openAPI.getPaths().addPathItem(loginPath, pathItem); |
| 144 | + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignored) { |
144 | 145 | }
|
145 |
| - openAPI.getPaths().addPathItem(loginPath, pathItem); |
146 | 146 | }
|
147 | 147 | }
|
148 | 148 | };
|
|
0 commit comments