parent
d81c4d7c0b
commit
496c6d598e
7 changed files with 108 additions and 30 deletions
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.testsuite.example;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||||
|
*/
|
||||||
|
public class WebAppHelper {
|
||||||
|
|
||||||
|
public static String getAuthUri() {
|
||||||
|
boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true"));
|
||||||
|
String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180");
|
||||||
|
String authScheme = isTLSEnabled ? "https" : "http";
|
||||||
|
return authScheme + "://localhost:" + authPort + "/auth";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,17 +18,11 @@
|
||||||
|
|
||||||
<%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %>
|
<%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %>
|
||||||
<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
|
<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
|
||||||
|
<%@ page import="org.keycloak.testsuite.example.WebAppHelper" %>
|
||||||
<%
|
|
||||||
boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true"));
|
|
||||||
String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180");
|
|
||||||
String authScheme = isTLSEnabled ? "https" : "http";
|
|
||||||
String authUri = authScheme + "://localhost:" + authPort + "/auth";
|
|
||||||
%>
|
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<h2><a href="<%= KeycloakUriBuilder.fromUri(authUri).path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
|
<h2><a href="<%= KeycloakUriBuilder.fromUri(WebAppHelper.getAuthUri()).path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
|
||||||
.queryParam("redirect_uri", "http://localhost:8080/hello-world-authz-service").build("hello-world-authz").toString()%>">Logout</a></h2>
|
.queryParam("redirect_uri", "http://localhost:8080/hello-world-authz-service").build("hello-world-authz").toString()%>">Logout</a></h2>
|
||||||
|
|
||||||
<h3>Access Denied !</h3>
|
<h3>Access Denied !</h3>
|
||||||
|
|
|
@ -20,20 +20,16 @@
|
||||||
<%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %>
|
<%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %>
|
||||||
<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
|
<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
|
||||||
<%@ page import="org.keycloak.representations.idm.authorization.Permission" %>
|
<%@ page import="org.keycloak.representations.idm.authorization.Permission" %>
|
||||||
|
<%@ page import="org.keycloak.testsuite.example.WebAppHelper" %>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
KeycloakSecurityContext keycloakSecurityContext = (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName());
|
KeycloakSecurityContext keycloakSecurityContext = (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName());
|
||||||
AuthorizationContext authzContext = keycloakSecurityContext.getAuthorizationContext();
|
AuthorizationContext authzContext = keycloakSecurityContext.getAuthorizationContext();
|
||||||
|
|
||||||
boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true"));
|
|
||||||
String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180");
|
|
||||||
String authScheme = isTLSEnabled ? "https" : "http";
|
|
||||||
String authUri = authScheme + "://localhost:" + authPort + "/auth";
|
|
||||||
%>
|
%>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<h2>Welcome !</h2>
|
<h2>Welcome !</h2>
|
||||||
<h2><a href="<%= KeycloakUriBuilder.fromUri(authUri).path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
|
<h2><a href="<%= KeycloakUriBuilder.fromUri(WebAppHelper.getAuthUri()).path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
|
||||||
.queryParam("redirect_uri", "http://localhost:8080/hello-world-authz-service").build("hello-world-authz").toString()%>">Logout</a></h2>
|
.queryParam("redirect_uri", "http://localhost:8080/hello-world-authz-service").build("hello-world-authz").toString()%>">Logout</a></h2>
|
||||||
|
|
||||||
<h3>Your permissions are:</h3>
|
<h3>Your permissions are:</h3>
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.testsuite.servletauthz;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||||
|
*/
|
||||||
|
public class WebAppHelper {
|
||||||
|
|
||||||
|
public static String getAuthUri() {
|
||||||
|
boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true"));
|
||||||
|
String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180");
|
||||||
|
String authScheme = isTLSEnabled ? "https" : "http";
|
||||||
|
return authScheme + "://localhost:" + authPort + "/auth";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,18 +1,12 @@
|
||||||
<%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %>
|
<%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %>
|
||||||
<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
|
<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
|
||||||
|
<%@ page import="org.keycloak.testsuite.servletauthz.WebAppHelper" %>
|
||||||
<%
|
<%
|
||||||
String scheme = request.getScheme();
|
String scheme = request.getScheme();
|
||||||
String host = request.getServerName();
|
String host = request.getServerName();
|
||||||
int port = request.getServerPort();
|
int port = request.getServerPort();
|
||||||
String contextPath = request.getContextPath();
|
String contextPath = request.getContextPath();
|
||||||
String redirectUri = scheme + "://" + host + ":" + port + contextPath;
|
String redirectUri = scheme + "://" + host + ":" + port + contextPath;
|
||||||
|
|
||||||
|
|
||||||
boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true"));
|
|
||||||
String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180");
|
|
||||||
String authScheme = isTLSEnabled ? "https" : "http";
|
|
||||||
String authHost = System.getProperty("auth.server.host", "localhost");
|
|
||||||
String authUri = authScheme + "://" + authHost + ":" + authPort + "/auth";
|
|
||||||
%>
|
%>
|
||||||
<h2>Click here <a href="<%= KeycloakUriBuilder.fromUri(authUri).path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
|
<h2>Click here <a href="<%= KeycloakUriBuilder.fromUri(WebAppHelper.getAuthUri()).path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
|
||||||
.build("servlet-authz").toString()%>">Sign Out</a></h2>
|
.build("servlet-authz").toString()%>">Sign Out</a></h2>
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.testsuite.example;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||||
|
*/
|
||||||
|
public class WebAppHelper {
|
||||||
|
|
||||||
|
public static String getAuthUri() {
|
||||||
|
boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true"));
|
||||||
|
String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180");
|
||||||
|
String authScheme = isTLSEnabled ? "https" : "http";
|
||||||
|
return authScheme + "://localhost:" + authPort + "/auth";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,18 +1,12 @@
|
||||||
<%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %>
|
<%@ page import="org.keycloak.common.util.KeycloakUriBuilder" %>
|
||||||
<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
|
<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
|
||||||
|
<%@ page import="org.keycloak.testsuite.example.WebAppHelper" %>
|
||||||
<%
|
<%
|
||||||
String scheme = request.getScheme();
|
String scheme = request.getScheme();
|
||||||
String host = request.getServerName();
|
String host = request.getServerName();
|
||||||
int port = request.getServerPort();
|
int port = request.getServerPort();
|
||||||
String contextPath = request.getContextPath();
|
String contextPath = request.getContextPath();
|
||||||
String redirectUri = scheme + "://" + host + ":" + port + contextPath;
|
String redirectUri = scheme + "://" + host + ":" + port + contextPath;
|
||||||
|
|
||||||
|
|
||||||
boolean isTLSEnabled = Boolean.parseBoolean(System.getProperty("auth.server.ssl.required", "true"));
|
|
||||||
String authPort = isTLSEnabled ? System.getProperty("auth.server.https.port", "8543") : System.getProperty("auth.server.http.port", "8180");
|
|
||||||
String authScheme = isTLSEnabled ? "https" : "http";
|
|
||||||
String authHost = System.getProperty("auth.server.host", "localhost");
|
|
||||||
String authUri = authScheme + "://" + authHost + ":" + authPort + "/auth";
|
|
||||||
%>
|
%>
|
||||||
<h2>Click here <a href="<%= KeycloakUriBuilder.fromUri(authUri).path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
|
<h2>Click here <a href="<%= KeycloakUriBuilder.fromUri(WebAppHelper.getAuthUri()).path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
|
||||||
.build("servlet-policy-enforcer-authz").toString()%>">Sign Out</a></h2>
|
.build("servlet-policy-enforcer-authz").toString()%>">Sign Out</a></h2>
|
Loading…
Reference in a new issue