Git Product home page Git Product logo

Comments (12)

inongogo avatar inongogo commented on July 20, 2024

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.

andycwk avatar andycwk commented on July 20, 2024

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.

pauldotknopf avatar pauldotknopf commented on July 20, 2024

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.

SteveSandersonMS avatar SteveSandersonMS commented on July 20, 2024

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.

pauldotknopf avatar pauldotknopf commented on July 20, 2024

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.

SteveSanderson avatar SteveSanderson commented on July 20, 2024

@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.

andycwk avatar andycwk commented on July 20, 2024

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.

pauldotknopf avatar pauldotknopf commented on July 20, 2024

@andycwk I have an awesome chicken curry soup recipe if you are interested.

from javascriptservices.

SteveSandersonMS avatar SteveSandersonMS commented on July 20, 2024

@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.

SteveSandersonMS avatar SteveSandersonMS commented on July 20, 2024

@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.

andycwk avatar andycwk commented on July 20, 2024

@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.

SteveSandersonMS avatar SteveSandersonMS commented on July 20, 2024

Thanks. I'll mark this closed unless anyone has related ongoing questions.

from javascriptservices.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.