ASP.Net で認証モジュールを作成しましたが、ロジックが高価であるため、リソースが匿名アクセス用に構成されている場合、認証モジュールのロジックを実行したくありません。
認証を必要としないページと同じディレクトリに認証が必要なページがあります。私はこれを制御できません。URLAuthorizationModule の前にリソースが匿名アクセスを許可するように構成されていることを確認する簡単な方法はありますか?
現在、私は「感じる」権利を行う次のことを行っています。どんな助けでも大歓迎です。
public static bool AllowEveryone()
{
bool rslt = false;
AuthorizationSection config = (AuthorizationSection)WebConfigurationManager.GetSection("system.web/authorization");
if (config.Rules != null && config.Rules.Count > 0)
{
AuthorizationRule r = config.Rules[0]; //doing this based on implementation of urlauthorization module in reflector...
if (r.Action == AuthorizationRuleAction.Allow && r.Users.Contains("*"))
{
return true;
}
//todo: check for allow anon ? case
}
return rslt;
}