Use named arguments in Kotlin authorization rule
This commit is contained in:
parent
401393d756
commit
16a7cbee4b
|
@ -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)
|
||||
|
|
|
@ -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() {
|
|||
* (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))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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() {
|
|||
* (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…
Reference in New Issue