-
Notifications
You must be signed in to change notification settings - Fork 1
#31 #44
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
base: master
Are you sure you want to change the base?
#31 #44
Conversation
@l3r8yJ could you review this? |
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.
@PavelRyauzov take a look, please
src/main/kotlin/ru/l3r8y/springxrolesauthoritiesstarter/filter/XRolesAuthenticationFilter.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/ru/l3r8y/springxrolesauthoritiesstarter/filter/XRolesAuthenticationFilter.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/ru/l3r8y/springxrolesauthoritiesstarter/filter/XRolesAuthenticationFilter.kt
Outdated
Show resolved
Hide resolved
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.
@PavelRyauzov a few more
|
||
@SpringBootApplication | ||
public class TestApplication { | ||
open class TestApplication |
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.
@PavelRyauzov open here is redundant, apply plugin to all classes, please
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 was inattentive, fixed it
val registration = FilterRegistrationBean(XRolesAuthenticationFilter()) | ||
registration.order = SecurityProperties.DEFAULT_FILTER_ORDER | ||
return registration |
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.
@PavelRyauzov try this
return FilterRegistrationBean(XRolesAuthenticationFilter()).apply {
this.order = SecurityProperties.DEFAULT_FILTER_ORDER
}
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.
cool, it looks more elegant, fixed this
class XRolesAuthenticationFilter : OncePerRequestFilter() { | ||
|
||
private companion object { | ||
private const val X_ROLES_HEADER = "X-Roles" |
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.
@PavelRyauzov when companion object is private there is no need to make it members private, as far as i know. Double check this one please
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 checked, you were right, fixed this
val header = request.getHeader(X_ROLES_HEADER) | ||
header ?: run { | ||
chain.doFilter(request, response) | ||
return | ||
} |
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.
@PavelRyauzov try this
val header = request.getHeader(X_ROLES_HEADER) ?: run { chain.doFilter(request, response); return }
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.
done
val authorized = SecurityContextHolder.getContext().authentication | ||
authorized ?: run { | ||
chain.doFilter(request, response) | ||
return | ||
} |
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.
@PavelRyauzov same here
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.
done
authorized.credentials, | ||
authorities | ||
) | ||
SecurityContextHolder.getContext().authentication = withXRoles |
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.
@PavelRyauzov try this
SecurityContextHolder.getContext().apply {
this.authentication = withXRoles
}
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.
done
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.
@l3r8yJ please look again
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.
lgtm now
@PavelRyauzov fix CI please, run |
@PavelRyauzov some news? |
@l3r8yJ done, fixed xml |
@@ -62,6 +62,8 @@ SOFTWARE. | |||
</ciManagement> | |||
<properties> | |||
<java.version>17</java.version> | |||
<kotlin.version>1.9.22</kotlin.version> |
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.
@PavelRyauzov lets use latest version of Kotlin?
closes #31
PR-Codex overview
This PR focuses on migrating Java code to Kotlin, enhancing the codebase's conciseness and readability while maintaining functionality. It also introduces a new
XRolesAuthenticationFilter
and updates endpoint handling with Kotlin's syntax.Detailed summary
XRolesAuthenticationFilter.java
.TestApplication.java
toTestApplication.kt
.Endpoints.java
toEndpoints.kt
, changing method signatures and authorization logic.Config.java
toConfig.kt
, simplifying security configuration.XRolesAuthenticationFilter.kt
with custom filtering logic.EndpointsTest.java
toEndpointsTest.kt
, updating test method signatures and assertions.pom.xml
to include Kotlin dependencies and configuration.pom.xml
.