Giter Site home page Giter Site logo

spring-addons's Introduction

Ease OAuth2 / OpenID Configuration & Tests in Spring Boot 3

Useful links

Breaking News

Just added a Sponsor this project link to the repo ;-)

The OAuth2 BFF tutorial is now on Baeldung. It was deeply refreshed in the process and now contains samples for Angular, React (Next.js) and Vue (Vite).

In 7.6.0, the experimental support for RestClient and WebClient builders as well as @HttpExchange (the successor of @FeignClient) is moved to a dedicated starter: spring-addons-starter-rest. As a reminder, it helps to get pre-configured client builders and @HttpExchange proxies with this clients

7.5.0 comes with an important refactoring of the way JWT decoder(s) configuration is resolved. This greatly eases "dynamic" multi-tenant scenarios implementation. The only noticeable breaking change is the removal of SpringAddonsOidcProperties::getOpProperties. This feature is now the responsibility of the newly introduced OpenidProviderPropertiesResolver. The default implementation resolves properties with an exact match on issuer (just as getOpProperties was doing). As usual, auto-configured bean backs-off if you expose one to use another properties resolving strategy.

Important warning for those using @WithJwt (and since 7.3.0, @WithMockJwtAuth) but not spring-addons-starter-oidc: you should expose your JWT converter as a bean. See spring-addons-oauth2-test README for details.

With spring-addons-starter-oidc, you might need 0 Java conf, even in scenarios like:

  • accepting tokens issued by several trussted authorization servers
  • mapping authorities from a variety of claims
  • needing custom OAuth2 redirection URI or HTTP status
  • having per environment CORS configuration (not allowing the same origins in staging and prod for instance)
  • exposing CSRF token as a cookie accessible to a single-page application
  • logging out from an authorization server not strictly implementing RP-Initiated Logout (case of Auth0 and Amazon Cognito for instance)
  • adding extra parameters to authorization or token requests (like the audience required by Auth0)

Unit & Integration Testing With Security

Testing access control requires to configure the test security context. For that, spring-security-test provides with MockMvc request post-processors and WebTestClient mutators, but this can work only in the context of a request, which limits its usage to controllers.

To test any type of @Component (@Controller, off course, but also @Service and @Repository) there are only two options:

  • build tests security context by yourself and populate it with stubbed / mocked authentications
  • use annotations to do it for you (this is where spring-addons-oauth2-test jumps in)

Useful resources:

spring-addons's People

Contributors

ch4mpy avatar apucher avatar kwonglau avatar lartiquel avatar giovannicandido avatar lmller avatar mmiikkkkaa avatar ptemplier avatar tvogel8570 avatar weehongkoh avatar nexus061 avatar yennor avatar

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.