-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
262 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.mskcc.cbio</groupId> | ||
<artifactId>security</artifactId> | ||
<version>2.0.0-31-gefc5979c1-dirty-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>security-spring</artifactId> | ||
<version>2.0.0-31-gefc5979c1-dirty-SNAPSHOT</version> | ||
<properties> | ||
<org.springframework.social.google-version>1.1.3</org.springframework.social.google-version> | ||
<spring.social.version>1.1.6.RELEASE</spring.social.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.mskcc.cbio</groupId> | ||
<artifactId>web</artifactId> | ||
<version>2.0.0-31-gefc5979c1-dirty-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-acl</artifactId> | ||
<version>${spring.security.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-config</artifactId> | ||
<version>${spring.security.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-core</artifactId> | ||
<version>${spring.security.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-ldap</artifactId> | ||
<version>${spring.security.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-openid</artifactId> | ||
<version>${spring.security.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security.extensions</groupId> | ||
<artifactId>spring-security-saml2-core</artifactId> | ||
<version>${spring.security.saml.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-taglibs</artifactId> | ||
<version>${spring.security.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security</groupId> | ||
<artifactId>spring-security-web</artifactId> | ||
<version>${spring.security.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-security</artifactId> | ||
<version>2.1.2.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security.oauth.boot</groupId> | ||
<artifactId>spring-security-oauth2-autoconfigure</artifactId> | ||
<version>2.1.2.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.api-client</groupId> | ||
<artifactId>google-api-client</artifactId> | ||
<version>1.19.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.oauth-client</groupId> | ||
<artifactId>google-oauth-client</artifactId> | ||
<version>1.23.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.oauth-client</groupId> | ||
<artifactId>google-oauth-client-servlet</artifactId> | ||
<version>1.23.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.social</groupId> | ||
<artifactId>spring-social-config</artifactId> | ||
<version>${spring.social.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.social</groupId> | ||
<artifactId>spring-social-core</artifactId> | ||
<version>${spring.social.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.social</groupId> | ||
<artifactId>spring-social-security</artifactId> | ||
<version>${spring.social.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.social</groupId> | ||
<artifactId>spring-social-web</artifactId> | ||
<version>${spring.social.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.spring-social</groupId> | ||
<artifactId>spring-social-google</artifactId> | ||
<version>${org.springframework.social.google-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
<version>2.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>3.0.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.security.oauth</groupId> | ||
<artifactId>spring-security-oauth2</artifactId> | ||
<version>2.3.0.RC1</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...tal/security/spring/authentication/google/oauth2/CustomAuthorizationServerConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
import org.springframework.security.authentication.AuthenticationManager; | ||
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; | ||
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; | ||
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; | ||
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; | ||
|
||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
/** | ||
* | ||
* @author ochoaa | ||
*/ | ||
public class CustomAuthorizationServerConfigurer extends AuthorizationServerConfigurerAdapter { | ||
private AuthenticationManager authenticationManager; | ||
|
||
public CustomAuthorizationServerConfigurer(AuthenticationConfiguration authenticationConfiguration) throws Exception { | ||
this.authenticationManager = authenticationConfiguration.getAuthenticationManager(); | ||
} | ||
|
||
@Override | ||
public void configure(ClientDetailsServiceConfigurer clients) throws Exception { | ||
clients.inMemory() | ||
.withClient("client") | ||
.authorizedGrantTypes("password") | ||
.secret("{noop}secret") | ||
.scopes("all"); | ||
} | ||
|
||
@Override | ||
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { | ||
endpoints.authenticationManager(authenticationManager); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...ioportal/security/spring/authentication/google/oauth2/GenericOAuth2ConnectionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package org.cbioportal.security.spring.authentication.google.oauth2; | ||
|
||
//import java.util.Set; | ||
//import java.util.HashSet; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.security.oauth2.config.annotation.builders.ClientDetailsServiceBuilder; | ||
import org.springframework.security.oauth2.config.annotation.builders.ClientDetailsServiceBuilder.ClientBuilder; | ||
import org.springframework.security.oauth2.provider.ClientDetailsService; | ||
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory; | ||
|
||
/** | ||
* | ||
* @author ochoaa | ||
*/ | ||
public class GenericOAuth2ConnectionFactory extends DefaultOAuth2RequestFactory { | ||
@Value("${google.client}") | ||
private String clientId; | ||
@Value("${google.client.secret}") | ||
private String clientSecret; | ||
|
||
public GenericOAuth2ConnectionFactory(ClientDetailsService clientDetailsService) { | ||
super(clientDetailsService); | ||
} | ||
|
||
@Bean | ||
public GenericOAuth2ConnectionFactory genericOAuth2ConnectionFactory() throws Exception { | ||
// Set<String> redirectUris = new HashSet<>(); | ||
// redirectUris.add("https://accounts.google.com/o/oauth2/auth"); | ||
// redirectUris.add("https://accounts.google.com/o/oauth2/token"); | ||
ClientBuilder builder = new ClientDetailsServiceBuilder() | ||
.withClient(clientId) | ||
.secret(clientSecret); | ||
builder.redirectUris("https://www.googleapis.com/oauth2/v2/userinfo"); | ||
return new GenericOAuth2ConnectionFactory(builder.and().build()); | ||
} | ||
} |