Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit bb17964

Browse files
committed
fixup! feat($http): support sending XSRF token to whitelisted origins
1 parent 50aefd0 commit bb17964

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"urlResolve": false,
162162
"urlIsSameOrigin": false,
163163
"urlIsSameOriginAsBaseUrl": false,
164-
"urlIsAllowedOriginChecker": false,
164+
"urlIsAllowedOriginFactory": false,
165165

166166
/* ng/controller.js */
167167
"identifierForController": false,

src/ng/http.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ function $HttpProvider() {
391391
* @name $httpProvider#xsrfWhitelistedOrigins
392392
* @description
393393
*
394-
* Array containing URLs whose origins are considered trusted enough to receive the XSRF token.
395-
* See the {@link ng.$http#security-considerations Security Considerations} sections for more
396-
* details on XSRF.
394+
* Array containing URLs whose origins are trusted to receive the XSRF token. See the
395+
* {@link ng.$http#security-considerations Security Considerations} sections for more details on
396+
* XSRF.
397397
*
398398
* **Note:** An "origin" consists of the [URI scheme](https://en.wikipedia.org/wiki/URI_scheme),
399399
* the [hostname](https://en.wikipedia.org/wiki/Hostname) and the
@@ -452,7 +452,7 @@ function $HttpProvider() {
452452
/**
453453
* A function to check request URLs against a list of allowed origins.
454454
*/
455-
var urlIsAllowedOrigin = urlIsAllowedOriginChecker(xsrfWhitelistedOrigins);
455+
var urlIsAllowedOrigin = urlIsAllowedOriginFactory(xsrfWhitelistedOrigins);
456456

457457
/**
458458
* @ngdoc service
@@ -824,7 +824,7 @@ function $HttpProvider() {
824824
* for added security.
825825
*
826826
* The header will — by default — **not** be set for cross-domain requests. This
827-
* prevents unauthorized servers (e.g. malicious or compromized 3rd-party APIs) from gaining
827+
* prevents unauthorized servers (e.g. malicious or compromised 3rd-party APIs) from gaining
828828
* access to your users' XSRF tokens and exposing them to Cross Site Request Forgery. If you
829829
* want to, you can whitelist additional origins to also receive the XSRF token, by adding them
830830
* to {@link ng.$httpProvider#xsrfWhitelistedOrigins xsrfWhitelistedOrigins}. This might be

src/ng/urlUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function urlIsSameOriginAsBaseUrl(requestUrl) {
118118
* @returns {Function} - A function that receives a URL (string or parsed URL object) and returns
119119
* whether it is of an allowed origin.
120120
*/
121-
function urlIsAllowedOriginChecker(whitelistedOriginUrls) {
121+
function urlIsAllowedOriginFactory(whitelistedOriginUrls) {
122122
var parsedAllowedOriginUrls = [originUrl].concat(whitelistedOriginUrls.map(urlResolve));
123123

124124
/**

test/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
"urlResolve": false,
154154
"urlIsSameOrigin": false,
155155
"urlIsSameOriginAsBaseUrl": false,
156-
"urlIsAllowedOriginChecker": false,
156+
"urlIsAllowedOriginFactory": false,
157157

158158
/* karma */
159159
"dump": false,

test/ng/urlUtilsSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ describe('urlUtils', function() {
5858
});
5959

6060

61-
describe('urlIsAllowedOriginChecker', function() {
61+
describe('urlIsAllowedOriginFactory', function() {
6262
var origin = urlResolve(window.location.href);
6363
var urlIsAllowedOrigin;
6464

6565
beforeEach(function() {
66-
urlIsAllowedOrigin = urlIsAllowedOriginChecker([
66+
urlIsAllowedOrigin = urlIsAllowedOriginFactory([
6767
'https://foo.com/',
6868
origin.protocol + '://bar.com:1337/'
6969
]);

0 commit comments

Comments
 (0)