Posts

Add Angular application to GIT repository

Generate an angular application is very easy with the angular CLI utility. Step 1. Set up the Development Environment Before processing you must have installed Node.js and npm to your computer. Install Angular CLI with the following commands:  npm install -g @angular/cli Step 2. Create a GIT repository After creating an empty GIT repository,  clone it to a new directory. git clone <your-repository>.git Step 3. Create a new Project Open or keep your terminal window on the parent folder of your local repository. Remove the README.md first otherwise the angular CLI will throw an error. Generate a skeleton application by running the following commands: ng new <your-repository-name> --directory <your-repository-name> The directory option tells the command line interface to create all required files in the existing folder.

Authorization and Authentication with AngularJS + Jersey

Workflow User provides credentials which are sent to the server for identification. When the user is identified we perform the following task: A highly random, un-guessable string is generated. A JWT is generated with the User ID as subject and the random string as a claim . Store the JWT in cookie with HttpOnly , Secure flags (our session cookie). Store the random string in an another cookie with Secure flag only (xsrf cookie). The Login resource : All ajax requests should append the random string as the X-XSRF-Token Header. The server should reject any request that does not match between the supplied header and the claim of the session cookie. The Jersey filter : The AngularJS way... The session cookie is hidden from javascript because of HttpOnly flag. Consequently, we need to make a request (i.e. /api/current) on route change event ( AuthService.getUser() ). If the session cookie has expired or does not exist the endpoint should return...