Skip to content

Commit

Permalink
Deprecate feature-policy where not already deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
eleftherias authored and Ayush Kohli committed Aug 25, 2021
1 parent 9ebb074 commit 526ae79
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2420,7 +2420,9 @@ public HeaderSpec contentSecurityPolicy(Customizer<ContentSecurityPolicySpec> co
* Configures {@code Feature-Policy} response header.
* @param policyDirectives the policy
* @return the {@link FeaturePolicySpec} to configure
* @deprecated Use {@link #permissionsPolicy(Customizer)} instead.
*/
@Deprecated
public FeaturePolicySpec featurePolicy(String policyDirectives) {
return new FeaturePolicySpec(policyDirectives);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -137,6 +137,7 @@ class ServerHeadersDsl {
*
* @param policyDirectives policyDirectives the security policy directive(s)
*/
@Deprecated("Use 'permissionsPolicy { }' instead.")
fun featurePolicy(policyDirectives: String) {
this.featurePolicyDirectives = policyDirectives
}
Expand All @@ -163,6 +164,7 @@ class ServerHeadersDsl {
disabled = true
}

@Suppress("DEPRECATION")
internal fun get(): (ServerHttpSecurity.HeaderSpec) -> Unit {
return { headers ->
contentTypeOptions?.also {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -161,6 +161,7 @@ class HeadersDsl {
*
* @param policyDirectives policyDirectives the security policy directive(s)
*/
@Deprecated("Use 'permissionsPolicy { }' instead.")
fun featurePolicy(policyDirectives: String) {
this.featurePolicyDirectives = policyDirectives
}
Expand All @@ -174,7 +175,7 @@ class HeadersDsl {
* header in the response using the supplied policy directive(s).
* <p>
*
* @param policyDirectives policyDirectives the security policy directive(s)
* @param permissionsPolicyConfig the customization to apply to the header
*/
fun permissionsPolicy(permissionsPolicyConfig: PermissionsPolicyDsl.() -> Unit) {
this.permissionsPolicy = PermissionsPolicyDsl().apply(permissionsPolicyConfig).get()
Expand All @@ -199,6 +200,7 @@ class HeadersDsl {
disabled = true
}

@Suppress("DEPRECATION")
internal fun get(): (HeadersConfigurer<HttpSecurity>) -> Unit {
return { headers ->
defaultsDisabled?.also {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -121,6 +121,7 @@ class ServerHeadersDslTests {

@EnableWebFluxSecurity
@EnableWebFlux
@Suppress("DEPRECATION")
open class FeaturePolicyConfig {
@Bean
open fun springWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -84,6 +84,7 @@ class HeadersDslTests {
}

@EnableWebSecurity
@Suppress("DEPRECATION")
open class FeaturePolicyConfig : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
http {
Expand Down

0 comments on commit 526ae79

Please sign in to comment.