HTTPS跳转框架HTTP Security--Asp.net和ASP.NET MVC下可自由配置URL的HTTPS跳转框架

简介

一个简单易扩展的HTTP跳转HTTPS的框架。由配置文件配置规则,然后在HTTPMODULE里截获请求进行规则验证是否跳转HTTPS.

组成:

  1. web.config,用来配置规则
  2. HttpsConfiguration,用于读取配置文件
  3. HttpSecurityModule,用来截获请求触发规则验证
  4. RequestProcessor,用既有规则验证请求
  5. PathsMatcher,多路径(URL)匹配器
  6. PathMatcher,单URL路径匹配器
  7. PathMatcherFactory,用于创建StartsWith或Exact具体URL路径,可进行更多扩展,如正则表达式匹配。
  8. SecureRedirection,跳转HTTPS

WEB.CONFIG

<configSections>
    <section name="HttpsConfiguration" type="ICStars2_0.Common.ConfigSections.HttpsConfiguration, ICStars2_0.Common, Version=1.0.0.0, Culture=neutral" />

  </configSections>
 <HttpsConfiguration mode="On">
    <paths>
      <add path="/Test" />
      <add path="/Account" security="Ignore" />
      <add path="/Account/Check.aspx" matchType="Exact" />
      
      <add path="/Member" matchType="StartsWith" />
    </paths>
  </HttpsConfiguration>

mode选项On/Off, 开启或不开启HTTPS跳转

<add path=""/>, 添加一个URL验证规则。 默认security="Secure"并且matchType="StartsWith"

<add path="" security="" matchType="" />,添加一个URL验证规则并设置具体选项。security选项Secure/Ignore,进行HTTPS跳转或忽略当前设置。matchType选项Exact/StartsWith,进行完全匹配或仅匹配开始字串。


HttpsConfiguration

namespace ICStars2_0.Common.ConfigSections
{
    public enum Mode
    {
        On,
        Off
    }
   
    public enum RequestSecurity
    {
        Secure,
        Ignore
    }
   
    public enum PathMatchType
    {
       
        Exact,
        StartsWith
    }
    internal sealed class ElementNames
    {
        internal const string Mode = "mode";

        internal const string Paths = "paths";
        internal const string MatchType = "matchType";
        internal const string Path = "path";
        internal const string Security = "security";
    }
    public class HttpsConfiguration : ConfigurationSection
    {
        [ConfigurationProperty(Elem
  • 7
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 14
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值