我从Laravel 4搬到了Laravel 5.我看到的一个重大变化是所有模型文件都必须放在/app目录下.
如何配置我的laravel 5安装,以便我可以放置我的模型文件,/app/Models并以常规FooModel::with(...)(例如)方式使用模型?
安全。如今,如果没有通过开发人员使用的框架或开发人员自己编程适当的安全性,任何应用程序都无法在互联网上生存。我目前正在开发一个 RESTful API,以使用 Bearer 令牌身份验证进行工作,但一直在阅读有关 XSS 和 CSRF 攻击的内容。
问题 1)从我所读到的内容来看,如果令牌存储在浏览器的 localStorage/sessionStorage 而不是 cookie 中,则使用基于令牌的身份验证的 RESTful API 的应用程序容易受到 XSS 而不是CSRF的攻击。这是因为,要使 CSRF 发挥作用,应用程序必须使用 cookie。我对么?
但现在令牌存储在 localStorage/sessionStorage 中,应用程序变得容易受到 XSS 攻击。如果应用程序的任何部分不清理输入(例如,框架对 Angular 输入进行清理,但也许我正在使用的某个第三方库默认情况下不清理输入),那么攻击者就可以注入恶意代码窃取其他用户的令牌,然后通过模拟他们发出经过身份验证的请求。
问题 2)有一种方法可以在使用 RESTful API 的应用程序中防范这两种攻击。我偶然发现了这篇文章。该文章的要点是,在用户登录并请求不记名令牌时,让服务器也返回一个httpOnlycookie,该 cookie 的作用类似于CSRFProtectionCookie. 我相信本文中的解决方案非常强大并且提供了强大的保护。再说一遍,我说得对吗?您有何看法?
上面的帖子中提到的方法要求我将其保存CSRFProtectionCookie在某种数据库中。我不想那样做。我不希望每次向 API 发出经过身份验证的请求时都会访问数据库。相反,我能做的是:
登录
csrf为 JWT 的声明。httpOnly名为 的 cookie XSRF-TOKEN,其值是相同的随机字符串,但这次是加密的。XSRF-TOKEN设置 …我已经使用php artisan down命令将应用程序放下进行维护。
我的自定义维护页面作为电子邮件输入,用于接受来自用户的电子邮件并将其存储在我的数据库中,以在站点备份并再次运行时通知用户。
但是当我使用POST提交表单时,我被重定向到维护模式页面。
我希望一条特定的路线绕过维护模式。可能吗?
如何adal.js在AngularJS中使用https://management.azure.com我的JavaScript代码为观众获取承载令牌?
我在AD中创建了一个客户端应用程序,并设置其权限以允许其访问“ Windows Azure服务管理API”。我的angularjs代码如下:
adalService.init(
{
instance: "https://login.windows.net/",
tenant: "<something>.onmicrosoft.com",
clientId: "<some id>",
cacheLocation: 'localStorage',
redirectUri: 'http://localhost:63691/index.html#/configure',
endpoints: {
/* 'target endpoint to be called': 'target endpoint's resource ID' */
'https://management.azure.com/subscriptions?api-version=2014-04-01': 'https://management.azure.com/'
}
},
$httpProvider
);
Run Code Online (Sandbox Code Playgroud)
如果我使用此adalService在POSTMAN中收到的令牌来调用https://management.azure.com/subscriptions?api-version=2014-04-01,则会收到以下错误:
The access token has been obtained from wrong audience or resource '<some id>'.
It should exactly match (including forward slash) with one of the allowed audiences 'https://management.core.windows.net/','https://management.azure.com/'.
Run Code Online (Sandbox Code Playgroud) 我在"成分"和"食谱"之间有多对多的关系.我知道我可以使用关系添加和删除对象
var Recipe = Parse.Object.extend("Recipe");
var Ingredient = Parse.Object.extend("Ingredient");
var recipe = new Recipe();
var ingredient = new Ingredient();
ingredient.id = "abcDef1234"; //random
var recipe_ingredients = recipe.relation("recipe_ingredients");
recipe_ingredients.add(ingredient);
Run Code Online (Sandbox Code Playgroud)
但这只会增加成分.我如何存储像"数量"这样的字段以及添加的每种成分?(就像数据透视表上的额外属性一样?)
谢谢!
php ×2
adal.js ×1
angularjs ×1
azure ×1
csrf ×1
javascript ×1
laravel ×1
laravel-4 ×1
laravel-5 ×1
many-to-many ×1
pivot-table ×1
rest ×1
routing ×1
xss ×1