Giter Site home page Giter Site logo

spring-guides / tut-spring-security-and-angular-js Goto Github PK

View Code? Open in Web Editor NEW
1.7K 197.0 1.6K 3.04 MB

Spring Security and Angular:: A tutorial on how to use Spring Security with a single page application with various backend architectures, ranging from a simple single server to an API gateway with OAuth2 authentication.

Home Page: https://spring.io/guides/tutorials/spring-security-and-angular-js/

Ruby 0.18% Java 36.33% HTML 5.59% JavaScript 8.05% CSS 0.39% Shell 0.94% Batchfile 2.59% FreeMarker 2.03% TypeScript 43.90%

tut-spring-security-and-angular-js's Introduction

tut-spring-security-and-angular-js's People

Contributors

ajdowds avatar andruhon avatar bclozel avatar dependabot[bot] avatar doklib avatar dsyer avatar gavvvr avatar gitter-badger avatar gordianyuan avatar gregturn avatar kaminski-tomasz avatar lauriru avatar liuyocean avatar rdlopes avatar spring-operator avatar thetric avatar wgorder avatar wilder avatar yoshuanahar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tut-spring-security-and-angular-js's Issues

Static assets

How did you get your project to listen to static asset changes? I use the exact same project you have here in IntelliJ running it with Debug mode. And when I change something in the html or js the changes are not shown in broswer.

The only way to show changes is to trigger the Build manually...

When I work with an older Spring project that is not using Spring boot and is still using .jsp files, then there is no need for something like that. All the static asset changes are shown automatically.

oauth2 - No Access-Control-Allow-Origin

In the oauth2 project, when I run the outh2-ui, I get in the browser the following cross domain error:

XMLHttpRequest cannot load http://localhost:9999/uaa/oauth/authorize?client_id=acme&redirect_uri=http://localhost:8080/login&response_type=code&state=9EMa0U. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

But when you hit the "login" button you don't get it and you make it all the way to http://localhost:9999/uaa/login in order to authenticate which is the desired behavior.

Taking a look at the Network view in Chrome, the difference is that when the app loads the http://localhost:9999/uaa/oauth/authorize request shows as the initiator "other", but when you click on the login button the initiator shows as localhost:8080/login

CSRF-TOKEN not sending in response which creates a new session

This is for single subproject.

For example if we just do GET /user with valid Authorization header then in response there are no XSRF-TOKEN cookie as CsrfHeaderFilter thinks that token from request is not changed. But actially token is changing on creating a new session.

As a result if we try to instantly do any POST (for example POST /logout) then it doesn't work until we GET any resource.

I found a solution.
Instead of doing
.addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class)
I doing
.addFilterAfter(new CsrfHeaderFilter(), SessionManagementFilter.class)

I think that SessionManagementFilter creating a new CSRF token when creating a new session for authenticated user. So now when we do request.getAttribute(CsrfToken.class.getName()) then we get a new token and all working fine.

unable to run the ui server - error during build time

I cloned the the completed code repository.
Inside the Oauth2-vanilla, I started the authServer and resourceServer successfully by running mvn spring-boot run.

Inside the ui folder, I ran mvn spring-boot:run. I get the following error.
I get same error when I run mvn clean package too.

[INFO] wroManagerFactory class: ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
[Fatal Error] :4:66: The reference to entity "webapps" must end with the ';' delimiter.
[ERROR] Exception occured while processing: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected token: < @ line 1, column 1.
   <groups xmlns="http://www.isdc.ro/wro">
   ^

1 error
, class: org.codehaus.groovy.control.MultipleCompilationErrorsException,caused by: 
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected token: < @ line 1, column 1.
   <groups xmlns="http://www.isdc.ro/wro">
   ^

1 error

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296)
    at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:143)
    at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:113)
    at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:125)
    at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:353)
    at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:105)
    at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:72)
    at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:249)
    at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:158)
    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:814)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:511)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:279)
    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:727)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:739)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:694)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:775)
    at ro.isdc.wro.extensions.model.factory.GroovyModelFactory.create(GroovyModelFactory.java:64)
    at ro.isdc.wro.extensions.model.factory.GroovyModelFactory.create(GroovyModelFactory.java:42)
    at ro.isdc.wro.model.factory.LazyWroModelFactoryDecorator.create(LazyWroModelFactoryDecorator.java:28)
    at ro.isdc.wro.model.factory.LazyWroModelFactoryDecorator.create(LazyWroModelFactoryDecorator.java:16)
    at ro.isdc.wro.extensions.model.factory.SmartWroModelFactory.create(SmartWroModelFactory.java:194)
    at ro.isdc.wro.extensions.model.factory.SmartWroModelFactory.create(SmartWroModelFactory.java:38)
    at ro.isdc.wro.model.factory.ConfigurableModelFactory.create(ConfigurableModelFactory.java:68)
    at ro.isdc.wro.model.factory.ConfigurableModelFactory.create(ConfigurableModelFactory.java:18)
    at ro.isdc.wro.model.factory.WroModelFactoryDecorator.create(WroModelFactoryDecorator.java:27)
    at ro.isdc.wro.model.factory.FallbackAwareWroModelFactory.create(FallbackAwareWroModelFactory.java:48)
    at ro.isdc.wro.model.factory.FallbackAwareWroModelFactory.create(FallbackAwareWroModelFactory.java:22)
    at ro.isdc.wro.model.factory.WroModelFactoryDecorator.create(WroModelFactoryDecorator.java:27)
    at ro.isdc.wro.model.factory.ModelTransformerFactory.create(ModelTransformerFactory.java:55)
    at ro.isdc.wro.model.factory.ModelTransformerFactory.create(ModelTransformerFactory.java:27)
    at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator$1.initialize(DefaultWroModelFactoryDecorator.java:60)
    at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator$1.initialize(DefaultWroModelFactoryDecorator.java:50)
    at ro.isdc.wro.util.LazyInitializer.get(LazyInitializer.java:33)
    at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator.create(DefaultWroModelFactoryDecorator.java:114)
    at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator.create(DefaultWroModelFactoryDecorator.java:35)
    at ro.isdc.wro.maven.plugin.AbstractWro4jMojo.getModel(AbstractWro4jMojo.java:448)
    at ro.isdc.wro.maven.plugin.AbstractWro4jMojo.getAllModelGroupNames(AbstractWro4jMojo.java:444)
    at ro.isdc.wro.maven.plugin.AbstractWro4jMojo.getTargetGroupsAsList(AbstractWro4jMojo.java:292)
    at ro.isdc.wro.maven.plugin.Wro4jMojo.doExecute(Wro4jMojo.java:139)
    at ro.isdc.wro.maven.plugin.AbstractWro4jMojo.execute(AbstractWro4jMojo.java:164)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:364)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.492 s
[INFO] Finished at: 2015-08-28T11:54:40-07:00
[INFO] Final Memory: 22M/398M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "run-functional" could not be activated because it does not exist.
[ERROR] Failed to execute goal ro.isdc.wro4j:wro4j-maven-plugin:1.7.6:run (default) on project oauth2-vanilla-ui: Exception occured while processing: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[ERROR] Script1.groovy: 1: unexpected token: < @ line 1, column 1.
[ERROR] <groups xmlns="http://www.isdc.ro/wro">
[ERROR] ^
[ERROR] 
[ERROR] 1 error
[ERROR] , class: org.codehaus.groovy.control.MultipleCompilationErrorsException,caused by:
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Multiple UI:s, Zuul, Oauth2 SSO

Hi Dave,

I'm trying to build something similar to your excellent tutorial "Multiple UI Applications and a Gateway" (double) in combination with "SSO with OAuth2: Angular JS and Spring Security Part V" (oauth2-vanilla).

Basically I want the architecture as in the project double, but protected with OAuth2 SSO instead of HttpSession.

My target is to have 3 completly different UI-applications (Spring boot / angular) behind a ZuulProxy. Each UI-application is annotated with @EnableOAuth2Sso, so the authentication is handled by a OAuth2 AuthorizationServer (authorization_code flow), login page at "/uaa/login".

I also have several resource servers that should be accessible by the UI-applications and also other clients (mobile apps etc). The resource servers and the authorization server share a TokenStore, so the access-tokens can be verified.

Questions/problems:

  1. First and foremost; do you think my target architecture makes sense, or should I do some rethinking about some parts?
  2. When I navigate to http://localhost:8080/ui1 (which is routed by zuul to http://localhost:8081) the browser can't load java-script files for ui1 application (it tries to get them from http://localhost:8080/js), only if I add an extra slash, i.e: http://localhost:8080/ui1/. What can be the reason for that?
  3. When I navigate to http://localhost:8080/ui1/ and click on "login" I get redirected to http://localhost:9999/uaa/login as expected. But when I enter my credentials and sign-in I get redirected back to http://localhost:8081/#/ instead of :8080. How can I configure the setup to be redirected to the gateway as I think should be the intended scenario?

I created a sample repository for the applications, with only one UI. Please have a look.
https://github.com/flindby/spring-oauth2-zuul

Spring-session tutorial is unclear about Redis properties configuration

Will you please consider adding a note about adding the properties for the Redis host/port to the reader's application.properties file in the spring-session tutorial? Being a first time Docker and Redis user it wasn't immediately obvious that the Docker/Redis instance was running on a different IP address that needed to be added to the application.properties file.

Signup, Logout

Hello there,

first thanks for these samples. Could you extend the oauth2 example with a signup and logout function.
I tried by my own but I dont get it.

Or you can may give me a hint how to do it better.

First I created a SignupConfig like the LoginConfig

    @Configuration
    @Order(-9)
    protected static class SignupConfig extends WebSecurityConfigurerAdapter {
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.requestMatchers().antMatchers("/signup");
        }
    }

For Signup I created a controller by my own

@Controller
@RequestMapping("/signup")
public class SignupController {

    @Autowired
    private SignupService signupService;

    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView GET() {
        return new ModelAndView("signup");
    }

    @RequestMapping(method = RequestMethod.POST)
    public void POST(@RequestParam("username") String username, @RequestParam("password") String password, HttpServletRequest request) {
        signupService.signup(username, password, request);
    }

}

The signup service looks like

@Service
public class SignupServiceImpl implements SignupService {
    @Autowired
    private CustomUserRepository repository;

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void signup(String username, String password, HttpServletRequest request) {

        CustomUser user = new CustomUser();
        user.setName("name");
        user.setLogin(username);
        user.setPassword(password);

        repository.save(user);

        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
        // generate session if one doesn't exist
        request.getSession();

        token.setDetails(new WebAuthenticationDetails(request));
        Authentication authenticatedUser = authenticationManager.authenticate(token);
        SecurityContextHolder.getContext().setAuthentication(authenticatedUser);

    }
}

I know that the plain password is bad, but for quick testing its good enouhg ;)

So I got a nearly logged in user, if I go to localhost:7000/#/login I only have to authorize and than I have then full access as excepted. But, I want the user directly login after signup. I tried a lot of redirect stuff, but it neither looks good to me nor could it be the right way.

Can someone help me?

Thanks

JWT tokens not forwardable?

HI - I asked this question on Stackoverflow:

http://stackoverflow.com/questions/34185999/spring-oauth2resttemplate-loses-token-when-configured-to-use-jwt

The easier way of asking this question might be: should JWT tokens be forwardable (by default, OOB) with Spring Cloud OAuth2? They don't appear to be with the default behaviour, and I'm not sure if I have to implement something myself (e.g. my own TokenServices) or if I'm doing something else wrong.

In a nutshell, when resource servers are configured to use JWT (e.g. with a public key), once authentication occurs the token is not stored in the OAuth2ClientContext (like what happens with UserInfoTokenServices). So if a new request needs to be made downstream, the token is not available and it tries to go off and get one (and fails).

Incidentally, when an 'SSO client' (@EnableOAuth2Sso) authenticates by obtaining a token, it is stored in the OAuth2ClientContext, so as long as you don't try to perpetuate the calls beyond that it works OK.

oauth2-vanilla Resource Server asking for Basic auth, not Bearer

Hi Dave,

Wondering if I'm missing something simple. The oauth2-vanilla project, resource server is asking for Basic auth, not Bearer?

authserver is started, and looks like resource server has correct application.properties entry:

spring.oauth2.resource.userInfoUri: http://localhost:9999/uaa/user

Here's what happens ...

curl -v localhost:9000
> GET / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:9000
> Accept: */*
> 
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Basic realm="Spring"
...
{"timestamp":1423990178614,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/"}

As per your blog post it should do this ...

$ curl -v localhost:9000
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:9000
> Accept: */*
> 
< HTTP/1.1 401 Unauthorized
...
< WWW-Authenticate: Bearer realm="null", error="unauthorized", error_description="An Authentication object was not found in the SecurityContext"
< Content-Type: application/json;charset=UTF-8
{"error":"unauthorized","error_description":"An Authentication object was not found in the SecurityContext"}

Thanks,
Pete.

Is there a way to limit the origins that can log via the oauth2 sso?

I'm looking at the oauth2 example and it fits the use case I have in mind for my application, but i'm wondering if it is possibile to grant that only the ui webapp can log in to the system as client acme.

I'd like to provide different rights to different clients. But with the oauth2 Sso anyone can act like the "official" gui.

Can't get Resource Server to expect token authentication

There is a similar issue to this but I'm opening a new one since it is closed.

Hi,

I'm working through this tutorial and I've created a minimal resource server project. I'm at the bit where I'm trying to verify that the resource server expects a token. It looks like it's expecting basic authentication.

Everything below is for the resource server only, I don't think it's hitting the auth server, as even if I shut it down I get the same error.

Am I correct to think that something isn't right?

I read that basic authentication being enable might be the issue, but I've tried various ways of disabling it (Java config, application.yml) and it didn't seem to help.

[timw@neptune ~]$ curl -v localhost:9004
* Rebuilt URL to: localhost:9004/
*   Trying ::1...
* Connected to localhost (::1) port 9004 (#0)
> GET / HTTP/1.1
> Host: localhost:9004
> User-Agent: curl/7.45.0
> Accept: */*
> 
< HTTP/1.1 401 Unauthorized
< Server: Apache-Coyote/1.1
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Cache-Control: no-store
< Pragma: no-cache
< WWW-Authenticate: Bearer realm="null", error="unauthorized", error_description="Full authentication is required to access this resource"
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Sat, 21 Nov 2015 21:56:53 GMT
< 
* Connection #0 to host localhost left intact
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}

Code:

@EnableResourceServer
@SpringBootApplication
public class ResourceServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ResourceServerApplication.class, args);
    }
}

config:

server:
  port: 9004

security:
  basic:
    enabled: false
  oauth2:
    resource:
      userInfoUri: http://localhost:9999/uaa/user

POM:

<?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>resource-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>resource-server</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

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

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-oauth2</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-parent</artifactId>
            <version>Brixton.M3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

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

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

Multi tenant services

If the services are multi-tenant, where do I store the tenant information in Authorization server. Also how do I retrieve the tenant information from the token.

can part v "OAUTH2" use html5Mode?

I use part v JWT oauth2 and angular, it works fine ! thanks !!

but, when I use html5 Mode, part 3, "modular"

@RequestMapping(value = "/{[path:[^\\.]*}")
public String redirect() {
  return "forward:/";
}

in my ui "index.html", <a href="login"> it is not redirecting to
http://localhost:9999/uaa/login.

I have to change to <a href="http://localhost:9999/uaa/login"> and it redirected, when I input username and password, it redirect to "http://localhost:9988/uaa/" not expected " http://localhost:8080".

Can i use both html5 and your JWT oauth2 ?

how to href '/login' when using "Natural" Routes

hello,
i use
@RequestMapping(value = "/{[path:[^\.]*}")
public String redirect() {
return "forward:/";
}
if i want to use auth-server http://localhost:9999/uaa/oauth/login
in my ui server index.html,i set , but it intercepted by above "path redirect ",
how can i do ?
thanks

Only web static front ui angular application?

Hello gurus!

I could not find a model where the front ui application is only static files, like a pure angular app that just consume the backend. This is a bad practice?

Nowadays there's a lot of services in cloud on this model: static angular app -> firebase etc.

So I was thinking to do that with the OAuth2 model.

There's a good reference of Angular Consumption (just ignores the rails part): http://angular-tips.com/blog/2014/05/json-web-tokens-examples/

oauth2 two factor(multifactor) authorization

Hi. Could you please help me? I want to implement 2FA authorization with oauth2.
I want to use grant_type: password.
How do I see it...
Client after input login/password, will receive token with PRE_AUTH role. On success authentication I will add listener which will call service for sending sms with some code. I should add second factor here... I want to enhance token, or base on old token and sms code generate new token with FULL role.... I use default pass for oauth/token, but when I want to call it with Authentication: bearer token, I receive 403.
I think I should add Filter somewhere for intercept request, extract and parse token, add new role(FULL) and generate new token.
But where should I add this Filter?
And how should I generate new token, based on old one, If I use default bearer?
I need just entry points.
Maybe you have better solution how should I implement 2FA with oauth2.
Thanks in advance.

Unable to start Vanila OAuth2 UI

Cant start vanila OAuth2 UI server, always getting:

2015-11-29 01:13:51.727 ERROR 65612 --- [ main] o.s.boot.SpringApplication : Application startup failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [demo.UiApplication]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/cloud/security/oauth2/sso/OAuth2SsoConfigurerAdapter.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:677) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:519) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at demo.UiApplication.main(UiApplication.java:37) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_20]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_20]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_20]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_20]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/cloud/security/oauth2/sso/OAuth2SsoConfigurerAdapter.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReader.(SimpleMetadataReader.java:50) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:93) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:620) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getSuperClass(ConfigurationClassParser.java:800) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:313) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:231) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:190) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:271) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:231) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
... 18 common frames omitted

2015-11-29 01:13:51.735 INFO 65612 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@161479c6: startup date [Sun Nov 29 01:13:50 FET 2015]; root of context hierarchy

The first request "/ token" returned: HTTP / 1.1 401 Unauthorized

Reference spring-session example

According to this article (https://spring.io/blog/2015/01/20/the-resource-server-angular-js-and-spring-security-part-iii) configuration, discovery token first request failed!

angular code:

angular.module('hello', [ 'ngRoute' ])
...
.controller('home', function($scope, $http) {
    $http.get('token').success(function(token) {
        $http({
            url : 'http://localhost:9000',
            method : 'GET',
            headers : {
                'X-Auth-Token' : token.token
            }
        }).success(function(data) {
            $scope.greeting = data;
        });
    })
});

pom.xml add spring-security:

  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
  </dependency>

...

The first request "/ token" returned: HTTP / 1.1 401 Unauthorized
So I do not get 'X-Auth-Token': token.token

For java code "/ token" what configuration I missed it?

When accessing resource server gives "'uriTemplate' must not be null"

Hi there,

I setup your demo code. other services (UI and Auth) works fine. When I try to communicate with resource server it gives below error

java.lang.IllegalArgumentException: 'uriTemplate' must not be null
at org.springframework.util.Assert.hasText(Assert.java:162)
at org.springframework.web.util.UriTemplate$Parser.(UriTemplate.java:179)
at org.springframework.web.util.UriTemplate$Parser.(UriTemplate.java:172)
at org.springframework.web.util.UriTemplate.(UriTemplate.java:65)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:528)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:447)
at org.springframework.security.oauth2.provider.token.RemoteTokenServices.postForMap(RemoteTokenServices.java:138)
at org.springframework.security.oauth2.provider.token.RemoteTokenServices.loadAuthentication(RemoteTokenServices.java:107)
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager.authenticate(OAuth2AuthenticationManager.java:83)
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration$MetricsFilter.doFilterInternal(MetricFilterAutoConfiguration.java:90)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

Please advice me how to fix this issue.

Thank you very much.

Fahiz

error="invalid_scope" in authorization request

When i brows home page from OAuth2 UI, and it redirect to /login and then to /uaa/oauth/authorize
i got error empty scope. I did not limit the scope in any configuration. there is no scope param in authorization request.

I got authorization code by including default scope in authorization request, this is executed by curl command

Handling OAuth2 error: error="invalid_scope", error_description="Empty scope (either the client or the user is not allowed the requested scopes)"

Why http://localhost:9999/uaa/login is not proxyfied

I'm not sure I understood correctly the role Zuul is supposed to have.

I thought that zuul was supposed to be a reverse proxy so that every request to /login would be proxified to target localhost:9999/uaa/login

I've modified the routes like that :

zuul:
  routes:
    resource:
      path: /resource/**
      url: http://localhost:9000/resource
    login:
      path: /login/**
      url: http://localhost:9999/uaa/login
    user:
      path: /user/**
      url: http://localhost:9999/uaa/user
    auth:
      path: /auth/**
      url: http://localhost:9999/uaa/

But the browser is always redirected to localhost:9999/uaa/login

Is it possible to have only localhost:8080 used for all endpoints with Zuul ?

integration test example for resource server

There are some test cases of resource server to test the anonymous access denied when accessing the resource.

But there is no test case to demonstrate how accessing the resource server with proper or mocking authentication.

I tried it. But the resource server always talks to backend oauth2 server to verify the bearer token. Is there any way to mock the verify process? Could you add a test case to cover it?

oauth2 - Nothing showing on oauth2-ui localhost:8080

Thank you for your effort on creating very nice article set with full of information and samples.

I wanted to run and understand how it is working. Somehow I'm not able to see how oauth-ui works.
May be a m2e plugin issue. I use Eclipse Luna.

Some js files were not there or generated I think.
Here are my logs. Too many of them.

2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request '/' matched by universal pattern '/**'
2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 1 of 13 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 2 of 13 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] w.c.HttpSessionSecurityContextRepository : HttpSession returned null object for SPRING_SECURITY_CONTEXT
2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] w.c.HttpSessionSecurityContextRepository : No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@2d97191b. A new one will be created.
2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 3 of 13 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@1347f7ce
2015-07-18 12:19:38.931 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 4 of 13 in additional filter chain; firing Filter: 'CsrfFilter'
2015-07-18 12:19:38.932 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 5 of 13 in additional filter chain; firing Filter: ''
2015-07-18 12:19:38.932 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 6 of 13 in additional filter chain; firing Filter: 'LogoutFilter'
2015-07-18 12:19:38.932 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/'; against '/logout'
2015-07-18 12:19:38.932 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 7 of 13 in additional filter chain; firing Filter: 'OAuth2ClientAuthenticationProcessingFilter'
2015-07-18 12:19:38.932 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 8 of 13 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2015-07-18 12:19:38.932 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 9 of 13 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2015-07-18 12:19:38.932 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 10 of 13 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2015-07-18 12:19:38.932 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.a.AnonymousAuthenticationFilter  : Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@90576bf4: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@21a2c: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 9CAE6815F8AB448C2CA5ECFBAE987885; Granted Authorities: ROLE_ANONYMOUS'
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 11 of 13 in additional filter chain; firing Filter: 'SessionManagementFilter'
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 12 of 13 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / at position 13 of 13 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/'; against '/logout'
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor    : Secure object: FilterInvocation: URL: /; Attributes: [permitAll]
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor    : Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@90576bf4: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@21a2c: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 9CAE6815F8AB448C2CA5ECFBAE987885; Granted Authorities: ROLE_ANONYMOUS
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.access.vote.AffirmativeBased       : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@6e12796b, returned: 1
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor    : Authorization successful
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor    : RunAsManager did not change Authentication object
2015-07-18 12:19:38.933 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : / reached end of additional filter chain; proceeding with original chain
2015-07-18 12:19:38.934 DEBUG 17532 --- [nio-8080-exec-9] o.s.b.a.e.mvc.EndpointHandlerMapping     : Looking up handler method for path /
2015-07-18 12:19:38.935 DEBUG 17532 --- [nio-8080-exec-9] o.s.b.a.e.mvc.EndpointHandlerMapping     : Did not find handler method for [/]
2015-07-18 12:19:38.939 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/css/**'
2015-07-18 12:19:38.939 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/js/**'
2015-07-18 12:19:38.939 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/images/**'
2015-07-18 12:19:38.939 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/**/favicon.ico'
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/error'
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/info']
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/info'
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/info/**']
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/info/**'
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/info.*']
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/info.*'
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/hystrix.stream']
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/hystrix.stream'
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/hystrix.stream/**']
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/hystrix.stream/**'
2015-07-18 12:19:38.940 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/hystrix.stream.*']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/hystrix.stream.*'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/health']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/health'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/health/**']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/health/**'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/health.*']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/health.*'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/mappings']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/mappings'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/mappings/**']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/mappings/**'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/mappings.*']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/mappings.*'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/archaius']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/archaius'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/archaius/**']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/archaius/**'
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/archaius.*']
2015-07-18 12:19:38.941 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/archaius.*'
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/dump']
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/dump'
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/dump/**']
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/dump/**'
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/dump.*']
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/dump.*'
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/routes']
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/routes'
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/routes/**']
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/routes/**'
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/routes.*']
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/routes.*'
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/env']
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/env'
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/env/**']
2015-07-18 12:19:38.942 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/env/**'
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/env.*']
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/env.*'
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/restart']
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/restart'
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/restart/**']
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/restart/**'
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/restart.*']
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/restart.*'
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/refresh']
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/refresh'
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/refresh/**']
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/refresh/**'
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/refresh.*']
2015-07-18 12:19:38.943 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/refresh.*'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/metrics']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/metrics'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/metrics/**']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/metrics/**'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/metrics.*']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/metrics.*'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/configprops']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/configprops'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/configprops/**']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/configprops/**'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/configprops.*']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/configprops.*'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/autoconfig']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/autoconfig'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/autoconfig/**']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/autoconfig/**'
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/autoconfig.*']
2015-07-18 12:19:38.944 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/autoconfig.*'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/resume']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/resume'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/resume/**']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/resume/**'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/resume.*']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/resume.*'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/trace']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/trace'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/trace/**']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/trace/**'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/trace.*']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/trace.*'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/pause']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/pause'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/pause/**']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/pause/**'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/pause.*']
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/pause.*'
2015-07-18 12:19:38.945 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/beans']
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/beans'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/beans/**']
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/beans/**'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/beans.*']
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/beans.*'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request '/index.html' matched by universal pattern '/**'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 1 of 13 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 2 of 13 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 3 of 13 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 4 of 13 in additional filter chain; firing Filter: 'CsrfFilter'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 5 of 13 in additional filter chain; firing Filter: ''
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 6 of 13 in additional filter chain; firing Filter: 'LogoutFilter'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/index.html'; against '/logout'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 7 of 13 in additional filter chain; firing Filter: 'OAuth2ClientAuthenticationProcessingFilter'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 8 of 13 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 9 of 13 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2015-07-18 12:19:38.946 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 10 of 13 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2015-07-18 12:19:38.947 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.a.AnonymousAuthenticationFilter  : SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.AnonymousAuthenticationToken@90576bf4: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@21a2c: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 9CAE6815F8AB448C2CA5ECFBAE987885; Granted Authorities: ROLE_ANONYMOUS'
2015-07-18 12:19:38.947 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 11 of 13 in additional filter chain; firing Filter: 'SessionManagementFilter'
2015-07-18 12:19:38.947 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 12 of 13 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2015-07-18 12:19:38.947 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html at position 13 of 13 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2015-07-18 12:19:38.947 DEBUG 17532 --- [nio-8080-exec-9] o.s.security.web.FilterChainProxy        : /index.html reached end of additional filter chain; proceeding with original chain
2015-07-18 12:19:38.947 DEBUG 17532 --- [nio-8080-exec-9] o.s.b.a.e.mvc.EndpointHandlerMapping     : Looking up handler method for path /index.html
2015-07-18 12:19:38.948 DEBUG 17532 --- [nio-8080-exec-9] o.s.b.a.e.mvc.EndpointHandlerMapping     : Did not find handler method for [/index.html]
2015-07-18 12:19:38.950 DEBUG 17532 --- [nio-8080-exec-9] w.c.HttpSessionSecurityContextRepository : SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
2015-07-18 12:19:38.951 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.a.ExceptionTranslationFilter     : Chain processed normally
2015-07-18 12:19:38.951 DEBUG 17532 --- [nio-8080-exec-9] o.s.s.w.a.ExceptionTranslationFilter     : Chain processed normally
2015-07-18 12:19:38.951 DEBUG 17532 --- [nio-8080-exec-9] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2015-07-18 12:19:38.967 DEBUG 17532 --- [nio-8080-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/css/angular-bootstrap.css'; against '/css/**'
2015-07-18 12:19:38.967 DEBUG 17532 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : /css/angular-bootstrap.css has an empty filter list
2015-07-18 12:19:38.967 DEBUG 17532 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping     : Looking up handler method for path /css/angular-bootstrap.css
2015-07-18 12:19:38.968 DEBUG 17532 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping     : Did not find handler method for [/css/angular-bootstrap.css]
2015-07-18 12:19:38.970 DEBUG 17532 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping     : Looking up handler method for path /error
2015-07-18 12:19:38.971 DEBUG 17532 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping     : Did not find handler method for [/error]
2015-07-18 12:19:38.977 DEBUG 17532 --- [nio-8080-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/js/angular-bootstrap.js'; against '/css/**'
2015-07-18 12:19:38.977 DEBUG 17532 --- [nio-8080-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/js/angular-bootstrap.js'; against '/js/**'
2015-07-18 12:19:38.977 DEBUG 17532 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : /js/angular-bootstrap.js has an empty filter list
2015-07-18 12:19:38.977 DEBUG 17532 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping     : Looking up handler method for path /js/angular-bootstrap.js
2015-07-18 12:19:38.985 DEBUG 17532 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping     : Did not find handler method for [/js/angular-bootstrap.js]
2015-07-18 12:19:38.988 DEBUG 17532 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping     : Looking up handler method for path /error
2015-07-18 12:19:38.988 DEBUG 17532 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping     : Did not find handler method for [/error]
2015-07-18 12:19:39.005 DEBUG 17532 --- [io-8080-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/js/hello.js'; against '/css/**'
2015-07-18 12:19:39.005 DEBUG 17532 --- [io-8080-exec-10] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/js/hello.js'; against '/js/**'
2015-07-18 12:19:39.005 DEBUG 17532 --- [io-8080-exec-10] o.s.security.web.FilterChainProxy        : /js/hello.js has an empty filter list
2015-07-18 12:19:39.006 DEBUG 17532 --- [io-8080-exec-10] o.s.b.a.e.mvc.EndpointHandlerMapping     : Looking up handler method for path /js/hello.js
2015-07-18 12:19:39.007 DEBUG 17532 --- [io-8080-exec-10] o.s.b.a.e.mvc.EndpointHandlerMapping     : Did not find handler method for [/js/hello.js]

capture

And also pom has following error at wro4j-maven-plugin, which I do not understand,
capture2

"Could not get the value for parameter contextFolder for plugin execution default (ro.isdc.wro4j:wro4j-maven-plugin:1.7.6:run:default:generate-resources)"

All of the 3 apps are running.

How to use a different tokenstore ?

Hi,

I'm playing with the oauth2 sample.

I've tried to change the token store to use a MongoDBTokenStore.
I tried with an implementation of a token store found in jhipster. But I always get an error just after the confirmationForm (in authorize.ftl)

There was an unexpected error (type=Unauthorized, status=401).
Authentication Failed: Could not obtain access token

I modified the AuthserverApplication to add the creation of the bean :

    @Inject
    private OAuth2AccessTokenRepository oAuth2AccessTokenRepository;

    @Inject
    private OAuth2RefreshTokenRepository oAuth2RefreshTokenRepository;

    @Bean
    public TokenStore tokenStore() {
        return new MongoDBTokenStore(oAuth2AccessTokenRepository, oAuth2RefreshTokenRepository);
    }

Then I use it in OAuth2AuthorizationConfig

I've written some comments in the code to explain the modication.

        // injection of the mongodb token store 
        @Autowired
        private TokenStore tokenStore;


         // I commented this part because I don't think I need it if I use a persistent token store. But I'm not sure to understand correctly what it does.
//        @Bean
//        public JwtAccessTokenConverter jwtAccessTokenConverter() {
//            JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
//            KeyPair keyPair = new KeyStoreKeyFactory(
//                    new ClassPathResource("keystore.jks"), "foobar".toCharArray())
//                    .getKeyPair("test");
//            converter.setKeyPair(keyPair);
//            return converter;
//        }

        @Override
        public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
            clients.inMemory()
                    .withClient("acme")
                    .secret("acmesecret")
                    .authorizedGrantTypes("authorization_code", "refresh_token", "password")
                    .scopes("openid");
        }

        @Override
        public void configure(AuthorizationServerEndpointsConfigurer endpoints)
                throws Exception {
            endpoints
                    .tokenStore(tokenStore)
                    .authenticationManager(authenticationManager)
            ;
        }

        // I didn't understand this part and I've tried with or without with no success.
//        @Override
//        public void configure(AuthorizationServerSecurityConfigurer oauthServer)
//                throws Exception {
//            oauthServer.tokenKeyAccess("permitAll()").checkTokenAccess(
//                    "isAuthenticated()");
//        }

I've tried a lot of things :

  • disable the crsf settings (but without any success, I had some errors saying that a token is expected)
  • inject the tokenstore in OAuth2ResourceConfig to initialize the ResourceServerSecurityConfigurer with it
  • etc...

But to be honest, a lot of configurations seems obscure for me.

Any idea ?

Single - CSRF protection does not kick - "help wanted"

Hello everybody,

I am following Part II - The Login Page tutorial step by step. I am at the stage where CSRF protection is not configured ("Handling the Login Request on the Server" section on the webpage https://spring.io/guides/tutorials/spring-security-and-angular-js/#_the_login_page_angular_js_and_spring_security_part_ii) however the application is working perfectly well and I don't face 403 status when I submit login page. I don't understand why. I am able to access all the resources. It seems CSRF spring security protection does not kick.

I have clone the git repository and my java class look like that

@SpringBootApplication
@RestController
public class UiApplication {

...

@configuration
@order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@OverRide
protected void configure(HttpSecurity http) throws Exception {
http
.httpBasic()
.and()
.authorizeRequests()
.antMatchers("/index.html", "/home.html", "/login.html", "/").permitAll()
.anyRequest().authenticated();
}
}

}

It would be much appreciated if you have any idea

thanks

Bye

Benoit

Sign out

Hi Dave,
Thank you for this amazing series and all the support you are giving us all.
My goal is building a stable, scalable and mostly as secure as it can get system based on microservices, with front ends both web and mobile (Android/IOS).
I have successfully integrated together the “double” and “oauth2” sample, with the authentication server version that uses JWT Tokens. So basically I have followed part VI of the series and went back to an external authentication server with JWT’s. I also use a different Docker Redis image that allows for setting a Redis password. With very little modifications the system is up and running, everything works as expected, except the logout functionality.
I can login from the GW sith SSO, I can approve or deny request, etc. The problem is when I click the logout button, it logs me out at first. If I do a refresh of the page I am still logged out but at the second refresh something kicks in and I am automatically logged back in.
I can see in the GW console at the second refresh the following:
Secure object: FilterInvocation: URL: /user; Attributes: [authenticated]
2015-11-18 12:09:34.469 DEBUG 3648 --- [io-8080-exec-10] o.s.s.w.a.i.FilterSecurityInterceptor : Previously Authenticated: org.springframework.security.oauth2.provider.OAuth2Authentication@e9fcae3d: Principal: user; Credentials: [PROTECTED]; Authenticated: true; Details: remoteAddress=0:0:0:0:0:0:0:1, sessionId=, tokenType=bearertokenValue=; Granted Authorities: ROLE_ADMIN, ROLE_USER
2015-11-18 12:09:34.469 DEBUG 3648 --- [io-8080-exec-10] o.s.s.access.vote.AffirmativeBased : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@1488a3db, returned: 1
2015-11-18 12:09:34.469 DEBUG 3648 --- [io-8080-exec-10] o.s.s.w.a.i.FilterSecurityInterceptor : Authorization successful

Do you have any idea how to fix this?
Thank you!

How to configure JWT authorization server without redirect

Hi, I have question regarding "oauth2" version of the example.

Is there any easy way (or example) how to set up a JWT authorization server so that I can just log in using Angular form in UI application and access a token? This token should be automagically included in each request header and then read by a targeted micro service (I assume this part can be done without pain using @EnableResourceServer annotation and public key included in properties file). What I understand, I should use Zuul proxy to simplify routing stuff, but skip @EnableOAuth2Sso because I would use a login form of UI application and use auth server as a token provider without any user interface.

Any help would be appreciated.

Question about Zuul and oauth

Hi Dave,

Thanks for your reply here.

For my use case, spring cloud security doesn't suit me well. The OAuth server I'm using only support password grant type, so I don't know how can I achieve that, here is what I tried, but it doesn't seem to work:

    @Configuration
    protected static class OAuth2Configuration extends OAuth2SsoConfigurerAdapter {

        private final Logger log = LoggerFactory.getLogger(this.getClass());

        @Bean
        public OAuth2RestTemplate oAuth2RestTemplate() {
            return new OAuth2RestTemplate(resource());
        }

        @Bean
        protected OAuth2ProtectedResourceDetails resource() {

            ResourceOwnerPasswordResourceDetails resource = new ResourceOwnerPasswordResourceDetails();

            resource.setAccessTokenUri("http://localhost:9999/uaa/oauth/token");
            resource.setClientId("acme");
            resource.setId("sparklr");
            resource.setUsername("user");
            resource.setPassword("password");
            resource.setScope(Arrays.asList("openid"));
            resource.setClientSecret("acmesecret");
            resource.setGrantType("password");
            return resource;
        }
        @Override
        public void match(RequestMatchers matchers) {
            matchers.anyRequest();
        }

        @Override
        public void configure(HttpSecurity http) throws Exception {
            http.authorizeRequests().antMatchers("/index.html", "/home.html", "/")
                    .permitAll().anyRequest().authenticated().and().csrf()
                    .csrfTokenRepository(csrfTokenRepository()).and()
                    .addFilterAfter(csrfHeaderFilter(), CsrfFilter.class);
        }
... csrf stuff
    }

How do I approve individual scopes in the authorize page?

How do I make authorize.ftl to display and approve individual scopes like the WhiteLabelApproval Endpoint? I tried to send the below key/value pairs to /oauth/authorize
read = true
write = false
But /oauth/authorize endpoint accepts both the scopes as true. Am I missing something?

Unclear behavior in the project "single" with logout

There is an unclear behavior in the module "single" or some error (https://github.com/spring-guides/tut-spring-security-and-angular-js/tree/master/single).

The function:

$scope.logout = function() {
    $http.post('logout', {}).success(function() {
        $rootScope.authenticated = false;
        $location.path("/");
    }).error(function(data) {
        console.log("Logout failed")
        $rootScope.authenticated = false;
    });
}

in the hello.js always return error with the status 401. But in general, logout works correct, because protected resources are not available after that. But why the success handler doesn't work ? That is the question.

Deploy it on tomcat

Hi, I checkout the source code, tried build a project using maven and Eclipse, after tried run it inside a Tomcat. It cannot run stand alone as every developer in the world does, please can you convert it to a normal form? Many of us don't appreciate running command line and wait things happen magically.

oauth2-vanilla directions should specify adding userInfoUri before Bearer realm appears

In the "Changing the Resource Server" section of the README.adoc it specifies that after modifying pom.xml and ResourceApplication.groovy that server will respond with:
WWW-Authenticate: Bearer realm="null"....

However, in running the example I found that I also had to modify the application.properties (specifically add the userInfoUri key) before I would receive that. It would be nice if the directions could be updated to match the needed steps.

That said, these tutorials are awesome. Thank you very much.

formLogin

I tried to use formLogin instead of basic . The reason for this is i want to have the feature of redirecting to initial requested page after successful login .

After doing the changes it worked out if i login then go to any page on the UI but if i try to go to the UI directly and it prompt the login (redirect to login page on Gateway) i never get authenticated.

I think the problem is in wrong SESSION returned.

Have any one tried to use formlogin or implemented the default return url feature.

Spring-session resource application does not handle Chrome's OPTIONS requests

@dsyer
I'm writing because I spent several hours trying to figure out why I was receiving a "Response for preflight has invalid HTTP status code 401" from my Chrome's console. It turns out that the Resources application is sending back a 401 to the initial OPTIONS request that the Chrome browser is issuing. I resolved this issue by overriding the configure method in the WebSecurityConfigurerAdapter class with the following:

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
       .csrf().disable()
       .authorizeRequests()
         .antMatchers(HttpMethod.OPTIONS,"/").permitAll()//allow CORS option calls
         .antMatchers("/resources/**").permitAll()
         .anyRequest().authenticated()
       .and()
       .formLogin()
       .and()
       .httpBasic();
    }

Please consider adding something of this likeness to the tutorial in order to avoid confusion for future readers as it was an extremely confusing bug to resolve.

P.S.- Thank you for your Spring Session tutorial, it's been extremely helpful and mostly intuitive.

Is it possible to restrict resource access on resource service with @PreAuthorize ?

Hi, I have cloned your spring-security-angular/oauth2 example with resource, auth and ui components and tried to restrict resource endpoint with:

@PreAuthorize("hasAnyRole('ROLE_FOO','ROLE_BAR')")
@RequestMapping('/')
def home() {
    [id: UUID.randomUUID().toString(), content: 'Hello World']
}

however, it still passes (I expected 403 to be returned).
Is it possible to restrict resource access in a such way?

oauth2-vanilla custom login/approval

When I copied the oauth2 project Freemarker custom login code, WRO js scripts and dependencies to the oauth2-vanilla project and replace the jwt token store with in memory token store the UI is not getting the token so it reports 401 error on approval request. Are there other changes that need to be added?

I would also like to suggest a future topic on using a mobile client for logging into to the server.

@SpringBootApplication
@Configuration
@Controller
@SessionAttributes("authorizationRequest")
@EnableResourceServer
public class AuthserverApplication extends  WebMvcConfigurerAdapter{

    private static final Logger log = LoggerFactory.getLogger(AuthserverApplication.class);


    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/oauth/confirm_access").setViewName("authorize");
    }

    public static void main(String[] args) {
        SpringApplication.run(AuthserverApplication.class, args);
    }

    @RequestMapping("/user")
    @ResponseBody
    public Principal user(Principal user) {
        return user;
    }

    @Configuration
    @EnableAuthorizationServer
    protected static class OAuth2Config extends AuthorizationServerConfigurerAdapter {

        @Autowired
        private AuthenticationManager authenticationMgr;

        @Bean
        public TokenStore tokenStore() {
            return new InMemoryTokenStore();
        }


        @Override
        public void configure(AuthorizationServerEndpointsConfigurer endpoints)
                throws Exception {
            endpoints.tokenStore(tokenStore()).authenticationManager(this.authenticationMgr);
        }


        @Override
        public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
            oauthServer.tokenKeyAccess("permitAll()").checkTokenAccess("isAuthenticated()");
        }


        @Override
        public void configure(ClientDetailsServiceConfigurer clients)
                throws Exception {
            clients.inMemory()
                    .withClient("acme")
                    .secret("acmesecret")
                    .authorizedGrantTypes("authorization_code",
                            "refresh_token", "password").scopes("openid");
        }

    }


    @Configuration
    @Order(-10)
    protected static class LoginConfig extends WebSecurityConfigurerAdapter {


        @Autowired
        private AuthenticationManager authenticationManager;


        @Autowired
        private DataSource dataSource;


        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
                .formLogin().loginPage("/login").permitAll()
            .and()
                .requestMatchers().antMatchers("/metrics", "/login", "/oauth/authorize", "/oauth/confirm_access","/admin/**")
            .and().authorizeRequests().antMatchers("/admin/**").hasRole("ADMIN").and()
                .authorizeRequests().anyRequest().authenticated();
        }

        @Override
        public void configure(AuthenticationManagerBuilder auth) throws Exception {
            auth.parentAuthenticationManager(authenticationManager).jdbcAuthentication().dataSource(dataSource);

        }

    }
}

Error in spring-security-angular\spring-session for command mvn spring-boot:run

Many thanks for the wonderful examples. I am trying to learn these.

I am trying to the application spring-security-angular\spring-session with command 'mvn spring-boot:run'

And end up getting this error. I could not find any readme document to run this example.
Please help.

2015-10-08 10:22:40.798  WARN 6720 --- [lication.main()] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class org.springframework.session.data.redis.config.anno
tation.web.http.RedisHttpSessionConfiguration: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested
 exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
        at demo.UiApplication.main(UiApplication.java:40)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a res
ource from the pool
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:140)
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:229)
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:57)
        at org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotificationsInitializer.afterPropertiesSet(RedisHttpSessionConfiguration.
java:156)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
        ... 21 common frames omitted
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
        at redis.clients.util.Pool.getResource(Pool.java:42)
        at redis.clients.jedis.JedisPool.getResource(JedisPool.java:84)
        at redis.clients.jedis.JedisPool.getResource(JedisPool.java:10)
        at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:133)
        ... 26 common frames omitted
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect
        at redis.clients.jedis.Connection.connect(Connection.java:150)
        at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:71)
        at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1783)
        at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:65)
        at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:836)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:434)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:361)
        at redis.clients.util.Pool.getResource(Pool.java:40)
        ... 29 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at redis.clients.jedis.Connection.connect(Connection.java:144)
        ... 36 common frames omitted

2015-10-08 10:22:41.131  INFO 6720 --- [lication.main()] o.apache.catalina.core.StandardService   : Stopping service Tomcat

Making Resource server standalone with out spring boot and using tomcat as target environment

I had an issue while making my existing REST API to security enabling with Oauth2. I am using completely annotation based and I have made my controller with preauthorize methods. I have followed your example and I have had issues while running the app with out spring boot. Here is the issue:

java.lang.IllegalArgumentException: An AuthenticationManager is required
    at org.springframework.util.Assert.notNull(Assert.java:112)

And the above message I am aware about that its about authentication manager but I do not want to include the part of code where authentication manager is in the resource server since I have already authentication manager in authentication server project . I am attaching my files what I have included in the resource server.
AuthQueryController.txt
MethodSecurityConfig.txt
OAuth2ResourceConfig.txt
OAuth2ResourceService.txt

Please help me what am I missing on making this with out spring boot. I have commented out the boot class.

How to get user details after successful OAuth2 authorization

First of all, thank you very much for this awesome tutorial.

I have a question about OAuth2 UserDetails and access/refresh token intercepting after successful OAuth2 authorization. After successful authorization I need to create a new User in my own database with a UserDetails returned by OAuth2 Auth Server and also need to store access/refresh tokens for this user.

How it can be achieved ? I can't find a place where this logic have to be added.

This is my question on stackoverflow:
http://stackoverflow.com/questions/34639130/spring-intercept-successful-oauth2-authorization-on-the-resourceserver-side

Could you please show how it can be implemented ?

User Details Service integration to the gateway.

In 'double' project we use

auth.inMemoryAuthentication()
                .withUser("user").password("password").roles("USER")
            .and()
                .withUser("admin").password("admin").roles("USER", "ADMIN", "READER", "WRITER")
            .and()
                .withUser("audit").password("audit").roles("USER", "ADMIN", "READER");

and we can login users with these details. But when we add

auth.userDetailsService(customUserDetailsService).passwordEncoder(passwordEncoder());

it gives an error with

java.lang.ClassNotFoundException: <pakage>.CustomUserDetailsService$UserRepositoryUserDetails

How to solve this issue. Or even get user details from database?

How to handle a resource calling another one with OAuth2 and JWT

I have a working setup with multiple resource services and SSO working fine when calling them from the ui. This is based on your OAuth2 tutorial at https://github.com/spring-guides/tut-spring-security-and-angular-js/tree/master/oauth2

Now I'm trying to figure out how one service can call another one and can't find any examples or tutorial. I've tried a couple of different solutions such as adding @EnableOAuth2Client to the "client" service, creating my own OAuth2ClientContextFilter and different RestTemplate setups without any luck.
The results have been variable from HTTP 401 to "A redirect is required to get the users approval"

Can you help me with any pointers?

N.B: Also worth mentioning that Eureka for service discovery is involved.

Rest authentication

As seen in examples, authentication is always done through web browser on authentication server. Is it possible to have security configuration in that way to do login in RESTful manner with oauth2? So, not to have redirect on server, but to get 401, and then do post on '/login' with username and password which will be sent to oauth server by zuul. And to have result as rest response with oauth2 token?

SSO autologin not works

First of all, thanks for the very good articles, and samples.

My problem in oauth2 sample:
I can start all 3 application, and everything works fine, but:
I would like to test, what happens, if the UI project cookie expires, but AuthServer's not.
In my case, if the authserver thinks, that user is logged in, but UI has not got logged in information, then UI fetch that information from AuthServer. But not did it.

How can I tried this:

  • Login to UI, with Authserver's help (got cookie session for Authserver, and UI also)
  • delete/invalidate ui cookie
  • refresh the page

Result:

  • I need to reLogin, but in Authserver I am logged in, so I can not reEnter my username, and password)

Expected result:

  • The UI server auto login the user (SSO), and display the page, as u logged in, and authorized. (not neccesary to click to login link, and trust again)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.