我正在为基金/养老金经理制定系统架构.我们提供两个ASP.NET MVC Web应用程序; 一个允许养老基金的成员登录和检查他们的余额,管理他们的投资等,另一个允许雇主代表雇员(成员)向基金捐款.还有通过Intranet提供的内部应用程序.
我们一直在考虑使用Active Directory来存储,认证/授权不仅是内部用户(已经使用AD登录域和资源授权),而是用于成员和雇主用户帐户.成员和雇主用户帐户将位于内部用户的不同层次结构(甚至可能是不同的AD实例?)中.
但是我想知道这是否是AD的最佳用例......鉴于AD是一种"内部"资源,它是否应该用于保存"外部"用户的auth详细信息(替代方案是数据库中的USERS表) )?
好处是:AD专为保存此类数据而设计和优化,ASP.NET应用程序可轻松集成AD授权,可能存在用于处理数据的现有工具(密码重置等).
有什么风险?
architecture authentication authorization web-applications active-directory
这是我写的一个递归函数,用于确定给定用户是否有权查看页面上的内容.它基本上以下列方式调用:
if(authorize($_SESSION['user']['user_id'], $necessaryClearance)){
//Output restricted content
} else{
//Inform user they are not authorized
}
Run Code Online (Sandbox Code Playgroud)
每个用户都有清关级别和清关状态.这允许使用$ clearance作为用户必须匹配或击败的许可级别,用户必须匹配的许可状态或一组状态(用户可以匹配的任何一个)来调用授权功能.通常,$ user_id是从会话数据中提取的($ _SESSION ['user'] ['$ user_id'],每次页面加载时从数据库刷新),并且每页或每个显式设置清除 - 模块基础.
//This function checks if the user is authorized to view the page
//It returns 1 if access is granted and a 0 if access is denied
function authorize($id, $clearance){
//$clearance == array
if (is_array($clearance)){
//if yes Iterate array through Authorize($id, $clearance[])
foreach($clearance as $userStatus){
$tally += authorize ($id, $userStatus);
}
return $tally;
//if no check if …Run Code Online (Sandbox Code Playgroud) 我已经静态地允许使用带有角色的标准Authorize属性来访问控制器/操作方法.我使用默认的ASP.Net成员资格提供程序.
我们的一位客户希望获得更细粒度的访问控制.他们希望能够动态分配哪些角色可以访问哪些控制器/操作等.我已经看到答案说实现CustomAuthorize属性.
只是想知道是否有任何工具包等.这似乎是一个合理的标准功能.我想这样的事情http://kbochevski.blogspot.com/2009/11/mvc-custom-authorization.html
这是一个更多的问题,而不是解决特定问题的问题.
我第一次使用CakePHP,现在正在开发网站的管理部分.
作为MVC或CakePHP开发人员,您喜欢把管理功能放在哪里?
最初我将它们放在AdminController中,但后来改为将函数放在一个控制器中,该控制器用于被操作的数据类型.例如,我将用户列表/编辑放在UserController中.
对我来说这更有意义,因为UserController中可能存在可能有用的功能.
如果你留下回复,请你说几句话说明原因?也许这是一个有争议的问题.
小心,李
- 编辑
if ($this->Auth->user('user_type') == 1){//double-check the user is Admin
$this->Auth->allow('display');
$this->Auth->allow('watch');
Run Code Online (Sandbox Code Playgroud) 我一直在寻找一些帮助,为我的应用程序创建授权,让它以root身份运行一些shell脚本.我查看了Apple文档(当然用OBJ-C编写并且非常含糊),我正在尝试使用Swift中的代码示例.
我正在运行该AuthorizationCreate函数的错误:
var authRef: AuthorizationRef
let osStatus = AuthorizationCreate(nil, nil, kAuthorizationFlagDefaults, &authRef)
Run Code Online (Sandbox Code Playgroud)
'Int' is not convertible to 'AuthorizationFlags'
我只是想跟随以下文档中的代码片段:https://developer.apple.com/library/mac/documentation/Security/Conceptual/authorization_concepts/03authtasks/authtasks.html#//apple_ref/doc/UID/TP30000995-CH206-TP9
我kAuthorizationFlagDefaults从这里找到了常数:https://developer.apple.com/library/mac/documentation/Security/Reference/authorization_ref/#//apple_ref/doc/constant_group/Authorization_Options
如果重要的话,我在10.10.1中跑步.
我已经看到了使用AppleScript的解决方案,但我真的想避免这种情况.
我正在尝试在activemq中使用授权,但是现在停滞了一段时间。
这是我的Java代码,删除授权插件后一切正常。我正在尝试创建一个名为“ room2”的主题。
Context jndiContext = new InitialContext();
ConnectionFactory connectionFactory;
connectionFactory = (ConnectionFactory) jndiContext
.lookup("ConnectionFactory");
connection = connectionFactory.createConnection("system", "manager");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic t = session.createTopic("room2");
Run Code Online (Sandbox Code Playgroud)
这是我的activemq.xml:
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="system" password="manager"
groups="admins,publishers,consumers"/>
<authenticationUser username="user" password="password"
groups="admins,users,publishers"/>
<authenticationUser username="guest" password="password" groups="guests"/>
</users>
</simpleAuthenticationPlugin>
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry topic="room2" read="consumers" write="publishers" admin="admins" />
</authorizationEntries>
</authorizationMap>
</map>
</authorizationPlugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
User system is not authorized to create: topic://ActiveMQ.Advisory.Connection
Run Code Online (Sandbox Code Playgroud)
如果我使用<authorizationEntry topic=">" read="consumers" write="publishers" admin="admins" />,那么它可以正常工作,那么究竟是什么>意思呢?
我试图通过身份服务器让我的脑袋脱离云端.
我想实现身份服务器项目以进行身份验证
在这篇博文中,我已经阅读了一些关于客户的细节.作者简单地说:
OAuth 2为不同的用例提供了几种"授权类型".定义的授权类型是:
- 在Web服务器上运行的应用程序的授权代码
- 隐含于基于浏览器或移动应用程序
- 使用用户名和密码登录的密码
- 应用程序访问的客户端凭据
授权码和隐式之间有什么区别?这是否意味着隐式应该用于例如javascript代码?
说我需要:
另外一个问题,我想基于Bearer Token和简单的apiKey在我的web api中实现授权.这两种类型都可以融合吗?如何使用Identity Server实现apiKey?
非常感谢,如果这些都是愚蠢的问题,请原谅.
authorization oauth-2.0 thinktecture-ident-server identityserver3 identityserver4
我不需要Admin角色,所以我只需要执行身份验证.
@Configuration
@EnableWebSecurity
protected static class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private DataSource dataSource;
@Autowired
private MyAuthenticationSuccessHandler authenticationSuccessHandler;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage("/login")
.successHandler(authenticationSuccessHandler).failureUrl("/login?error").permitAll().and().logout()
.permitAll();
http.csrf().disable();
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery("select login, password, enabled from users where login=?");
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我尝试运行它时,我得到了
org.springframework.security.authentication.InternalAuthenticationServiceException: PreparedStatementCallback; bad SQL grammar [select username,authority from authorities where username = ?]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'phonebook.authorities' doesn't exist
Run Code Online (Sandbox Code Playgroud)
,这是合乎逻辑的,因为我没有.authoritiesByUsernameQuery()应用方法.问题是我该如何克服它?如何在不需要查询数据库的情况下为所有用户分配默认角色?如何仅使用登录名和密码从数据库登录,并且没有角色?
authentication authorization jdbc spring-security spring-java-config
即使用户未登录并尝试打开主页,在重定向到登录页面后,也会显示authError.是否有一种优雅的方法可以防止这种情况,而无需修改Auth组件?这是我加载Auth组件的方式(我使用TinyAuth作为授权适配器):
$this->loadComponent('Auth', [
'loginAction' => [
'controller' => 'Users',
'action' => 'login'
],
'loginRedirect' => [
'controller' => 'Home',
'action' => 'index'
],
'authError' => 'You dont have permissions for that action',
'authenticate' => [
'Form' => [
'fields' => [
'username' => 'email',
'password' => 'password'
],
'scope' => ['Users.active' => true],
'contain' => ['Roles']
]
],
'authorize' => [
'TinyAuth.Tiny' => [
'roleColumn' => 'role_id',
'rolesTable' => 'Roles',
'multiRole' => true,
'pivotTable' => 'roles_users',
'superAdminRole' => null,
'authorizeByPrefix' …Run Code Online (Sandbox Code Playgroud) 场景 - 使用SQL Server管理应用程序特定权限和扩展用户身份的Active Directory中的.Net Core Intranet应用程序.
迄今为止的成功 - 用户已通过身份验证,并且可以使用Windows声明(名称和组).Identity.Name可用于从具有扩展属性的数据库返回域用户模型.
问题和问题 - 我试图填充一个自定义声明属性"Id",并通过ClaimsPrincipal全局提供.到目前为止,我已经查看了ClaimsTransformation,但没有取得多大成功.在其他文章中,我已经读过你必须在登录之前添加声明,但这真的可以吗?这意味着完全依赖AD满足所有索赔,情况确实如此吗?
下面是我在HomeController中的简单代码.我正在访问数据库,然后尝试填充ClaimsPrincipal,然后返回域用户模型.我认为这可能是我的问题所在,但我是.net的授权新手,并努力让我的头脑索赔.
非常感谢所有的帮助
现行代码:
public IActionResult Index()
{
var user = GetExtendedUserDetails();
User.Claims.ToList();
return View(user);
}
private Models.User GetExtendedUserDetails()
{
var user = _context.User.SingleOrDefault(m => m.Username == User.Identity.Name.Remove(0, 6));
var claims = new List<Claim>();
claims.Add(new Claim("Id", Convert.ToString(user.Id), ClaimValueTypes.String));
var userIdentity = new ClaimsIdentity("Intranet");
userIdentity.AddClaims(claims);
var userPrincipal = new ClaimsPrincipal(userIdentity);
return user;
}
Run Code Online (Sandbox Code Playgroud)
更新:
我已经注册了ClaimsTransformation
app.UseClaimsTransformation(o => new ClaimsTransformer().TransformAsync(o));
Run Code Online (Sandbox Code Playgroud)
并根据此github查询构建如下所示的ClaimsTransformer
https://github.com/aspnet/Security/issues/863
public class ClaimsTransformer : IClaimsTransformer
{
private readonly …Run Code Online (Sandbox Code Playgroud) authorization ×10
cakephp ×2
php ×2
security ×2
architecture ×1
asp.net ×1
asp.net-core ×1
cakephp-3.0 ×1
jdbc ×1
macos ×1
oauth-2.0 ×1
swift ×1
xcode6 ×1