Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit 173eee6

Browse files
author
Mario
committed
1247 - First approach to oauth/revoke
1 parent 8deee6c commit 173eee6

File tree

14 files changed

+743
-3
lines changed

14 files changed

+743
-3
lines changed

extensions/servlet/src/main/java/com/stormpath/sdk/servlet/config/Config.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ public interface Config extends Map<String, String> {
109109

110110
String getAccessTokenUrl();
111111

112+
String getRevokeTokenUrl();
113+
112114
String getUnauthorizedUrl();
113115

114116
boolean isMeEnabled();

extensions/servlet/src/main/java/com/stormpath/sdk/servlet/config/filter/DefaultFilterChainManagerConfigurer.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ public FilterChainManager configure() throws ServletException {
107107
boolean accessTokenChainSpecified = false;
108108
boolean oauthEnabled = config.isOAuthEnabled();
109109

110+
String revokeTokenUrl = config.getRevokeTokenUrl();
111+
String revokeTokenUrlPattern = cleanUri(revokeTokenUrl);
112+
boolean revokeTokenChainSpecified = false;
113+
110114
String unauthorizedUrl = config.getUnauthorizedUrl();
111115
String unauthorizedUrlPattern = cleanUri(unauthorizedUrl);
112116
boolean unauthorizedChainSpecified = false;
@@ -240,6 +244,14 @@ public FilterChainManager configure() throws ServletException {
240244
chainDefinition += Strings.DEFAULT_DELIMITER_CHAR + filterName;
241245
}
242246

247+
} else if (uriPattern.startsWith(revokeTokenUrlPattern)) {
248+
revokeTokenChainSpecified = true;
249+
250+
String filterName = DefaultFilter.revokeToken.name();
251+
if (!chainDefinition.contains(filterName)) {
252+
chainDefinition += Strings.DEFAULT_DELIMITER_CHAR + filterName;
253+
}
254+
243255
} else if (uriPattern.startsWith(unauthorizedUrlPattern)) {
244256
unauthorizedChainSpecified = true;
245257

@@ -321,6 +333,9 @@ public FilterChainManager configure() throws ServletException {
321333
if (!accessTokenChainSpecified && oauthEnabled) {
322334
mgr.createChain(accessTokenUrlPattern, DefaultFilter.accessToken.name());
323335
}
336+
if (!revokeTokenChainSpecified && oauthEnabled) {
337+
mgr.createChain(revokeTokenUrlPattern, DefaultFilter.revokeToken.name());
338+
}
324339
if (!samlChainSpecified && callbackEnabled) {
325340
mgr.createChain(samlUrlPattern, DefaultFilter.saml.name());
326341
mgr.createChain(samlCallbackPattern, DefaultFilter.samlResult.name());
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2017 Stormpath, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.stormpath.sdk.servlet.config.filter;
17+
18+
import com.stormpath.sdk.servlet.config.Config;
19+
import com.stormpath.sdk.servlet.mvc.RevokeTokenController;
20+
21+
/**
22+
* https://github.com/stormpath/stormpath-sdk-java/issues/1247
23+
*
24+
* @since 1.5.0
25+
*/
26+
public class RevokeTokenFilterFactory extends ControllerFilterFactory<RevokeTokenController> {
27+
28+
@Override
29+
protected RevokeTokenController newController() {
30+
return new RevokeTokenController();
31+
}
32+
33+
@Override
34+
protected void configure(RevokeTokenController controller, Config config) throws Exception {
35+
controller.setApplicationResolver(config.getApplicationResolver());
36+
}
37+
}

extensions/servlet/src/main/java/com/stormpath/sdk/servlet/config/impl/DefaultConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public class DefaultConfig implements Config {
8080
public static final String UNAUTHORIZED_URL = "stormpath.web.unauthorized.uri";
8181
public static final String LOGOUT_INVALIDATE_HTTP_SESSION = "stormpath.web.logout.invalidateHttpSession";
8282
public static final String ACCESS_TOKEN_URL = "stormpath.web.oauth2.uri";
83+
public static final String REVOKE_TOKEN_URL = "stormpath.web.oauth2.revoke.uri";
8384
public static final String ACCESS_TOKEN_VALIDATION_STRATEGY = "stormpath.web.oauth2.password.validationStrategy";
8485

8586
protected static final String SERVER_URI_RESOLVER = "stormpath.web.oauth2.origin.authorizer.serverUriResolver";
@@ -274,6 +275,11 @@ public String getAccessTokenUrl() {
274275
return CFG.getString(ACCESS_TOKEN_URL);
275276
}
276277

278+
@Override
279+
public String getRevokeTokenUrl() {
280+
return CFG.getString(REVOKE_TOKEN_URL);
281+
}
282+
277283
@Override
278284
public String getUnauthorizedUrl() {
279285
return CFG.getString(UNAUTHORIZED_URL);

extensions/servlet/src/main/java/com/stormpath/sdk/servlet/filter/DefaultFilter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.stormpath.sdk.servlet.config.filter.LogoutFilterFactory;
3535
import com.stormpath.sdk.servlet.config.filter.MeFilterFactory;
3636
import com.stormpath.sdk.servlet.config.filter.RegisterFilterFactory;
37+
import com.stormpath.sdk.servlet.config.filter.RevokeTokenFilterFactory;
3738
import com.stormpath.sdk.servlet.config.filter.SamlFilterFactory;
3839
import com.stormpath.sdk.servlet.config.filter.SamlResultFilterFactory;
3940
import com.stormpath.sdk.servlet.config.filter.StaticResourceFilterFactory;
@@ -51,6 +52,7 @@
5152
public enum DefaultFilter {
5253

5354
accessToken(ControllerFilter.class, AccessTokenFilterFactory.class),
55+
revokeToken(ControllerFilter.class, RevokeTokenFilterFactory.class),
5456
account(AccountAuthorizationFilter.class, AccountAuthorizationFilterFactory.class),
5557
anon(AnonymousFilter.class, null),
5658
authc(AuthenticationFilter.class, AuthenticationFilterFactory.class),

0 commit comments

Comments
 (0)