标签: authorization

如何保护asp.net MVC中的目录?

在asp.net mvc中保护目录最简单的方法是什么?

目前我有一个misc文件的文件夹,属于该网站的众多用户.理想情况下,我不希望一个用户能够在浏览器中键入其中一个文档的URL并且可以访问它.这些文件只能通过控制器操作下载,该操作将通过验证用户凭据然后返回文件来授权下载.

提前致谢

iis asp.net-mvc authorization

2
推荐指数
1
解决办法
783
查看次数

如何以编程方式测试Spring Security中的URL授权?

我在JSF 2应用程序中使用Spring security 3.0.5.

为了在我的导航菜单中为不允许访问它们的用户停用/隐藏条目,我需要一种方法来以编程方式测试当前登录的用户是否被允许访问给定的URL.

最简单的方法是什么?

authorization spring-security

2
推荐指数
1
解决办法
1898
查看次数

自定义授权属性

我正在实现CustomAuthorizeAttribute.我需要获取正在执行的操作的名称.如何在AuthorizeCore函数中获取当前操作名称的名称?

asp.net-mvc authorization

2
推荐指数
1
解决办法
2816
查看次数

Rails cancan load_and_authorize_resource无法正常工作

我承诺定制一个具有cancan认证的项目.我的康康舞ability.rb

if user.has_role? :super_admin
  can :manage, :all
elsif user.has_role? :site_admin
  can :manage, [User, Listing]
elsif user.has_role? :manager
  can :manage, Listing, :user_id => user.id
end
Run Code Online (Sandbox Code Playgroud)

我的模特:

User

Listing has_many :listing_types

ListingType belongs_to :listing

现在我创建了一个新模型 ListingDetail belongs_to :listing

控制器listing_details,load_and_authorize_resource 当我从经理角色访问此页面时,它重定向到登录页面(在我的管理命名空间的索引控制器的索引操作中,我重定向到nil用户的登录页面)为什么会发生这种情况?

authorization cancan ruby-on-rails-3

2
推荐指数
1
解决办法
1850
查看次数

User.IsInRole错误

我里面的这段代码Page_LoadSite.Master.cs.

if(User.IsInRole("Read"))
{
   NavigationMenu.Visible = false;
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

非静态字段,方法或属性'Microsoft.VisualBasic.ApplicationServices.User.IsInRole(string)需要对象引用.

有线索吗?

c# asp.net authorization

2
推荐指数
1
解决办法
1713
查看次数

想要在不使用samAccountName或DirectoryServices.AccountManagement的情况下查找AD组的SID

题:

在C#中,有没有办法在使用DirectoryServices.AccountManagement库或icky-ugly LDAP的情况下查找Active Directory组SID ?

[更新] - 为什么我问:

[Authorize]属性和底层WindowsPrincipal.IsInRole(string role)只检查samAccountNameAD中的内容.

这不仅是Microsoft在检查角色时建议避免的遗留标识符:

// It is also better from a performance standpoint than the overload that accepts a string. 
// The aformentioned overloads remain in this class since we do not want to introduce a 
// breaking change. However, this method should be used in all new applications and we should document this.
public virtual bool IsInRole (SecurityIdentifier sid) {} …
Run Code Online (Sandbox Code Playgroud)

c# authentication asp.net-mvc authorization active-directory

2
推荐指数
1
解决办法
6730
查看次数

如何通过直接在zend框架中输入url来限制学生和教师访问每个页面?

localhost.test/teacher/marklist- teacher是控制器和标记列表是视图页面.

student登录并输入上述url显示该页面.怎么预防这个?

php authorization zend-framework zend-framework2

2
推荐指数
1
解决办法
132
查看次数

如何在JBoss 7中设置EJB方法的默认角色?

我有一个带有多个EJB JAR的EAR,它们应该通过一个非常简单的身份验证机制来保护:只要他/她经过身份验证,每个用户都可以访问每个EJB方法.所以我通过将文件添加security-domain到EAR中来保护EAR文件jboss-app.xml:

<jboss-app>
  <security-domain>my-security-domain</security-domain>
</jboss-app>
Run Code Online (Sandbox Code Playgroud)

用户使用JBoss默认users.properties文件进行身份验证.在JBoss 4.2.3中,这很好用.现在在JBoss 7中我得到一个授权例外:

16:45:32,791 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 2) JBAS014134: EJB Invocation failed on component MyServiceBean for method public abstract java.util.List mypackage.MyService.findAllFoo(): javax.ejb.EJBAccessException: JBAS014502: Invocation on method: public abstract java.util.List mypackage.MyService.findAllFoo() of bean: MyServiceBean is not allowed
Run Code Online (Sandbox Code Playgroud)

设置记录类别后,org.jboss.securityTRACE我发现,那JBoss的7显然需要一个默认<NOBODY>每个EJB方法的角色,当另有规定没有明确的作用.从日志:

16:45:32,791 TRACE [org.jboss.security.audit] (EJB default - 2) [Failure]Source=org.jboss.security.plugins.javaee.EJBAuthorizationHelper;Action=authorization;Exception:=PBOX000017: Acces denied: authorization failed ;Resource:=[org.jboss.security.authorization.resources.EJBResource:contextMap={policyRegistration=null}:method=public abstract java.util.List mypackage.MyService.findAllFoo():ejbMethodInterface=Remote:ejbName=MyServiceBean:ejbPrincipal=rschneider:MethodRoles=Roles(<NOBODY>,):securityRoleReferences=null:callerSubject=Betreff:
    Principal: org.jboss.remoting3.security.UserPrincipal@ce844325
    Principal: Roles(members:user)
    Principal: CallerPrincipal(members:org.jboss.remoting3.security.UserPrincipal@ce844325)
:callerRunAs=null:callerRunAs=null:ejbRestrictionEnforcement=false:ejbVersion=2.0];policyRegistration=null;
Run Code Online (Sandbox Code Playgroud)

然后我尝试将角色映射配置到JBoss中,以便每个用户都映射到此 …

java authentication authorization jboss7.x

2
推荐指数
1
解决办法
6505
查看次数

OAuth 2中的授权代码仅在客户端应用程序运行服务器的生命周期中使用一次吗?

我正在阅读关于OAuth2如何工作的博客.这是一个很好的来源,我想我已经理解了OAuth2如何工作的基础知识.

在阅读时Authorization grant,涉及授予对应用服务器(我的服务器)的访问权限,该服务器通过注册的重定向URI交换从授权服务器(例如,facebook)接收的授权代码.

myserver然后交换此access_token和刷新令牌的授权码.当访问令牌过期时,刷新令牌用于获取新的访问令牌.

Q1)从这个流程中,我看到facebook提供的授权代码只在我的服务器上使用一次才能获得access_token.对于后续请求,不使用此授权代码.它是否正确 ?

如果用户在访问令牌过期的3天后登录我的服务器,我的服务器将使用刷新令牌获取新的访问令牌并使用此访问令牌.

Q2)刷新令牌是否过期或每次使用刷新令牌获取新的访问令牌时,是否提供了新的刷新令牌?

authorization facebook oauth oauth-2.0

2
推荐指数
1
解决办法
762
查看次数

HttpClient授权标头格式无效

当我尝试GET使用下面的地址和授权值进行请求时,我没有任何问题。

地址:http//example.com/xyz.svc/branches/?latitude = 0&longitude = 0&range = 20000

标头密钥:授权

值:example; foo

当我尝试使用时,HttpCLient出现授权标头值的格式无效错误

这就是我尝试的方式

HttpClient client = new HttpClient();

    string latitude = "0";
    string longitude = "0";
    string range = "2000";

    string uri = "/xyz.svc/branches/?latitude=0&longitude=0&range=20000;

    string value = "foo";

    client.BaseAddress = new Uri("http://example.com");
    client.DefaultRequestHeaders.Accept.Clear();
    client.DefaultRequestHeaders.Accept.Add(
        new MediaTypeWithQualityHeaderValue("application/json"));
    client.DefaultRequestHeaders.Add("Authorization", String.Format("example;{0}", value));

    HttpResponseMessage response = await client.GetAsync(uri);

    var responseJson = await response.Content.ReadAsStringAsync();

    Console.WriteLine(responseJson);
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

c# authorization dotnet-httpclient

2
推荐指数
1
解决办法
992
查看次数