Skip to content

synyx/spring-security-oauth-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple playground application using Spring Security with OAuth2 and JWT to

  • secure a resource with OAuth2
  • provide an endpoint to supply JWT access tokens to the resource

Usage:

  • run with
$ gradle bootRun
  • try to access resource w/o authorization, which will fail:
$ curl localhost:8080/foobar'
  • request OAuth2 access token by supplying user credentials:
$ curl -X 'POST'
    -u my_client_username:my_client_password
    --data "username=hdampf
        &password=wert123$
        &client_id=my_client_username
        &grant_type=password
        &scope=foobar_scope"
    localhost:8080/oauth/token

  • the endpoint replies with an access token, which is a Json Web Token (JWT) provided as a base64-encoded string
  • go to http://jwt.io/ and paste the token there to see its contents. the secret used is "foobar" (as set in AuthorizationServer)
  • access resource with access token:
$ curl -H "Authorization: Bearer $TOKEN" localhost:8080/foobar

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages