Spring Security REST and Angular - angularjs

I have a full Spring application (security managed by spring-security and the controller Layer is build with Spring MVC).
I am using in the front-end AngularJS .
I need some example of how I will handle REST authentication with Spring Security and how I will call these services in the Angular side.
Note: Basic authentication will be perfect in my case .

Some code is needed to integrate AngularJS and Spring Security, as Spring Security wasn't meant to be used by a full Ajax framework.
Here is a sample application that does this integration, you will get both the Spring Security configuration and some classes used to do this integration:
https://github.com/jhipster/jhipster-sample-app

One of the great things about AngularJS is that its pretty flexible and can operate with a number of different backend configurations. While I haven't personally used spring MVC or spring security I have used Angular with .NET MVC, Node, and PHP all with slightly different authentication systems and it worked out very well.
Dave Mosher has a great tutorial series that incorporates authentication concepts(his example is PHP with Laravel) but the concepts may be helpful:
https://github.com/davemo/end-to-end-with-angularjs
For a more advanced example of authentication with AngularJS you might want to check out Angular-App:
https://github.com/angular-app/angular-app

Related

Is it a good practice to bundle the react web application in spring boot instead of running as a separate micro service?

I am new to react and single sign on implementation as well. Tech stack of application is Spring boot, SAML , ADFS and React. After reading some the article we found of ADFS interaction through SPA is not a good choice. We can't move out of react at the same time. So though of bundle the react and Springboot application as single service instead of separate micro services.
Please let me know is this a good approach. I found some article related to this approach.
But, I am looking for a better way to achieve this.
https://medium.com/analytics-vidhya/how-to-package-your-react-app-with-spring-boot-41432be974bc

ADAL, Angular and WEB API strategy

I am a Microsoft developer. Making an ASP.NET application with authentication to Azure AD is very easy. The traditional multi page application with Vue (as an example) can be created within two minutes (by using the Authentication wizard in Visual Studio). However watching some Angular and NPM videos I liked the CLI/npm approach. So I decided to build my next project using ADAL.js, ASP.NET Core API and Angular 6 (deploy to Azure web app). But I haven't been able to succeed, and have only been met by complexity and issues.
Is the combo of these three technologies just a bad mix, Visual Studio not suited for SPA, or have I just gotten a bad start? Any suggestions on a good setup? I am considering to split the API and front end in two apps, so I can use clean Angular without having to worry about who is building TypeScript (VS or Node) etc. But then I need two web apps, and have to worry about CORS. Any suggestions here, what is a good setup to get started?
I have followed a lot of articles like:
http://www.talkingdotnet.com/how-to-create-an-angular-6-app-with-visual-studio-2017/
https://www.npmjs.com/package/microsoft-adal-angular6
But all of them had issues.
Refer to this Microsoft published GitHub sample. This sample demonstrates the use of ADAL for JavaScript for securing an AngularJS based single page app, implemented with an ASP.NET Web API backend, that calls another ASP.NET Web API using CORS.
Call an Azure AD protected Web API in an AngularJS Single Page App

Another front-end technology inqury - but using serverless backend

We have started to work with serverless technologies specifically with AWS Lambda and API Gateway using the serverless framework. We are working with Auth0 to manage authentication. Question is what is the best front-end technology we should use?
I think that we can build the front-end using S3 and cloudfront. The flexibility of each webpage or a set of webpages without any server sounds fantastic and simple, however I wanted to know of any pros and cons in building out web pages that use standard javascript ajax calls using S3 and cloudfront versus using other front-end technologies such as angularjs or vue?
tldr;: Should we build front-end pages using angularjs, vue, etc. or should we use S3 using pure AJAX calls? What are the pros and cons?
You should find hosting any application that uses a popular SPA framework via S3 is achievable. The fact you are using serverless for the API(s) that will be called from your SPA application makes no difference from the perspective of the SPA (client). The client is referencing a web endpoint only. For secured API endpoints, please look at Auth0's Resource API approach, where you would receive a JWT ID Token and JWT Access Token on successful authentication, and send the JWT Access Token with each request. More information on this on the Auth0 website together with samples illustrating how it all works.
Regarding choice on SPA framework / JS technology to use - here are a few useful links to help getting started:
AngularJS - https://auth0.com/docs/client-platforms/angularjs
AngularJS 2 - https://auth0.com/docs/client-platforms/angular2
EmberJS - https://auth0.com/docs/client-platforms/emberjs
EmberJS 2 - https://auth0.com/docs/client-platforms/ember2js
React - https://auth0.com/docs/client-platforms/react
jQuery - https://auth0.com/docs/client-platforms/jquery
Vanilla JS - https://auth0.com/docs/client-platforms/vanillajs
Hope your project is a success.

Is requirement of AngularJS for big web based app necessary?

I wanted to build a maven based project based on google app engine which uses RESTful web services. So is angularJS really required in this type of project or can it be achieved without it also?
No, AngularJS is not required. While it provides a $resource module that works with RESTful web services, you can use other front-end tools as well. For example, smartphone apps written in their native languages can use RESTful services.

Spring Security + Angular JS + Spring MVC Rest

I am trying to build a web application with the following frameworks:
Angular JS on the front end
REST Web Services in the backend using Spring MVC
I want to use Spring Security to authenticate all the requests going from Angular JS to Spring REST Web services. I also need to manage the session timeout/remember password etc. (All of the typical functionalities of a login functionality in a web app)
I have gone over hundreds of articles trying to find out how to do this but none of them is exactly serving the purpose I am asking for.
Any help on this (inline answer or external links) with detailed steps is highly appreciated.
(Note: I don't want to use Spring boot. Many tutorials including the one provided by Spring is using Spring boot.)
Finally found the way to do this. Clearly explained, step by step process to secure a Spring MVC based REST APIs using Spring Security
https://malalanayake.wordpress.com/2014/06/30/stateless-spring-security-on-rest-api/

Resources