Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use Feature-Policy header name for now
In 90e710d the FeaturePolicy middleware
was renamed to PermissionsPolicy as this will be new name of the header
as used by browsers.
The Permissions-Policy header requires a different implementation and
isn't yet supported by all browsers. To avoid having to rename the
middleware in the future, we keep the new name for the Middleware, but
use the old implementation and header name.
  • Loading branch information
p8 committed Nov 19, 2020
1 parent 151bce1 commit 2e07915
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion actionpack/lib/action_dispatch/http/permissions_policy.rb
Expand Up @@ -6,7 +6,12 @@ module ActionDispatch #:nodoc:
class PermissionsPolicy
class Middleware
CONTENT_TYPE = "Content-Type"
POLICY = "Permissions-Policy"
# The Feature-Policy header has been renamed to Permissions-Policy.
# The Permissions-Policy requires a different implementation and isn't
# yet supported by all browsers. To avoid having to rename this
# middleware in the future we use the new name for the middleware but
# keep the old header name and implementation for now.
POLICY = "Feature-Policy"

def initialize(app)
@app = app
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/dispatch/permissions_policy_test.rb
Expand Up @@ -137,6 +137,6 @@ def permissions_policy=(policy)

def assert_policy(expected)
assert_response :success
assert_equal expected, response.headers["Permissions-Policy"]
assert_equal expected, response.headers["Feature-Policy"]
end
end
6 changes: 3 additions & 3 deletions railties/test/application/permissions_policy_test.rb
Expand Up @@ -34,7 +34,7 @@ def index
app("development")

get "/"
assert_nil last_response.headers["Permissions-Policy"]
assert_nil last_response.headers["Feature-Policy"]
end

test "global permissions policy in an initializer" do
Expand Down Expand Up @@ -124,7 +124,7 @@ def index

get "/"
assert_equal 200, last_response.status
assert_nil last_response.headers["Permissions-Policy"]
assert_nil last_response.headers["Feature-Policy"]
end

test "override permissions policy using different directives in a controller" do
Expand Down Expand Up @@ -185,7 +185,7 @@ def index
private
def assert_policy(expected)
assert_equal 200, last_response.status
assert_equal expected, last_response.headers["Permissions-Policy"]
assert_equal expected, last_response.headers["Feature-Policy"]
end
end
end

0 comments on commit 2e07915

Please sign in to comment.