SlideShare a Scribd company logo
Creating applications
with Grails, Angular JS
and Spring Security
Álvaro Sánchez-Mariscal
Álvaro Sánchez-Mariscal
Software Engineer
Grails Development Team
sanchezmariscala@ociweb.com
Creating applications with Grails, Angular JS and Spring Security - GR8Conf US 2016
OCI is the new home of Grails
More at ociweb.com/grails
The workshop
http://bit.ly/grails-angular-gr8conf
Creating REST
API’s with Grails
The REST Profile
• Targeted at building REST applications.
• REST Specific plugins and commands.
• No GSP, asset pipeline, UI plugins.
• JSON / Markup views instead.
The REST Profile
• Profile specific commands:
• create-domain-resource - creates an
@Resource domain
• create-restful-controller - creates a
RestfulController
The REST Profile
• Statically compiled, extensible JSON views:
json.person	{	
		name	"bob"	
}	
{"person":{"name":"bob"}}
Create the project
$ grails create-app -profile rest-api
-features hibernate5,json-views todo
| Application created at /tmp/todo
Create a domain resource
$ grails create-domain-resource todo
| Created grails-app/domain/todo/Todo.groovy
| Created src/test/groovy/todo/TodoSpec.groovy
REST Domain class
package com.example



import grails.rest.Resource



@Resource(uri = '/todos')

class Todo {



String description

boolean completed



}
Demo - REST API
Create a restful controller
$ grails create-restful-controller todo.Todo
| Created grails-app/controllers/todo/TodoController.groovy
RESTful Controller
package com.example



import grails.rest.RestfulController



class TodoController extends RestfulController {



static responseFormats = ['json']



TodoController() {

super(Todo)

}



def pending() {

respond Todo.findAllByCompleted(false), view: 'index'

}

}
JSON View
import com.example.Todo



model {

Todo todo

}



json {

hal.links(todo)

id todo.id

description todo.description

completed todo.completed

}
Demo - JSON
Views
Working with the
Angular JS profile
The Angular JS Profile
• Extends the REST profile.
• Adds project setup for AngularJS.
• Code generation for AngularJS.
• Scaffolding available via plugin.
The Angular JS Profile
• Profile specific commands:
• create-ng-controller
• create-ng-service	
• create-ng-domain	
• create-ng-directive	
• create-ng-component	
• create-ng-module
Create the project
$ grails create-app -profile angular
-features hibernate5,json-views todo
| Application created at /tmp/todo
Scaffold all the things!
$ grails ng-generate-all todo.Todo
Demo - AngularJS
scaffolding
Adding Security with
Spring Security REST
Spring Security REST
• Compatibility layer over Spring Security Core.
• Login and logout REST endpoints.
• Token validation filter.
• Stateless by default, with JWT (signed and encrypted)
• Memcached, Redis, GORM and Grails Cache token storages.
• Implicit grant support through 3rd party providers.
• RFC 6750 Bearer Token support.
Create the project
$ grails create-app -profile angular
-features hibernate,json-views,security todo
| Application created at /tmp/todo
The interceptor
angular

.module("todo")

.factory('authInterceptor', function ($rootScope, $window) {

return {

request: function (config) {

config.headers = config.headers || {};

if ($window.sessionStorage.token) {

config.headers.Authorization = 'Bearer ' + $window.sessionStorage.token;

}

return config;

}

};

})

.config(function ($httpProvider) {

$httpProvider.interceptors.push('authInterceptor');

})

.controller("TodoController", TodoController);
Demo - All
together
Thank you!
Álvaro Sánchez-Mariscal

More Related Content

What's hot (20)

PDF
Rest with grails 3
Jenn Strater
 
PDF
Swagger code motion talk
Victor Trakhtenberg
 
PPTX
你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)
Will Huang
 
PPTX
Iterative Development with Swagger on the JDK
Swagger API
 
PDF
Swagger 2.0: Latest and Greatest
LaunchAny
 
PDF
Swagger UI
Walaa Hamdy Assy
 
PDF
Euroclojure2014: Schema & Swagger - making your Clojure web APIs more awesome
Metosin Oy
 
PDF
Getting Started With Angular
Stormpath
 
PDF
JHipster
Yuen-Kuei Hsueh
 
PDF
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
The Software House
 
PDF
How to generate a REST CXF3 application from Swagger ApacheConEU 2016
johannes_fiala
 
PDF
Design Driven API Development
Sokichi Fujita
 
PPTX
Magic of web components
HYS Enterprise
 
PDF
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Alvaro Sanchez-Mariscal
 
PDF
Creating RESTful API’s with Grails and Spring Security
Alvaro Sanchez-Mariscal
 
PDF
OpenAPI Specification概要
Kazuchika Sekiya
 
PDF
Swagger / Quick Start Guide
Andrii Gakhov
 
PDF
Documenting your REST API with Swagger - JOIN 2014
JWORKS powered by Ordina
 
PDF
Improve monitoring and observability for kubernetes with oss tools
Nilesh Gule
 
Rest with grails 3
Jenn Strater
 
Swagger code motion talk
Victor Trakhtenberg
 
你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)
Will Huang
 
Iterative Development with Swagger on the JDK
Swagger API
 
Swagger 2.0: Latest and Greatest
LaunchAny
 
Swagger UI
Walaa Hamdy Assy
 
Euroclojure2014: Schema & Swagger - making your Clojure web APIs more awesome
Metosin Oy
 
Getting Started With Angular
Stormpath
 
JHipster
Yuen-Kuei Hsueh
 
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
The Software House
 
How to generate a REST CXF3 application from Swagger ApacheConEU 2016
johannes_fiala
 
Design Driven API Development
Sokichi Fujita
 
Magic of web components
HYS Enterprise
 
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Alvaro Sanchez-Mariscal
 
Creating RESTful API’s with Grails and Spring Security
Alvaro Sanchez-Mariscal
 
OpenAPI Specification概要
Kazuchika Sekiya
 
Swagger / Quick Start Guide
Andrii Gakhov
 
Documenting your REST API with Swagger - JOIN 2014
JWORKS powered by Ordina
 
Improve monitoring and observability for kubernetes with oss tools
Nilesh Gule
 

Similar to Creating applications with Grails, Angular JS and Spring Security - GR8Conf US 2016 (20)

PPTX
Spring Northwest Usergroup Grails Presentation
ajevans
 
PDF
Gr8Conf 2016 - What's new in Grails 3
graemerocher
 
PDF
Coders Workshop: API First Mobile Development Featuring Angular and Node
Apigee | Google Cloud
 
PDF
Developing SPI applications using Grails and AngularJS
Alvaro Sanchez-Mariscal
 
PPTX
Building a scalable API with Grails
Tanausu Cerdeña
 
PDF
Workshop: Creating RESTful API’s with Grails and Spring Security (GR8Conf 2014)
Alvaro Sanchez-Mariscal
 
PPTX
Grails Advanced
Saurabh Dixit
 
PPTX
The future of web development write once, run everywhere with angular.js and ...
Mark Roden
 
PDF
The future of web development write once, run everywhere with angular js an...
Mark Leusink
 
PPTX
Single-page applications and Grails
Alvaro Sanchez-Mariscal
 
PPT
Using RESTFUL APIs in ANGULARJS
Mindfire Solutions
 
PPT
Introduction To Grails
Christopher Bartling
 
PDF
Grails 101
David Jacobs
 
PPTX
Angular js
Baldeep Sohal
 
PPTX
Grails basics
Saurabh Dixit
 
PDF
Groovy grailstutorial
Rasmita Patra
 
PPT
Fast web development using groovy on grails
Anshuman Biswal
 
ODP
Groovy and Grails intro
Miguel Pastor
 
PDF
Grails 101
Lim Kin
 
PDF
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Codemotion
 
Spring Northwest Usergroup Grails Presentation
ajevans
 
Gr8Conf 2016 - What's new in Grails 3
graemerocher
 
Coders Workshop: API First Mobile Development Featuring Angular and Node
Apigee | Google Cloud
 
Developing SPI applications using Grails and AngularJS
Alvaro Sanchez-Mariscal
 
Building a scalable API with Grails
Tanausu Cerdeña
 
Workshop: Creating RESTful API’s with Grails and Spring Security (GR8Conf 2014)
Alvaro Sanchez-Mariscal
 
Grails Advanced
Saurabh Dixit
 
The future of web development write once, run everywhere with angular.js and ...
Mark Roden
 
The future of web development write once, run everywhere with angular js an...
Mark Leusink
 
Single-page applications and Grails
Alvaro Sanchez-Mariscal
 
Using RESTFUL APIs in ANGULARJS
Mindfire Solutions
 
Introduction To Grails
Christopher Bartling
 
Grails 101
David Jacobs
 
Angular js
Baldeep Sohal
 
Grails basics
Saurabh Dixit
 
Groovy grailstutorial
Rasmita Patra
 
Fast web development using groovy on grails
Anshuman Biswal
 
Groovy and Grails intro
Miguel Pastor
 
Grails 101
Lim Kin
 
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Codemotion
 
Ad

More from Alvaro Sanchez-Mariscal (19)

PDF
Serverless functions with Micronaut
Alvaro Sanchez-Mariscal
 
PDF
Asynchronous and event-driven Grails applications
Alvaro Sanchez-Mariscal
 
PDF
6 things you need to know about GORM 6
Alvaro Sanchez-Mariscal
 
PDF
Reactive microservices with Micronaut - GR8Conf EU 2018
Alvaro Sanchez-Mariscal
 
PDF
Reactive microservices with Micronaut - Greach 2018
Alvaro Sanchez-Mariscal
 
PDF
Practical Spring Cloud
Alvaro Sanchez-Mariscal
 
PDF
Efficient HTTP applications on the JVM with Ratpack - JDD 2015
Alvaro Sanchez-Mariscal
 
PDF
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Alvaro Sanchez-Mariscal
 
PDF
Stateless authentication for microservices - GR8Conf 2015
Alvaro Sanchez-Mariscal
 
PDF
Ratpack 101 - GR8Conf 2015
Alvaro Sanchez-Mariscal
 
PDF
Ratpack 101 - GeeCON 2015
Alvaro Sanchez-Mariscal
 
PDF
Stateless authentication for microservices - Spring I/O 2015
Alvaro Sanchez-Mariscal
 
PDF
Stateless authentication for microservices - Greach 2015
Alvaro Sanchez-Mariscal
 
PDF
Stateless authentication for microservices applications - JavaLand 2015
Alvaro Sanchez-Mariscal
 
PDF
Stateless authentication for microservices
Alvaro Sanchez-Mariscal
 
PDF
Stateless token-based authentication for pure front-end applications
Alvaro Sanchez-Mariscal
 
PDF
Embrace the frontend revolution
Alvaro Sanchez-Mariscal
 
PDF
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
Alvaro Sanchez-Mariscal
 
PDF
DevQA: make your testers happier with Groovy, Spock and Geb
Alvaro Sanchez-Mariscal
 
Serverless functions with Micronaut
Alvaro Sanchez-Mariscal
 
Asynchronous and event-driven Grails applications
Alvaro Sanchez-Mariscal
 
6 things you need to know about GORM 6
Alvaro Sanchez-Mariscal
 
Reactive microservices with Micronaut - GR8Conf EU 2018
Alvaro Sanchez-Mariscal
 
Reactive microservices with Micronaut - Greach 2018
Alvaro Sanchez-Mariscal
 
Practical Spring Cloud
Alvaro Sanchez-Mariscal
 
Efficient HTTP applications on the JVM with Ratpack - JDD 2015
Alvaro Sanchez-Mariscal
 
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Alvaro Sanchez-Mariscal
 
Stateless authentication for microservices - GR8Conf 2015
Alvaro Sanchez-Mariscal
 
Ratpack 101 - GR8Conf 2015
Alvaro Sanchez-Mariscal
 
Ratpack 101 - GeeCON 2015
Alvaro Sanchez-Mariscal
 
Stateless authentication for microservices - Spring I/O 2015
Alvaro Sanchez-Mariscal
 
Stateless authentication for microservices - Greach 2015
Alvaro Sanchez-Mariscal
 
Stateless authentication for microservices applications - JavaLand 2015
Alvaro Sanchez-Mariscal
 
Stateless authentication for microservices
Alvaro Sanchez-Mariscal
 
Stateless token-based authentication for pure front-end applications
Alvaro Sanchez-Mariscal
 
Embrace the frontend revolution
Alvaro Sanchez-Mariscal
 
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
Alvaro Sanchez-Mariscal
 
DevQA: make your testers happier with Groovy, Spock and Geb
Alvaro Sanchez-Mariscal
 
Ad

Recently uploaded (20)

PDF
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
PDF
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
 
PPTX
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
DOCX
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
SEOLIFT - SEO Company London
 
PPTX
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
PDF
Mastering VPC Architecture Build for Scale from Day 1.pdf
Devseccops.ai
 
PDF
Alur Perkembangan Software dan Jaringan Komputer
ssuser754303
 
DOCX
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
PDF
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
 
PDF
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
 
PDF
Designing Accessible Content Blocks (1).pdf
jaclynmennie1
 
PDF
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
PPTX
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
PDF
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
PDF
Which Hiring Management Tools Offer the Best ROI?
HireME
 
PDF
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
PDF
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
PPTX
For my supp to finally picking supp that work
necas19388
 
TEASMA: A Practical Methodology for Test Adequacy Assessment of Deep Neural N...
Lionel Briand
 
Telemedicine App Development_ Key Factors to Consider for Your Healthcare Ven...
Mobilityinfotech
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
SEOLIFT - SEO Company London
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
Mastering VPC Architecture Build for Scale from Day 1.pdf
Devseccops.ai
 
Alur Perkembangan Software dan Jaringan Komputer
ssuser754303
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
 
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
 
Designing Accessible Content Blocks (1).pdf
jaclynmennie1
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Which Hiring Management Tools Offer the Best ROI?
HireME
 
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
For my supp to finally picking supp that work
necas19388
 

Creating applications with Grails, Angular JS and Spring Security - GR8Conf US 2016