Reputation: 4133
I want to build a single login interface (with Angular) which should be a kind of stand alone, so that it can be used and embedded from/on any page.
E.g. a customer can embed it on his index page as over layer and the code/functions should be will passed from a JavaScript API and build the the UI and the connection.
I'am thinking about a concept like single sign-on application which allows users to interact on other websites through their account on Facebook. Something like Facebook connect.
What's the best approach to reach this? Preferred technology is Angular2, Angular4
Upvotes: 0
Views: 5449
Reputation: 26766
[Not entirely an answer but too long for a comment]
I think the fundamental mis-match is that you're asking "how do I do auth" and I'm countering with "there are lots of ways, with varied costs/benefits. You need to assess them and pick the right approach for your use case. OAuth2 is a sensible starting point, but many others exist."
After that, finding a library that does the work is (relatively) simple.
So... there are a number of things which I think you'll need to get nailed down before you can proceed.
My initial questions would be:
Broad strokes, I'd suggest an architecture that does something like this:
The 3PA can then use that token to act on behalf of the user until the token is cancelled.
Benefits:
What I've described is basically, a minimalist OAuth workflow. You could go about implementing it yourself, but there are a lot of pitfalls and I'm not convinced you fully appreciate the security implications of what you're attempting, so I'd definitely suggest using a known-good process rather than trying to roll your own.
Assuming OAuth fits your use-case.... I've never had to do this from Angular so can't recommend a library but a quick Google shows dozens... Near the top of the results was a simple tutorial: https://devcenter.kinvey.com/angular/tutorials/how-to-implement-safe-signin-via-oauth
And one potential library: https://github.com/oauthjs/angular-oauth2 (although at a glance, that doesn't seem to handle the intercepted-credentials scenario very well)
Upvotes: 3