Giter Site home page Giter Site logo

selakavon / spring-rest-oauth2-mongo Goto Github PK

View Code? Open in Web Editor NEW
25.0 25.0 18.0 41 KB

Sample Hypermedia-Driven RESTful Web Service service based on Spring Boot platform using OAuth2 for protecting the endpoint and Mongo DB as a NoSQL storage.

Java 100.00%

spring-rest-oauth2-mongo's People

Contributors

selakavon 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

Watchers

 avatar  avatar  avatar

spring-rest-oauth2-mongo's Issues

java.lang.IllegalArgumentException: Invalid character (CR or LF) found in method name

I am simply running this code on the 8080, by commenting the logic on properties file

java.lang.IllegalArgumentException: Invalid character (CR or LF) found in method name

2017-09-12 01:55:56.181  INFO 21432 --- [nio-8080-exec-3] o.a.coyote.http11.Http11NioProcessor     : Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

java.lang.IllegalArgumentException: Invalid character (CR or LF) found in method name
	at org.apache.coyote.http11.AbstractNioInputBuffer.parseRequestLine(AbstractNioInputBuffer.java:228) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-embed-core-8.0.32.jar:8.0.32]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.32.jar:8.0.32]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.32.jar:8.0.32]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_144]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_144]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.32.jar:8.0.32]
	at java.lang.Thread.run(Unknown Source) [na:1.8.0_144]

image

org.springframework.web.HttpMediaTypeNotSupportedException

I am using exactly the same code as yours, but the following is not working

C:>curl -X POST https://localhost:8443/api/users -k -d '{"fullName":"Ales Novak","userName":"ales","password":"secret"}' -H 'Content-Type: application/json'

{"timestamp":1505151006511,"status":415,"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException","message":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported","path":"/api/users"}

curl: (6) Could not resolve host: application

The below are the

2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/oauth/token']
2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token'; against '/oauth/token'
2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.web.util.matcher.OrRequestMatcher  : matched
2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 1 of 11 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 2 of 11 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 3 of 11 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 4 of 11 in additional filter chain; firing Filter: 'LogoutFilter'
2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token'; against '/logout'
2017-09-11 23:13:00.073 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 5 of 11 in additional filter chain; firing Filter: 'BasicAuthenticationFilter'
2017-09-11 23:13:00.074 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.a.www.BasicAuthenticationFilter  : Basic Authentication Authorization header found for user 'webui'
2017-09-11 23:13:00.074 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.authentication.ProviderManager     : Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
2017-09-11 23:13:00.074 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.a.www.BasicAuthenticationFilter  : Authentication success: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@f964dd99: Principal: org.springframework.security.core.userdetails.User@6bc54e8: Username: webui; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: USER
2017-09-11 23:13:00.074 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 6 of 11 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2017-09-11 23:13:00.074 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 7 of 11 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2017-09-11 23:13:00.074 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 8 of 11 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2017-09-11 23:13:00.074 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.a.AnonymousAuthenticationFilter  : SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@f964dd99: Principal: org.springframework.security.core.userdetails.User@6bc54e8: Username: webui; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: USER'
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 9 of 11 in additional filter chain; firing Filter: 'SessionManagementFilter'
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] s.CompositeSessionAuthenticationStrategy : Delegating to org.springframework.security.web.authentication.session.ChangeSessionIdAuthenticationStrategy@540489cb
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 10 of 11 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token at position 11 of 11 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token'; against '/oauth/token'
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.a.i.FilterSecurityInterceptor    : Secure object: FilterInvocation: URL: /oauth/token; Attributes: [fullyAuthenticated]
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.a.i.FilterSecurityInterceptor    : Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@f964dd99: Principal: org.springframework.security.core.userdetails.User@6bc54e8: Username: webui; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: USER
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.access.vote.AffirmativeBased       : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@7a87dd9b, returned: 1
2017-09-11 23:13:00.075 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.a.i.FilterSecurityInterceptor    : Authorization successful
2017-09-11 23:13:00.076 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.a.i.FilterSecurityInterceptor    : RunAsManager did not change Authentication object
2017-09-11 23:13:00.076 DEBUG 54736 --- [nio-8443-exec-5] o.s.security.web.FilterChainProxy        : /oauth/token reached end of additional filter chain; proceeding with original chain
2017-09-11 23:13:00.077 DEBUG 54736 --- [nio-8443-exec-5] .s.o.p.e.FrameworkEndpointHandlerMapping : Looking up handler method for path /oauth/token
2017-09-11 23:13:00.078 DEBUG 54736 --- [nio-8443-exec-5] .s.o.p.e.FrameworkEndpointHandlerMapping : Returning handler method [public org.springframework.http.ResponseEntity<org.springframework.security.oauth2.common.OAuth2AccessToken> org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.postAccessToken(java.security.Principal,java.util.Map<java.lang.String, java.lang.String>) throws org.springframework.web.HttpRequestMethodNotSupportedException]
2017-09-11 23:13:00.078 DEBUG 54736 --- [nio-8443-exec-5] .o.p.p.ResourceOwnerPasswordTokenGranter : Getting access token for: webui
2017-09-11 23:13:00.078 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.authentication.ProviderManager     : Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
2017-09-11 23:13:00.079 DEBUG 54736 --- [nio-8443-exec-5] o.s.d.m.r.query.MongoQueryCreator        : Created query Query: { "userName" : "ales"}, Fields: null, Sort: null
2017-09-11 23:13:00.079 DEBUG 54736 --- [nio-8443-exec-5] o.s.data.mongodb.core.MongoTemplate      : findOne using query: { "userName" : "ales"} fields: null for class: class sixkiller.sample.domain.User in collection: user
2017-09-11 23:13:00.079 DEBUG 54736 --- [nio-8443-exec-5] o.s.data.mongodb.core.MongoDbUtils       : Getting Mongo Database name=[jogging]
2017-09-11 23:13:00.080 DEBUG 54736 --- [nio-8443-exec-5] o.s.data.mongodb.core.MongoTemplate      : findOne using query: { "userName" : "ales"} in db.collection: jogging.user
2017-09-11 23:13:00.166 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.a.dao.DaoAuthenticationProvider    : User 'ales' not found
2017-09-11 23:13:00.166  INFO 54736 --- [nio-8443-exec-5] o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error: InvalidGrantException, Bad credentials
2017-09-11 23:13:00.169 DEBUG 54736 --- [nio-8443-exec-5] o.s.s.w.a.ExceptionTranslationFilter     : Chain processed normally
2017-09-11 23:13:00.169 DEBUG 54736 --- [nio-8443-exec-5] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed

Unable to create the user

I am getting the below error while executing the below CURL:

C:\>curl -X POST https://localhost:8443/api/users -k -d '{"fullName":"Ales Novak","userName":"ales","password":"secret"}' -H 'Content-Type: application/json'
{"timestamp":1505151985452,"status":415,"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException","message":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported","path":"/api/users"}

curl: (6) Could not resolve host: application

mvn profiles doesn´t work

Hi there,

first of all, thanks for share this amazing projet.

I was trying to run this project using the command mvn spring-boot:run -Drun.profiles=https,localmongo, but got maven phase problems:
[ERROR] Unknown lifecycle phase ".profiles=https,localmongo".

And I was checking the code there are no references to application-https.properties, so how should I start with https ?

best regards,

Eduardo.

All your CURL commands doesn't works

Not sure why CURL command doesn't works ? If I execute the using browser then it works, but not sure why

curl -X GET https://localhost:8443/api -k doesn't works ?

C:\>curl -X GET https://localhost:8443/api -k curl: (7) Failed to connect to localhost port 8443: Connection refused

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.