Adding HTTP security headers to WSO2 APIM (4.1.0) via deployment.toml config

I have followed : adding security headers in wso2am-4.0.0 (sts & csp & referer headers) to add the header config to the control plane and it is working ( carbon portal, dev portal and publisher).

I added the same config in the gateway profile node but its not getting applied to my APIs deployed in the gateway.

Is there a global configuration that I can add to the gateway that will apply the http security headers to all APIs ( without going for custom header policies)

You can add a global mediation policy to add these headers.

  1. Create a file called WSO2AM–Ext–Out.xml.
  2. Add the following content and place the file in the location – wso2am-4.1.0/repository/deployment/server/synapse-configs/default/sequences.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--Out">

    <property name="header1" value="val1" scope="transport" />
    <property name="header2" value="val2" scope="transport" />

</sequence>
  1. Add the following configurations into the deployment.toml in wso2am-4.1.0/repository/conf/.
[apim.sync_runtime_artifacts.gateway.skip_list]
sequences = ["WSO2AM--Ext--Out.xml"]

0

Accepted answer works for success API calls. Below is with fault cases also

Create a file called _Set_HTTPSecurityHeaders_.xml

Add the following content and place the file in the location – AM410_GW_HOME/repository/deployment/server/synapse-configs/default/sequences

<sequence name="_Set_HTTPSecurityHeaders_" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <property name="Strict-Transport-Security" value="max-age=63072000; includeSubDomains; preload" action="set" scope="transport"/>
    <property name="X-Content-Type-Options" value="nosniff" action="set" scope="transport"/>
    <property name="X-Frame-Options" value="DENY" action="set" scope="transport"/>
    <property name="X-XSS-Protection" value="1" action="set" scope="transport"/>
</sequence>

Create a file called WSO2AM–Ext–Out.xml

Add the following content and place the file in the location – AM410_GW_HOME/repository/deployment/server/synapse-configs/default/sequences

<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--Out">
    <sequence key="_Set_HTTPSecurityHeaders_"/>
</sequence>

Add following line at the end of AM410_GW_HOME/repository/deployment/server/synapse-configs/default/sequences/_cors_request_handler_.xml line num ~ 35 after filter

<sequence key="_Set_HTTPSecurityHeaders_"/>

Add following line before any send mediator in AM410_GW_HOME/repository/deployment/server/synapse-configs/default/sequences/main.xml

<sequence key="_Set_HTTPSecurityHeaders_"/>

Add the following configurations into the deployment.toml

[apim.sync_runtime_artifacts.gateway.skip_list]
sequences = ["WSO2AM--Ext--Out.xml", "_Set_HTTPSecurityHeaders_.xml"]

If this configuration is successful all APIs in the gateway will have http security response headers for success/failure (e.g. 2xx, 401, 403, 405, 500) responses.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật