Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Rewrite the CoffeeNet integration code for Spring Boot 2.x #67

Open
wants to merge 61 commits into
base: master
Choose a base branch
from

Conversation

punycode
Copy link
Member

A lot of the integration code in CoffeeNet has to be revamped for a move towards Spring Boot 2.x.

The actual parts of the code base and how to address them still needs to be done. We will update the ticket description while doing so.

derTobsch and others added 5 commits February 16, 2020 17:05
The Spring Boot 2.x migration will be a rewrite, so we will keep the
previous code next to the new version while migrating. Since this will
need a different set of Maven dependencies, the complete management POMs
will be replicated into a `legacy/` subfolder.
To not collide accidentally while refactoring, the complete
autoconfigure and actuator code in the `legacy/` folder has now a
`.legacy` inserted into the package hierarchy.
@punycode punycode linked an issue Feb 16, 2020 that may be closed by this pull request
The next release will be a REAL major version. This change was brought
to you by:

```
$ ./mvnw versions:set -DnewVersion=2.0.0-SNAPSHOT -DprocessAllModules=true
```
Multiple parts of CoffeeNet contribute UI/UX components to the final
application. This abstraction allows to write these in a
technology-agnostic way.
To enable more CoffeeNet autoconfiguration possibilities, we need to
hook into the process of defining global `SecurityConfigurer` beans,
that are applied to instances of `WebSecurityConfigurerAdapter`.
This makes use of the feature from the previous commit, to automatically
configure features on instances of `WebSecurityConfigurerAdapter`, if
certain conditions are met. In this case, we auto-enable OAuth2.
Mirroring `SecurityAutoConfiguration` from Spring Boot, this class will
be used only for servlet based environments. We will later add a
reactive variant.
In the previous CoffeeNet iteration a profile for the currently logged
in user could be retrieved via an exposed service. Most of the time this
feature is needed for frontend work. Therefore we implement this
reworked implementation via the Spring mechanism of a
`HandlerMethodArgumentResolver`.

This commit adds the needed auto-configuration as also an implementation
for OAuth2/OIDC.
Since the `PrincipalCoffeeNetProfileMapper` is explicitly intended to
work with implementation of `java.security.Principal` we can reflect
this in the method signature.
The `DefaultCoffeeNetProfile` is a default implementation, that cannot
instantiated or subclassed and is only constructable by a builder. We
move the builder to the actual `CoffeeNetProfile` interface and hide
the default implementation at the package level.
Since we want to encourage usage of JUnit 5 all across the CoffeeNet
projects, we exclude it by default from the transitive dependencies of
`spring-boot-starter-test`. This way JUnit 4 annotations and classes
will not be available.
Since we may want to serialize the domain interfaces to JSON, we should
add consistent naming for the resulting JSON keys emitted.
In prepartion for WebFlux support, we move the configuration for the
`CoffeeNetProfileMapper` into the parent package.
This commit adds auto-configuration for WebFlux based applications in
the same manner, that servlet based applications are instrumented.
Specifically it adds auto-configuration for OAuth2 authentication on all
WebFlux `ServerHttpSecurity` instances and the method argument
resolution of `CoffeeNetProfile` for those applications.
punycode and others added 2 commits April 27, 2020 03:52
@punycode punycode mentioned this pull request May 23, 2020
@punycode punycode force-pushed the spring-2-rewrite branch 4 times, most recently from 7951d4e to d2ac336 Compare May 24, 2020 00:39
To ease prototyping features with the rewrite we start publishing the
`spring-2-rewrite` branch to Sonatype OSS snapshot repository too.
Instead of listing all `coffeenet-starter*` dependencies manually, we
simply can add all starter artifacts by iterating over existing
subprojects and adding those who match the name pattern.
We ensure in our build configuration to produce Java 8+ compatible
artifacts. But Sonaqube is complaining if the Java version used for the
build is 1.8, so we switch the build to actually use Java 11.
Spring Cloud Hoxton.SR5+ are now only supported on Spring Boot 2.3+.
@sonarcloud
Copy link

sonarcloud bot commented Aug 2, 2020

SonarCloud Quality Gate failed.

Bug C 3 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 9 Security Hotspots to review)
Code Smell A 20 Code Smells

69.1% 69.1% Coverage
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Jul 26, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 3 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 3 Security Hotspots
Code Smell A 20 Code Smells

69.1% 69.1% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Update auf Spring Boot 2
2 participants