|
| 1 | +/** |
| 2 | + * ContainerProxy |
| 3 | + * |
| 4 | + * Copyright (C) 2016-2020 Open Analytics |
| 5 | + * |
| 6 | + * =========================================================================== |
| 7 | + * |
| 8 | + * This program is free software: you can redistribute it and/or modify |
| 9 | + * it under the terms of the Apache License as published by |
| 10 | + * The Apache Software Foundation, either version 2 of the License, or |
| 11 | + * (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * Apache License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the Apache License |
| 19 | + * along with this program. If not, see <http://www.apache.org/licenses/> |
| 20 | + */ |
| 21 | +package eu.openanalytics.containerproxy.security; |
| 22 | + |
| 23 | +import javax.servlet.http.HttpServletRequest; |
| 24 | + |
| 25 | +import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; |
| 26 | +import org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizationRequestResolver; |
| 27 | +import org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver; |
| 28 | +import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest; |
| 29 | + |
| 30 | +public class FixedDefaultOAuth2AuthorizationRequestResolver implements OAuth2AuthorizationRequestResolver { |
| 31 | + |
| 32 | + private DefaultOAuth2AuthorizationRequestResolver delegate; |
| 33 | + |
| 34 | + public FixedDefaultOAuth2AuthorizationRequestResolver(ClientRegistrationRepository clientRegistrationRepository, String authorizationRequestBaseUri) { |
| 35 | + delegate = new DefaultOAuth2AuthorizationRequestResolver(clientRegistrationRepository, authorizationRequestBaseUri); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public OAuth2AuthorizationRequest resolve(HttpServletRequest request) { |
| 40 | + if (request.getServletPath().startsWith("/app_direct")) { |
| 41 | + return null; |
| 42 | + } |
| 43 | + return delegate.resolve(request); |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public OAuth2AuthorizationRequest resolve(HttpServletRequest request, String clientRegistrationId) { |
| 48 | + if (request.getServletPath().startsWith("/app_direct")) { |
| 49 | + return null; |
| 50 | + } |
| 51 | + return delegate.resolve(request, clientRegistrationId); |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments