Comments (12)
@sjlongland and I worked really hard and we finally found something that works the way we wanted.
Develop branch have just been updated and all the tests I have made are successful with nhaystack and Skyspark.
For now, only his_read is treated as POST. Next step will be to convert write to POST... but for now, let's celebrate his_read working on skyspark.
@clarsen thanks for your contribution
This will be merge to master ASAP so PyPI version works for Skyspark. So please give any feedback.
Thanks
from pyhaystack.
from pyhaystack.
Basic Idea here.
I just override _on_his_read
for skyspark session.
Why breaking every other implementation for now ? :)
def _on_his_read(self, point, rng, callback, **kwargs):
"""
Skyspark will not accept GET request for his_read by default
[ref : https://project-haystack.org/forum/topic/787#c6]
The default behavior of SkySpark is now to disallow GET requests
non-idempotent operations. So its still allowed on certain operations
such as about, formats, read. However as Chris said it can be toggled
back on using Settings|API for backward compatibility.
However as a recommendation I think we should always be using POST as
a safer alternative. Using GET for ops with side-effects is against
the HTTP spec. Plus it is an attack vector if cookies are involved.
And it provides a more precise way to pass the request payload.
Its not really from a theoretical perspective. But in SkySpark
we allow customers to generate histories using their own custom
functions. So from a security perspective we took the safest route
and consider it to potentially have side effects.
If your code is all using GET, then just have the customer set
Settings|API allowGetWithSideEffects flag to false and it should all work.
"""
if isinstance(rng, slice):
str_rng = ",".join([hszinc.dump_scalar(p) for p in (rng.start, rng.stop)])
elif not isinstance(rng, string_types):
str_rng = hszinc.dump_scalar(rng)
else:
# Better be valid!
str_rng = rng
col_list = [('id',[]),('range',[])]
his_grid = hszinc.grid.Grid(columns=col_list)
his_grid.insert(0,{"id": self._obj_to_ref(point), "range": str_rng})
print(his_grid)
return self._post_grid(
"hisRead",
his_grid,
callback,
**kwargs
)
I think I got it right (not sure my Grid is number 1 but it seem to work) ... but server throws :
HTTPError: 400 Client Error: SkyArc-Attest-Key required for url: https://demo.skyfoundry.com/api/demo/hisRead
This confirms what @clarsen was seing in issue #84
Reading through forums and doc, i see this
If you are not using a browser, then don't use cookies! Use a bearer token with authorization header
Then my knowledge is not strong enough to overpass this. I don't get it.
@sjlongland if you can bring some light it would be awesome.
I'm also poking people that took part of issue #84
@clarsen you were near something in april, maybe you can help
@gmanohar25
@San42
@justindarcy
@dawcurious
from pyhaystack.
from pyhaystack.
Okay, so the cookie stuff… that could be tricky as I tried very hard to round-trip cookies set by the server, and now they want us to do the opposite?
from pyhaystack.
@clarsen Submitted where ?
I missed something ?
from pyhaystack.
https://github.com/ChristianTremblay/pyhaystack/blob/master/pyhaystack/client/http/base.py#L160-L163
Okay, so we need to set exclude_cookies=True
in requests made to SkySpark.
from pyhaystack.
Okay, so python-requests
is too clever for its own good I think… it was ignoring me when told to not round-trip cookies.
https://github.com/sjlongland/pyhaystack/tree/skyspark-his-read-fix
I actually have converted all GET
requests to POST
s, things seem to work. I don't see it being a problem for the other implementations either. We should give that a shot and see what happens.
from pyhaystack.
@clarsen Submitted where ?
I missed something ?
Sorry i only shared 1/2 of the code involved. #93 has the modifications to strip out cookies.
from pyhaystack.
@ChristianTremblay hisWrite
should be a POST
request already… as it's often large blocks of data being written, more than what would fit in a GET
request. :-)
from pyhaystack.
I was thinking about point_write
from pyhaystack.
CLosing this as this is working in the develop branch. New release soon
from pyhaystack.
Related Issues (20)
- Issue with NaN values HOT 3
- Retrieving point write status was broken in 3.0? HOT 6
- Implement __await__ on operation classes HOT 5
- Breaking change from SkySpark 3.0.27 to 3.0.28 HOT 15
- LDAP login on SkySpark 3.0.28 HOT 6
- Axon eval(hisClear) requires POST, not GET with skyspark HOT 2
- Why was the Haystack read Op split into get_entity and find_entity? HOT 2
- hszinc.zincparser.ZincParseException: Failed to parse: Expected end of text, found '"' (line:6, col:1) HOT 2
- Pint error? HOT 3
- Possible error while fetching data from a Niagara server hosted on HTTPS HOT 2
- Parsing issue evalOrReadAll(\"ruleSparkSwivel([@nav:equip.all], toSpan(\\\"yesterday\\\"), [], {})\") HOT 2
- Use query function for Naigara4 nHaystack Server HOT 4
- Project Haxall HOT 1
- pyhaystack.util.state.NotReadyError HOT 10
- Niagara 4.9 | Possible breaking change for login HOT 2
- SkySpark Authentication HOT 3
- Writing histories to SkySpark HOT 4
- Watch_poll does not use argument refresh HOT 2
- Implementation of ability to add new entities? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyhaystack.