0

I'm looking for a good process of authentication in a SPA.
I think that the process what dewastator describes in this question seems good but the process of the article what thierry templier presentes in his answer seems more complex as it uses 'mac_key', 'refresh_token' and so on.
Is it not enough just to use login ID, password and access token for authentication? I'm not thinking to make APIs enable cross origin requests

1 Answer 1

2

Yes, you can simply exchange username & password for an access token. This is the Resource Owner Password Credentials Grant. This really is the simplest way to secure a Single Page App (SPA).

I recommend using JWT for the token format and HTTPS-Only cookies as the secure storage mechanism. I've covered these topics in my recent blog article, Token Based Authentication for Single Page Apps

Disclaimer: I work at Stormpath. We've been doing a lot of work with SPAs, and we have a full-stack javascript solution for token authentication in our Stormpath Angular SDK

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Perfect!. I thought that saving security roles in database per user record was enough but after read the usage of JWT in your blog, I agree saving that kind of information in tokens is a great idea.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.