|  | @@ -0,0 +1,32 @@
 | 
	
		
			
				|  |  | +'use strict';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +module.exports = options => {
 | 
	
		
			
				|  |  | +    return async function httpHeader(ctx, next) {
 | 
	
		
			
				|  |  | +        await next();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // CT-638506 避免获取用户敏感信息
 | 
	
		
			
				|  |  | +        ctx.set('X-Content-Type-Options', 'nosniff');
 | 
	
		
			
				|  |  | +        // CT-638385 点击劫持相关
 | 
	
		
			
				|  |  | +        // 禁止以iframe或者frame的形式嵌入 (deny/sameorign都可)
 | 
	
		
			
				|  |  | +        ctx.set('X-Frame-Options', 'deny');
 | 
	
		
			
				|  |  | +        // CT-638235
 | 
	
		
			
				|  |  | +        // 避免钓鱼欺骗 (启用XSS过滤器。如果检测到攻击,浏览器将不会清理页面,而是完全阻止页面的渲染)
 | 
	
		
			
				|  |  | +        ctx.set('X-XSS-Protection', '1; mode=block');
 | 
	
		
			
				|  |  | +        // 可以节省一次请求重定向(HSTS预加载服务,按指示提交域名后,浏览器将永不使用非安全方式链接)
 | 
	
		
			
				|  |  | +        ctx.set('strict-transport-security', 'max-age=31536000; includeSubDomains; preload');
 | 
	
		
			
				|  |  | +        //
 | 
	
		
			
				|  |  | +        const csp = [
 | 
	
		
			
				|  |  | +            'default-src', `'self' 'unsafe-inline' https://jiliang-qa.oss-cn-shenzhen.aliyuncs.com/ ${ctx.app.config.fujianOssPath} https://open.weixin.qq.com/ https://res.wx.qq.com/;`,
 | 
	
		
			
				|  |  | +            'img-src', `'self' data: blob: ${ctx.app.config.fujianOssPath};`,
 | 
	
		
			
				|  |  | +        ];
 | 
	
		
			
				|  |  | +        ctx.set('Content-Security-Policy', csp.join(' '));
 | 
	
		
			
				|  |  | +        // IE8以上版本用户,在下载时,不显示打开选项
 | 
	
		
			
				|  |  | +        ctx.set('X-Download-Options', 'noopen');
 | 
	
		
			
				|  |  | +        // 针对三方网站隐藏referer,防止隐私泄露和钓鱼攻击
 | 
	
		
			
				|  |  | +        // same-origin 同源则发送,反之不发送
 | 
	
		
			
				|  |  | +        // strict-origin 安全级别相同发送,反之不发送(例如https->http)
 | 
	
		
			
				|  |  | +        ctx.set('referer-policy', 'same-origin');
 | 
	
		
			
				|  |  | +        //
 | 
	
		
			
				|  |  | +        ctx.set('X-Permitted-Cross-Domain-Policies', 'master-only');
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +};
 |