Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Nov 11, 2012
2 parents 305c8bb + 673db3c commit c7f0295
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 254 deletions.
2 changes: 1 addition & 1 deletion .springBeans
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[2.9.1.201203220057-RELEASE]]></pluginVersion>
<pluginVersion><![CDATA[3.1.0.201210040510-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
Expand Down
55 changes: 38 additions & 17 deletions pom.xml
Expand Up @@ -11,7 +11,7 @@

<groupId>com.cloudfoundry.identity</groupId>
<artifactId>cloudfoundry-login-server</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
<packaging>war</packaging>
<name>Cloud Foundry Login</name>
<description>Cloud Foundry Login App</description>
Expand All @@ -23,6 +23,33 @@
<url>https://rbcon.atlassian.net/browse/CF</url>
</issueManagement>

<repositories>
<repository>
<id>spring-release</id>
<name>Spring Framework Release Repository</name>
<url>http://maven.springframework.org/release</url>
</repository>
<repository>
<id>spring-milestone</id>
<name>Spring Framework Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository>
<repository>
<!-- necessary for Spring Security OAuth SNAPSHOT dependency -->
<id>spring-snapshost</id>
<name>Spring Framework Maven Snapshot Repository</name>
<url>http://maven.springframework.org/snapshot</url>
</repository>
<repository>
<id>objectstyle</id>
<name>ObjectStyle.org Repository</name>
<url>http://objectstyle.org/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<developers>
<developer>
<id>dsyer</id>
Expand Down Expand Up @@ -222,6 +249,16 @@
<groupId>org.cloudfoundry.identity</groupId>
<artifactId>cloudfoundry-identity-common</artifactId>
<version>${identity.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-tx</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-jdbc</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -260,23 +297,13 @@
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
Expand All @@ -292,12 +319,6 @@
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-openid</artifactId>
<version>${spring.security.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
Expand Down
Expand Up @@ -80,6 +80,10 @@ public class RemoteUaaController {

private static final String COOKIE = "Cookie";

private static final String SET_COOKIE = "Set-Cookie";

private static final String COOKIE_MODEL = "cookie";

private static String DEFAULT_BASE_UAA_URL = "https://uaa.cloudfoundry.com";

private Properties gitProperties = new Properties();
Expand All @@ -94,8 +98,8 @@ public class RemoteUaaController {

private String uaaHost;

private Map<String,String> links = new HashMap<String, String>();
private Map<String, String> links = new HashMap<String, String>();

/**
* @param links the links to set
*/
Expand Down Expand Up @@ -176,7 +180,7 @@ public String prompts(HttpServletRequest request, @RequestHeader HttpHeaders hea
return "home";
}

private Map<String,?> getLinksInfo() {
private Map<String, ?> getLinksInfo() {
Map<String, Object> model = new HashMap<String, Object>();
model.put("uaa", baseUrl);
model.put("login", baseUrl.replaceAll("uaa", "login"));
Expand Down Expand Up @@ -281,7 +285,8 @@ public ModelAndView startAuthorization(HttpServletRequest request, @RequestParam
String location = response.getHeaders().getFirst("Location");
if (location != null) {
logger.info("Redirect in /oauth/authorize for: " + principal.getName());
return new ModelAndView(new RedirectView(location));
// Don't expose model attributes (cookie) in redirect
return new ModelAndView(new RedirectView(location, false, true, false));
}

throw new IllegalStateException("Neither a redirect nor a user approval");
Expand Down Expand Up @@ -350,12 +355,22 @@ public ModelAndView handleRestClientException(ResourceAccessException e) throws
}

private void saveCookie(HttpHeaders headers, Map<String, Object> model) {
if (!headers.containsKey(SET_COOKIE)) {
return;
}
StringBuilder cookie = new StringBuilder();
// Save back end cookie for later
String cookie = headers.getFirst("Set-Cookie");
if (cookie != null) {
logger.debug("Saved back end cookie: " + cookie);
model.put("cookie", cookie);
for (String value : headers.get(SET_COOKIE)) {
if (value.contains(";")) {
value = value.substring(0, value.indexOf(";"));
}
if (cookie.length()>0) {
cookie.append(";");
}
cookie.append(value);
}
logger.debug("Saved back end cookies: " + cookie);
model.put(COOKIE_MODEL, cookie.toString());
}

private Map<String, String> getLoginCredentials(Principal principal) {
Expand Down Expand Up @@ -389,10 +404,12 @@ private ResponseEntity<byte[]> passthru(HttpServletRequest request, HttpEntity<b
requestHeaders.remove(COOKIE);
requestHeaders.remove(COOKIE.toLowerCase());
// Get back end cookie if saved in session
String cookie = (String) model.get("cookie");
String cookie = (String) model.get(COOKIE_MODEL);
if (cookie != null) {
logger.debug("Found back end cookie: " + cookie);
requestHeaders.set("Cookie", cookie);
logger.debug("Found back end cookies: " + cookie);
for (String value : cookie.split(";")) {
requestHeaders.add(COOKIE, value);
}
}

ResponseEntity<byte[]> response = defaultTemplate.exchange(baseUrl + "/" + path,
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/jsp/login.jsp
Expand Up @@ -129,7 +129,7 @@ img.gsc-branding-img,img.gsc-branding-img-noclear,img.gcsc-branding-img,img.gcsc
</article>
</div>
<div class="footer"
title="Version: ${app.version}, Commit: ${commit_id}, Timestamp: ${timestamp}, UAA: ${uaa}">
title="Version: ${app.version}, Commit: ${commit_id}, Timestamp: ${timestamp}, UAA: ${links.uaa}">
Copyright &copy;
<fmt:formatDate value="<%=new java.util.Date()%>" pattern="yyyy" />
VMware, Inc. All rights reserved.
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/WEB-INF/spring-servlet.xml
Expand Up @@ -25,7 +25,7 @@

<sec:http pattern="/resources/**" security="none" />
<sec:http pattern="/favicon.ico" security="none" />
<sec:http pattern="/healthz" security="none" />
<sec:http pattern="/healthz/**" security="none" />
<sec:http pattern="/login" security="none" />
<sec:http pattern="/info" security="none" />
<sec:http pattern="/oauth/token" security="none" />
Expand Down Expand Up @@ -219,6 +219,8 @@
<property name="links" ref="links"/>
</bean>

<bean id="healthzEndpoint" class="org.cloudfoundry.identity.uaa.varz.HealthzEndpoint"/>

<oauth:resource id="uaa" access-token-uri="${uaa.token.url:http://localhost:8080/uaa/oauth/token}"
client-id="login" client-secret="${LOGIN_SECRET:loginsecret}" type="client_credentials" />

Expand Down
76 changes: 0 additions & 76 deletions src/main/webapp/WEB-INF/varz-servlet.xml

This file was deleted.

63 changes: 0 additions & 63 deletions src/main/webapp/WEB-INF/web.xml
Expand Up @@ -15,54 +15,11 @@
</init-param>
</filter>

<filter>
<filter-name>varzSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.varz</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>varzSecurityFilterChain</filter-name>
<url-pattern>/varz/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>varzSecurityFilterChain</filter-name>
<url-pattern>/varz</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>varzSecurityFilterChain</filter-name>
<url-pattern>/healthz/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>varzSecurityFilterChain</filter-name>
<url-pattern>/healthz</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>varz</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextInitializerClasses</param-name>
<param-value>org.cloudfoundry.identity.uaa.config.YamlServletProfileInitializer</param-value>
</init-param>
<init-param>
<param-name>CONFIG_FILE_NAME</param-name>
<param-value>login.yml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
Expand All @@ -77,26 +34,6 @@
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>varz</servlet-name>
<url-pattern>/varz/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>varz</servlet-name>
<url-pattern>/varz</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>varz</servlet-name>
<url-pattern>/healthz</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>varz</servlet-name>
<url-pattern>/healthz/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
Expand Down
Expand Up @@ -15,7 +15,6 @@
import static org.junit.Assert.assertNotNull;

import org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBean;
import org.cloudfoundry.identity.uaa.varz.VarzEndpoint;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -53,12 +52,6 @@ public void testRootContextDefaults() throws Exception {
assertNotNull(context.getBean("viewResolver", ViewResolver.class));
}

@Test
public void testVarzContextDefaults() throws Exception {
context = getServletContext("file:./src/main/webapp/WEB-INF/varz-servlet.xml");
assertNotNull(context.getBean("varzEndpoint", VarzEndpoint.class));
}

private GenericXmlApplicationContext getServletContext(String... resources) {

String profiles = null;
Expand Down

0 comments on commit c7f0295

Please sign in to comment.