Browse Source

Use named arguments in Kotlin authorization rule

pull/8445/head
Adam Millerchip 6 years ago committed by Eleftheria Stein-Kousathana
parent
commit
16a7cbee4b
  1. 2
      config/src/main/kotlin/org/springframework/security/config/web/servlet/AbstractRequestMatcherDsl.kt
  2. 9
      config/src/main/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDsl.kt
  3. 9
      config/src/main/kotlin/org/springframework/security/config/web/servlet/RequiresChannelDsl.kt

2
config/src/main/kotlin/org/springframework/security/config/web/servlet/AbstractRequestMatcherDsl.kt

@ -37,7 +37,7 @@ abstract class AbstractRequestMatcherDsl { @@ -37,7 +37,7 @@ abstract class AbstractRequestMatcherDsl {
protected data class PatternAuthorizationRule(val pattern: String,
val patternType: PatternType,
val servletPath: String?,
val servletPath: String? = null,
override val rule: String) : AuthorizationRule(rule)
protected abstract class AuthorizationRule(open val rule: String)

9
config/src/main/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDsl.kt

@ -65,7 +65,9 @@ class AuthorizeRequestsDsl : AbstractRequestMatcherDsl() { @@ -65,7 +65,9 @@ class AuthorizeRequestsDsl : AbstractRequestMatcherDsl() {
* (i.e. "hasAuthority('ROLE_USER') and hasAuthority('ROLE_SUPER')")
*/
fun authorize(pattern: String, access: String = "authenticated") {
authorizationRules.add(PatternAuthorizationRule(pattern, PATTERN_TYPE, null, access))
authorizationRules.add(PatternAuthorizationRule(pattern = pattern,
patternType = PATTERN_TYPE,
rule = access))
}
/**
@ -86,7 +88,10 @@ class AuthorizeRequestsDsl : AbstractRequestMatcherDsl() { @@ -86,7 +88,10 @@ class AuthorizeRequestsDsl : AbstractRequestMatcherDsl() {
* (i.e. "hasAuthority('ROLE_USER') and hasAuthority('ROLE_SUPER')")
*/
fun authorize(pattern: String, servletPath: String, access: String = "authenticated") {
authorizationRules.add(PatternAuthorizationRule(pattern, PATTERN_TYPE, servletPath, access))
authorizationRules.add(PatternAuthorizationRule(pattern = pattern,
patternType = PATTERN_TYPE,
servletPath = servletPath,
rule = access))
}
/**

9
config/src/main/kotlin/org/springframework/security/config/web/servlet/RequiresChannelDsl.kt

@ -72,7 +72,9 @@ class RequiresChannelDsl : AbstractRequestMatcherDsl() { @@ -72,7 +72,9 @@ class RequiresChannelDsl : AbstractRequestMatcherDsl() {
* (i.e. "REQUIRES_SECURE_CHANNEL")
*/
fun secure(pattern: String, attribute: String = "REQUIRES_SECURE_CHANNEL") {
channelSecurityRules.add(PatternAuthorizationRule(pattern, PATTERN_TYPE, null, attribute))
channelSecurityRules.add(PatternAuthorizationRule(pattern = pattern,
patternType = PATTERN_TYPE,
rule = attribute))
}
/**
@ -93,7 +95,10 @@ class RequiresChannelDsl : AbstractRequestMatcherDsl() { @@ -93,7 +95,10 @@ class RequiresChannelDsl : AbstractRequestMatcherDsl() {
* (i.e. "REQUIRES_SECURE_CHANNEL")
*/
fun secure(pattern: String, servletPath: String, attribute: String = "REQUIRES_SECURE_CHANNEL") {
channelSecurityRules.add(PatternAuthorizationRule(pattern, PATTERN_TYPE, servletPath, attribute))
channelSecurityRules.add(PatternAuthorizationRule(pattern = pattern,
patternType = PATTERN_TYPE,
servletPath = servletPath,
rule = attribute))
}
/**

Loading…
Cancel
Save