Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersvg committed Feb 25, 2017
0 parents commit 6908406
Show file tree
Hide file tree
Showing 22 changed files with 1,022 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
1 change: 1 addition & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Spring Boot and OAuth2

Spring boot OAuth2 application based on this [tutorial](https://spring.io/guides/tutorials/spring-boot-oauth2/).
Composed by the following modules:
* ui authentication server authorization server and reverse proxy
* client resource server


## Installation
jdk 1.8 required

## Usage

start ui server: `./mvnw -pl ui clean spring-boot:run`
start client server: `./mvnw -pl client clean spring-boot:run`
access: http://localhost:8080/client
24 changes: 24 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
4 changes: 4 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Client application

##Description
Application meant to connect to the authorization server to in time get redirected to the authentication endpoint
68 changes: 68 additions & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>client</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>com.example</groupId>
<artifactId>spring-boot-and-oauth2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
29 changes: 29 additions & 0 deletions client/src/main/java/com/example/ClientApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

@EnableAutoConfiguration
@Configuration
@EnableOAuth2Sso
//@RestController
public class ClientApplication {

// @RequestMapping("/")
// public String home(Principal user) {
// return "Hello " + user.getName();
// }

public static void main(String[] args) {
new SpringApplicationBuilder(ClientApplication.class)
.properties("spring.config.name=client").run(args);
}

}
26 changes: 26 additions & 0 deletions client/src/main/java/com/example/customer/Customer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.customer;

/**
* Created by javier on 04/02/17.
*/
public class Customer {

String id;
String name;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
10 changes: 10 additions & 0 deletions client/src/main/java/com/example/customer/CustomerRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.customer;

import org.springframework.data.mongodb.repository.MongoRepository;

/**
* Created by javier on 04/02/17.
*/
public interface CustomerRepository extends MongoRepository<Customer, String> {
Customer getByName(String name);
}
12 changes: 12 additions & 0 deletions client/src/main/resources/client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server:
port: 9999
context-path: /client
security:
oauth2:
client:
client-id: acme
client-secret: acmesecret
access-token-uri: http://localhost:8080/oauth/token
user-authorization-uri: http://localhost:8080/oauth/authorize
resource:
user-info-uri: http://localhost:8080/me
Loading

0 comments on commit 6908406

Please sign in to comment.