same-origin-policy

Why is cross-domain JSONP safe, but cross-domainJSON not?

橙三吉。 提交于 2019-12-02 18:05:16
I'm having trouble connecting some dots having recently learned of JSONP. Here's my understanding: Cross-domain XmlHttpRequests for any content (including JSON) is banned, due to the same origin policy. This protects against XSRF. You are permitted to have a script tag with a src that returns JSONP - some JSON padded inside a call to a Javascript function (say 'Foo') You can have some implementation of 'foo' on the page that will get called when the JSONP data is returned, and you can do things with the JSON data that function is passed Why is it OK to receive cross-domain data if it came via

Smartgwt RestDataSource with SpringMVC and cross-client

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 17:07:23
问题 After a lot of work, I have an existing back-end web services application that is powered by Spring-RS, Spring MVC, Spring controllers, and these controllers user Jackson within the Spring framework to convert responses to JSON. Here is part of the WEB-INF/myproject-servlet.xml <mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="objectMapper"> <bean class="com

Why does my JavaScript code get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not?

百般思念 提交于 2019-12-02 16:09:44
问题 I am trying to do authorization using JavaScript by connecting to the RESTful API built in Flask. However, when I make the request, I get the following error: XMLHttpRequest cannot load http://myApiUrl/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. I know that the API or remote resource must set the header, but why did it work when I made the request via the Chrome extension Postman? This is the request code:

Know which page the user is browsing in iframe

荒凉一梦 提交于 2019-12-02 14:16:13
问题 I would like to create a web page which is a main page that has one iframe whose content does not come from the same host as the main page but I would like to know which page the user is currently browsing in the iframe. For example, I have a main page with a button bound with an Javascript event and an iframe that load content from a site like google. A user can navigate the content in iframe as he wants but when the button in the main page is clicked, the current url in the iframe must be

Why does my JavaScript code get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not?

青春壹個敷衍的年華 提交于 2019-12-02 12:11:08
I am trying to do authorization using JavaScript by connecting to the RESTful API built in Flask . However, when I make the request, I get the following error: XMLHttpRequest cannot load http://myApiUrl/login . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. I know that the API or remote resource must set the header, but why did it work when I made the request via the Chrome extension Postman ? This is the request code: $.ajax({ type: "POST", dataType: 'text', url: api, username: 'user', password: 'pass', crossDomain

How does same origin policy solve issues with XHR, cookies and cross page commuication? [closed]

寵の児 提交于 2019-12-02 10:19:55
I understand that same origin policy is about restricting javascript from other domains from accessing contents of a page. I read these particular points of importance of same origin policy on the Web: XmlHttpRequests: they don't work if done cross domain. But why would a Web page make an xhr request to a less trusted site in the first place? Isn't it the Web page's fault? Why impose a restriction then? cookies: it is not right if a malicious page can view my Facebook cookies. So if it tries to check "document.cookies" it will never see my Facebook cookies anyway. Where does same policy come

Know which page the user is browsing in iframe

♀尐吖头ヾ 提交于 2019-12-02 09:30:02
I would like to create a web page which is a main page that has one iframe whose content does not come from the same host as the main page but I would like to know which page the user is currently browsing in the iframe. For example, I have a main page with a button bound with an Javascript event and an iframe that load content from a site like google. A user can navigate the content in iframe as he wants but when the button in the main page is clicked, the current url in the iframe must be popped up. I already tried it but since the same origin policy always applies, an error like this

AngularJS Allow-Origin to WebApi2

◇◆丶佛笑我妖孽 提交于 2019-12-02 07:44:10
I want to host my API on a separate domain. I have configured my auth-interceptor for token in angular with a bearer: config.headers.Authorization = 'Bearer ' + sessionStorage.getItem('token'); In my My WebApi2 I have configured the WebApiConfig with cors. var cors = new EnableCorsAttribute("http://mydomain.com", "*", "*"); config.EnableCors(cors); And in web.config of the API I also included: <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> </customHeaders> I still can´t access the api due to origin not allowed. Can I add something more in my header of the auth-interceptor

crossDomain heartbeat cant parse jsonp data with jquery

馋奶兔 提交于 2019-12-02 06:47:48
I embbeding my module, an asp.net project, in a "portal", the portal generate an iframe to my url, i know its a shit but i dont made it. To avoid session in main "portal" end while user iterating with my web project the portal owner told me to start an heartbeat by javascript from my application to portal. Everyone know keep session in this way is insecure but 'portal' there is then i havent nothing to do. The real problem is that i cant do cross-domain requests from my application to portal because same origin policy lock it, i found a solution using jquery but it require [heartbeat listener]

Can different subdomains of the same app prevent malicious attack like XSS?

a 夏天 提交于 2019-12-02 06:32:33
问题 In my Rails app i have 2 subdomains, one : members.myapp.com which is the area shared between all members (where they can login and manage their accounts) Two : each member has its own website on a subdomain like this : member1.myapp.com , member2.myapp.com , member3.myapp.com etc... Let's imagine that user1.myapp.com run a malicious js code in his site, can members.myapp.com be affected through XSS or other attacks? 回答1: They would be able to set cookies that can be read by members.myapp.com