Comments (12)
Correct me if I'm wrong, but I don't think you should rely on the AngularServices for that. I think you should look at IdentityServer or Auth0 for this kind of functionality. They have great samples and a JavaScript library for handling OAuth2 and OpenIdConnect requests to an API endpoint. Also, Brock Allen and Dominick Baier who developed and maintains IdentityServer has som great presentations and blog posts about this kind of security. I recommend you looking at this:
Dominick Baier Blog
Brock Allen Blog
Vimeo Brock Allen
Vimeo Dominick Baier
from javascriptservices.
Yeh, thanks for the reply @inongogo but I wasn't asking about how to use AngularServices to authenticate/obtain an access token - that, as you mention, is well managed by the likes of IdentityServer :)
Indeed, re-reading the original question, it may not have been clear what I was asking... I was more interested in how the pre-render & pre-fetch stuff would work with services that are not part of the same web project.. for example micro services or as in the example in the original question... an api on a different endpoint!
Especially when the access token only exists as a javascript object on the web client!
from javascriptservices.
As it stands currently, there doesn't seem to be a way to pre-render data in the templates, whether or not it is provided from inside the application, or from an external source. All data must be fetched on the client.
from javascriptservices.
As it stands currently, there doesn't seem to be a way to pre-render data in the templates
I'm not certain what you mean by that. The server-side code can contain any logic that the client-side code can. Are you referring to the issue that, specifically for the Angular server-side rendering (but not for React), it returns the HTML to the client without waiting for async operations such as data loads? If so, this is an issue in angular2-universal-preview
that should go away when they have fixed it.
from javascriptservices.
This WebAPI Controller only serves data up from the client via JavaScript network requests. This data isn't provided by any initial full GET request anywhere, which means you must visit a url (like http://somewhere.com/data), and then the client will load the data with some loading indicator. Instead, the server should be able to provide that data for the initial render, not requiring a client-side network request once the page has loaded.
from javascriptservices.
@pauldotknopf If I'm understanding your requirement correctly, this is accounted for already. See the React+Redux sample for an example where the initial data load is resolved on the server and the client doesn't have to re-fetch it. For Angular 2, you can either use @Html.PrimeCache
, or as I mentioned the angular2-universal-preview
module should eventually be fixed to account for waiting for server-side data loads before rendering the HTML. Or is your requirement something different?
from javascriptservices.
Feels like the question has taken on a life of it's own..
.. I simply wanted to know if & how @Html.PrimeCache operates in an environment where the api endpoints are exposed as micro services protected by an access token that is obtained by the web browser (or mobile client) especially if PrimeCache has no idea about the access token!
from javascriptservices.
@andycwk I have an awesome chicken curry soup recipe if you are interested.
from javascriptservices.
@andycwk I'm not sure if or how that scenario is compatible with server-side prerendering. If the authentication design is such that only the client is supposed to have access to the token, or goes through some handshake process to acquire it (e.g., including presenting some UI in which the user has to enter a password or similar) then there might not be any relevant way to do that on the server. Ultimately it depends on the exact details of how you've got the auth and token handover set up.
from javascriptservices.
@andycwk My expectation for traditional cookie-based auth systems is that PrimeCache would pass through any cookies sent by the browser with the original page request, but that won't help you if your auth setup doesn't involve sending the token to the static UI server.
from javascriptservices.
@SteveSandersonMS yeh, figured as much - just wondered if any one had any smart ideas :(
So at the moment the static content server needs an auth cookie or something 'else' that can be proxied through to the true endpoint - hmmm, if I have a brain wave I will come back and share (sanity check)!!
But in the meantime, feel welcome to close this question once finished the conversation with @pauldotknopf
btw @pauldotknopf 'chicken curry soup' sounds great :P
from javascriptservices.
Thanks. I'll mark this closed unless anyone has related ongoing questions.
from javascriptservices.
Related Issues (20)
- package reinstall HOT 2
- s
- Uncaught ReferenceError: vendor_ is not defined when using DllReferencePlugin HOT 5
- aspnet-webpack support? HOT 2
- Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.browser.module.ngfactory' HOT 1
- Buffer is deprecated in Node 10
- Expose some of the internal classes HOT 1
- React+Redux Template does not compile with --strict HOT 1
- JavaScriptServices vs Templating github HOT 1
- SSR with Vue requires javascript enabled? HOT 2
- What happened to the template in .NET Core 2.1?
- Ignore
- Delay in domain-task Promise Resolution when Server Side Rendering HOT 1
- How to publish the javascriptservices project (asp.netcore rest api project which uses node api) to IIS 8. The application not wroking after publishing to IIS HOT 2
- UseProxyToSpaDevelopmentServer doesn't auto-refresh browser using an Aurelia ClientApp with HMR HOT 3
- Release date for angular 6 template ? HOT 1
- Using Angular template - all routes are directing to Angular app directly, unable to implement ASP.NET /API route HOT 2
- Files being written to disk with WebpackDevMiddleware HOT 1
- The request matched multiple endpoints HOT 1
- Need clarification
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 javascriptservices.