diff --git a/maxkey-core/src/main/java/org/maxkey/entity/apps/AppsOAuth20Details.java b/maxkey-core/src/main/java/org/maxkey/entity/apps/AppsOAuth20Details.java index ac161f64..d1073639 100644 --- a/maxkey-core/src/main/java/org/maxkey/entity/apps/AppsOAuth20Details.java +++ b/maxkey-core/src/main/java/org/maxkey/entity/apps/AppsOAuth20Details.java @@ -81,6 +81,7 @@ public class AppsOAuth20Details extends Apps { this.id = application.getId(); this.setName(application.getName()); this.setLoginUrl(application.getLoginUrl()); + this.setLogoutUrl(application.getLogoutUrl()); this.setCategory(application.getCategory()); this.setProtocol(application.getProtocol()); this.setIcon(application.getIcon()); diff --git a/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/client/JdbcClientDetailsService.java b/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/client/JdbcClientDetailsService.java index 6cdee807..ab865323 100644 --- a/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/client/JdbcClientDetailsService.java +++ b/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/client/JdbcClientDetailsService.java @@ -152,6 +152,7 @@ public class JdbcClientDetailsService implements ClientDetailsService, ClientReg if (count != 1) { throw new NoSuchClientException("No client found with id = " + clientDetails.getClientId()); } + clientDetailsCache.invalidate(clientDetails.getClientId()); } public void updateClientSecret(String clientId, String secret) throws NoSuchClientException { diff --git a/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/TokenEndpointAuthenticationFilter.java b/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/TokenEndpointAuthenticationFilter.java index c844f699..25b0ee26 100644 --- a/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/TokenEndpointAuthenticationFilter.java +++ b/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/TokenEndpointAuthenticationFilter.java @@ -155,14 +155,17 @@ public class TokenEndpointAuthenticationFilter implements Filter { try { String grantType = request.getParameter(OAuth2Constants.PARAMETER.GRANT_TYPE); if (grantType != null && grantType.equals(OAuth2Constants.PARAMETER.GRANT_TYPE_PASSWORD)) { + //password usernamepassword(request,response); }else { Authentication authentication=ClientCredentials(request,response); logger.trace("getPrincipal " + authentication.getPrincipal().getClass()); SigninPrincipal auth = null; if(authentication.getPrincipal() instanceof SigninPrincipal) { + //authorization_code auth = (SigninPrincipal)authentication.getPrincipal(); }else { + //client_credentials auth =new SigninPrincipal((User)authentication.getPrincipal()); } auth.setAuthenticated(true); @@ -242,7 +245,7 @@ public class TokenEndpointAuthenticationFilter implements Filter { public Authentication ClientCredentials(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { if (allowOnlyPost && !"POST".equalsIgnoreCase(request.getMethod())) { - throw new HttpRequestMethodNotSupportedException(request.getMethod(), new String[] { "POST" }); + throw new HttpRequestMethodNotSupportedException(request.getMethod(), new String[] { "POST","G" }); } String clientId = request.getParameter(OAuth2Constants.PARAMETER.CLIENT_ID); diff --git a/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/request/DefaultOAuth2RequestFactory.java b/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/request/DefaultOAuth2RequestFactory.java index f91509df..94c542f3 100644 --- a/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/request/DefaultOAuth2RequestFactory.java +++ b/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/request/DefaultOAuth2RequestFactory.java @@ -17,6 +17,7 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.maxkey.authz.oauth2.common.OAuth2Constants; import org.maxkey.authz.oauth2.common.exceptions.InvalidClientException; import org.maxkey.authz.oauth2.common.util.OAuth2Utils; @@ -109,6 +110,10 @@ public class DefaultOAuth2RequestFactory implements OAuth2RequestFactory { } } String grantType = requestParameters.get(OAuth2Constants.PARAMETER.GRANT_TYPE); + if(StringUtils.isBlank(grantType)) { + //default client_credentials + grantType = OAuth2Constants.PARAMETER.GRANT_TYPE_CLIENT_CREDENTIALS; + } Set scopes = extractScopes(requestParameters, clientId); TokenRequest tokenRequest = new TokenRequest(requestParameters, clientId, scopes, grantType); diff --git a/maxkey-webs/maxkey-web-maxkey/src/main/resources/application-http.properties b/maxkey-webs/maxkey-web-maxkey/src/main/resources/application-http.properties index 936c3a86..bd65398f 100644 --- a/maxkey-webs/maxkey-web-maxkey/src/main/resources/application-http.properties +++ b/maxkey-webs/maxkey-web-maxkey/src/main/resources/application-http.properties @@ -16,7 +16,7 @@ #spring.profiles.active=http # ############################################################################ #server port -server.port =8080 +server.port =80 #session default 1800 #1800s =30m #28800s=8h diff --git a/maxkey-webs/maxkey-web-maxkey/src/main/resources/application.properties b/maxkey-webs/maxkey-web-maxkey/src/main/resources/application.properties index 73734b17..56e4f411 100644 --- a/maxkey-webs/maxkey-web-maxkey/src/main/resources/application.properties +++ b/maxkey-webs/maxkey-web-maxkey/src/main/resources/application.properties @@ -27,5 +27,5 @@ spring.main.banner-mode =log ############################################################################ #spring.profiles.active https/http; default https # ############################################################################ -spring.profiles.active =https +spring.profiles.active =http diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AccountsStrategyJob.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AccountsStrategyJob.java index 397721d5..da6bac33 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AccountsStrategyJob.java +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/AccountsStrategyJob.java @@ -57,9 +57,7 @@ public class AccountsStrategyJob implements Job , Serializable { accountsService = (AccountsService) context.getMergedJobDataMap().get("service"); }else { - accountsService.refreshAllByStrategy(); - Thread.sleep(10 *1000); } _logger.debug("DynamicGroupsJob is success " ); diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicGroupsJob.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicGroupsJob.java index 7890dc19..2ef93bbc 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicGroupsJob.java +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/jobs/DynamicGroupsJob.java @@ -56,9 +56,7 @@ public class DynamicGroupsJob implements Job , Serializable { groupsService = (GroupsService) context.getMergedJobDataMap().get("service"); }else { - groupsService.refreshAllDynamicGroups(); - Thread.sleep(10 *1000); } _logger.debug("DynamicGroupsJob is success " ); diff --git a/maxkey-webs/maxkey-web-mgt/src/main/resources/templates/views/apps/oauth20/appAdd.ftl b/maxkey-webs/maxkey-web-mgt/src/main/resources/templates/views/apps/oauth20/appAdd.ftl index 7428c3d7..3afb947c 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/resources/templates/views/apps/oauth20/appAdd.ftl +++ b/maxkey-webs/maxkey-web-mgt/src/main/resources/templates/views/apps/oauth20/appAdd.ftl @@ -81,6 +81,7 @@ authorization_code | code password implicit + client_credentials refresh_token id_token token diff --git a/maxkey-webs/maxkey-web-mgt/src/main/resources/templates/views/apps/oauth20/appUpdate.ftl b/maxkey-webs/maxkey-web-mgt/src/main/resources/templates/views/apps/oauth20/appUpdate.ftl index 4f4dadad..3ad6be09 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/resources/templates/views/apps/oauth20/appUpdate.ftl +++ b/maxkey-webs/maxkey-web-mgt/src/main/resources/templates/views/apps/oauth20/appUpdate.ftl @@ -68,6 +68,7 @@ authorization_code | codechecked type="checkbox" id="grantTypes_authorization_code" name="authorizedGrantTypes" value="authorization_code"/> passwordchecked type="checkbox" id="grantTypes_trust" name="authorizedGrantTypes" value="password"/> implicitchecked type="checkbox" id="grantTypes_implicit" name="authorizedGrantTypes" value="implicit"/> + client_credentialschecked type="checkbox" id="grantTypes_client_credentials" name="authorizedGrantTypes" value="client_credentials"/> refresh_tokenchecked type="checkbox" id="grantTypes_refresh_token" name="authorizedGrantTypes" value="refresh_token"/> id_tokenchecked type="checkbox" id="grantTypes_id_token" name="authorizedGrantTypes" value="id_token"/> tokenchecked type="checkbox" id="grantTypes_token" name="authorizedGrantTypes" value="token"/>