mark_anderson_us wrote:So, I got some basic stuff working with devices using Angular.
I created the following Angular "objects"
- DeviceService (factory pattern) - Gets a list of devices or a named devices detailsMain controller
- Main layout - has header, footer, etc, and "slots in" content based on which route (controller) is chosen
- Main Controller - specifies routes (controller and templates)
- DeviceListController - Gets list of devices using DeviceService
- DeviceController - Gets device details when clicking a device, using DeviceService
Things are looking good.
Regards
Mark
Hey Mark,
Can you share your code for how you were able to get Digest Auth working with CORS using Indigo in Angular? I assume its in angular 1.x?
I'm making a similar project in Angular2 and am having some issues. There are no good examples that I can find to do digest auth in Angular2, so I am piecing together my own solution, using the guts from
https://www.npmjs.com/package/request-digest. I've replaced the node package 'crypto', which is only available in the node server/backend and is not available in the browser, with CryptoJS which has a typescript definition from DefinitelyTyped. In order to get access to the digest nonce challenge to compute a proper response, I had to add another header (in addition to Access-Control-Allow-Origin = '*') which is Access-Control-Expose-Header = 'WWW-Authenticate'. With those headers added to Indigo's cherrypy config, I can now see the WWW-Authenticate response header from my first unauthorized request attempt. When I compute the Authentication header for the digest response and attempt to make a second request with that header, I see in Chrome dev tools that it triggers an OPTIONS pre-flight request, which does not and should not contain auth headers, but this OPTIONS request gets denied with the same 401 Unauthorized response.
It seems the pre-flight OPTIONS request requires auth from the Indigo server and this goes against the CORS spec, which states that OPTIONS requests should not require credentials. As noted here
http://stackoverflow.com/questions/38326128/xmlhttprequest-cannot-load-response-for-preflight-has-invalid-http-status-cAny examples you could provide from an angular 1.x solution might be useful in getting the same thing to work with my current angular2 implementation.
Thanks!
Matt