-
Notifications
You must be signed in to change notification settings - Fork 741
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
Migration of various Groovy classes to Java #1663
Conversation
.registerModule(new JavaTimeModule()) | ||
|
||
return new JsonHttpMessageConverter(objectMapper) | ||
return new JsonHttpMessageConverter(objectMapperBuilder.build()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how many times I have to emphasize this, but Spring Boot offers this super useful builder class for making an ObjectMapper
, and you can configure default settings in the Spring properties somewhere. Thus, I've moved the feature flags to application.properties
on the classpath which Spring Boot picks up by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least in this commit, I don't see anything moving to application.properties. In this other commit I do see read-unknown-enum-values-as-null
set to true. I don't see an equivalent of .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
nor .registerModule(new JavaTimeModule()
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabling fail on unknown properties is a default setting in Jackson2ObjectMapperBuilder
. JavaTimeModule
is one of the "standard" Jackson modules that class looks for, too. See https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.html for more info.
@@ -210,12 +203,6 @@ class GateConfig extends RedisHttpSessionConfiguration { | |||
createClient "clouddriver", ClouddriverService | |||
} | |||
|
|||
@Bean | |||
@ConditionalOnProperty("services.keel.enabled") | |||
KeelService keelService(OkHttpClientProvider clientProvider) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a duplicate bean. There's another one defined later in this file without the OkHttpClientProvider
argument (which is ignored in this method anyways).
* can be pulled and forwarded in the AuthenticatedRequestFilter. | ||
*/ | ||
@Bean | ||
FilterRegistrationBean securityFilterChain( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now handled in application.properties
since all it was doing was reordering the spring security filter. That's a supported config property in Spring Boot, so no need to expose internal details of Spring Security!
ASN1OctetString octetString = ASN1OctetString.getInstance(bytes); | ||
var primitive = ASN1Primitive.fromByteArray(octetString.getOctets()); | ||
String string; | ||
if (primitive instanceof ASN1String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the Spinnaker docs say this needs to be a UTF-8 string, ASN.1 does support like a million other string types that Bouncycastle supports, and they all implement this interface. That is what their toString()
methods delegate to, though other ASN.1 types in BC don't necessarily print out machine-parseable data.
gate-core/src/main/groovy/com/netflix/spinnaker/gate/filters/FiatSessionFilter.java
Outdated
Show resolved
Hide resolved
@Mergifyio update |
✅ Branch has been successfully updated |
...rc/main/groovy/com/netflix/spinnaker/gate/config/PermissionRevokingLogoutSuccessHandler.java
Outdated
Show resolved
Hide resolved
gate-core/src/main/groovy/com/netflix/spinnaker/gate/config/AuthConfig.java
Outdated
Show resolved
Hide resolved
gate-core/src/main/groovy/com/netflix/spinnaker/gate/config/AuthConfig.java
Outdated
Show resolved
Hide resolved
gate-core/src/main/groovy/com/netflix/spinnaker/gate/security/anonymous/AnonymousConfig.java
Outdated
Show resolved
Hide resolved
gate-x509/src/main/groovy/com/netflix/spinnaker/gate/security/x509/X509Config.java
Outdated
Show resolved
Hide resolved
gate-x509/src/main/groovy/com/netflix/spinnaker/gate/security/x509/OidRolesExtractor.java
Outdated
Show resolved
Hide resolved
And add some tests that generate certificates directly.
Broken up into several commits, I've ported over several Groovy classes to Java. Included is a small simplification to how
AuthConfig
works for setting up theWebSecurity
builder object as that can be done via a customizer. An equivalent approach to simplifying the setup forHttpSecurity
would require a much larger change as all the authentication configuration classes would need to migrate fromWebSecurityConfigurerAdapter
to instead defineSecurityFilterChain
beans which compose more easily than the existing approach (Spring Security doesn't let you use both approaches at the same time).In the
OidRolesExtractor
migration, I've also simplified the use of Bouncycastle APIs slightly as they define convenience methods that do the same thing as what was done in the Groovy code but with less verbosity. I did some research into the particular OID from the test and documentation, and amusingly enough, that same OID is already used for some power management authentication standard, but we don't seem to encode role info even remotely similar to that. While there's some RFC about defining roles and such in certificates, these seem to apply to what's known as an "attribute certificate" which is separate from a normal X.509 certificate (Bouncycastle includes ASN.1 classes for that RFC). Anyways, I made the role parsing more explicit there as relying ontoString()
for implementation details is not ideal (not every ASN.1 class from BC implements a usefultoString()
here, but we do expect string data).