Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK 2017

Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK 2017

Microservices are all the rage and being deployed by many Java Hipsters. If you’re working on a large team that needs different release cycles for product components, microservices can be a blessing. If you’re working at your VW Restoration Shop and running its online store with your own software, having five services to manage and deploy can be a real pain. Share your knowledge and experience about microservices in this informative and code-heavy talk.

You'll see how to use JHipster (a Yeoman generator) to create Angular + Spring Boot apps on separate instances with a unified front-end. I’ll also show you options for securing your API gateway and individual applications using JWT. Heroku, Kubernetes, Docker, ELK, Spring Cloud, Okta; there will be plenty of interesting demos to see!

Matt Raible

May 11, 2017

More Decks by Matt Raible

Other Decks in Technology


  1. View Slide

  2. View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. Conway’s Law
    Any organization that designs a system (defined
    broadly) will produce a design whose structure is a copy
    of the organization’s communication structure.
    Melvyn Conway 1967

    View Slide

  7. "Do one thing and do it well."

    View Slide

  8. The Future?

    View Slide

  9. You shouldn’t start with a microservices architecture.
    Instead begin with a monolith, keep it modular, and split
    it into microservices once the monolith becomes a
    Martin Fowler March 2014

    View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. start.spring.io

    View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. View Slide

  18. Microservices are awesome, but they’re not free.
    Les Hazlewood Stormpath CTO

    View Slide

  19. View Slide

  20. View Slide

  21. View Slide

  22. View Slide

  23. Securing Your API
    Choose the Right API Security Protocol
    Basic API Authentication with TLS (aka SSL)
    OAuth 1.0a, OAuth 2.0, OpenID Connect
    API Keys vs. Username/Password Authentication
    Store Your API Security Key securely
    Use globally unique IDs (e.g. Url62)
    Avoid sessions, especially in URLs

    View Slide

  24. JSON Web Tokens

    View Slide

  25. Create a JWT in Java
    String jwt = Jwts.builder()
    .setExpiration(new Date(1300819380))
    .claim("name", "Robert Token Man")
    .claim("scope", "self groups/admins")

    View Slide

  26. Validating a JWT
    String jwt = // get JWT from Authorization header
    Jws claims = Jwts.parser()
    String scope = claims.getBody().get("scope")
    assertEquals(scope, "self groups/admins");

    View Slide

  27. Better Secret
    String b64EncodedSecret =

    View Slide

  28. View Slide

  29. View Slide

  30. JHipster by the numbers
    +250 contributors
    +6800 Github stars
    +480,000 installations
    +150 companies officially using it

    View Slide

  31. How to use JHipster
    To install JHipster, you run an npm command:
    $ npm install -g generator-jhipster
    $ mkdir myapp && cd myapp
    $ yo jhipster

    View Slide

  32. What’s Generated?
    Spring Boot application
    Angular application
    Liquibase changelog files
    Configuration files

    View Slide

  33. Security Screens
    Several generated screens
    Login, logout, forgot password
    Account management
    User management
    Useful for most applications
    Pages must be tweaked
    User roles will be added/extended
    Provides good examples of working screens
    Forms, directives, validation…

    View Slide

  34. Admin Screens
    Spring Boot configuration
    Spring Security audits
    Log management
    Very useful in production

    View Slide

  35. Liquibase

    View Slide

  36. Microservices with JHipster

    View Slide

  37. View Slide

  38. JHipster on Google Cloud

    View Slide

  39. Microservices are not free, but you get a deep discount
    on microservices with JHipster.
    Matt Raible 2016

    View Slide

  40. JHipster.next
    JHipster CLI
    gRPC Support
    React Support
    Spring 5 and Reactive
    Improved Kafka Support

    View Slide

  41. View Slide

  42. Do one thing and do it well.
    Unix philosophy

    View Slide

  43. This Presentation and Demos

    View Slide

  44. View Slide

  45. View Slide

  46. Image Credits
    Fountain of colours - Paulius Malinovskis on Flickr
    Ponte dell’Accademia at Sunrise - Trey Ratcliff on Stuck in Customs
    Conway’s Law - Martin Fowler and James Lewis on Microservices
    Good Morning Denver - Sheila Sund on Flickr
    Monoliths - Arches National Park on Flickr
    Mexico - Trish McGinity on McGinity Photo
    Future - vivianhir on Flickr
    Spring Runoff - Ian Sane on Flickr
    The memory Seeker, Santa Monica Pier, CA - Pacheco on Flickr
    San Francisco By Night - Trish McGinity on McGinity Photo

    View Slide