creating applications with grails, angular js and spring security
TRANSCRIPT
Creating applications with Grails, Angular JS and Spring Security
Álvaro Sánchez-Mariscal
Álvaro Sánchez-Mariscal Software Engineer Grails Development Team @alvaro_sanchez [email protected]
OCI is the new home of Grails More at ociweb.com/grails
Grails 3 update
Grails 3 status update
• v3.1.4 is the latest stable version.
• v3.2 is the current development version.
• Older versions:
• v3.0.15 for 3.0.x line.
• v2.5.4 for 2.5.x line.
Grails 3.0 recap• New architecture.
• Spring Boot, Gradle, profiles.
• Same philosophy.
• Conventions, DRY, plugins.
Grails 3.1 recap• Spring Boot 1.3, Spring 4.2.
• Massive improvements to profiles.
• Packaging and publishing.
• REST and Angular JS profile.
• JSON views.
• GORM 5.
Grails 3.1 recap
• GORM 5.
• Hibernate 3, 4 and 5.
• MongoDB 3
• Neo4j 2.3
• Cassandra
What’s coming in Grails 3.2?• GORM 6.
• GORM REST Client.
• Non-blocking GORM API.
• MongoDB 3.0 Async driver support.
• GORM Multi Tenancy Support.
• AngularJS scaffolding.
• Dynamic and static.
… and in Grails 3.3• Netty-based Profile.
• Low memory footprint, non-blocking.
• Support for controllers, REST, GORM and Angular JS.
• PostgreSQL Async Support.
• Lightweight GORM-SQL abstraction.
Upcoming conferences• Greach 2016.
• Madrid, Spain. April 8-9.
• http://greachconf.com
Upcoming conferences• GR8Conf EU 2016.
• Copenhagen, Denmark. June 1-3.
• http://gr8conf.eu
Upcoming conferences• G3 Summit.
• Fort Lauderdale, Florida, USA.
• Nov 28 - Dec 1, 2016.
• https://g3summit.com
Join the community
slack-signup.grails.org
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 hibernate,json-views todo
| Application created at /tmp/todo
REST Domain classpackage com.exampleimport grails.rest.Resource@Resource(uri = '/todos', formats = ['json']) class Todo { String description boolean completed}
RESTful Controllerpackage com.exampleimport grails.rest.RestfulControllerclass TodoController extends RestfulController { static responseFormats = ['json'] TodoController() { super(Todo) } def pending() { respond Todo.findAllByCompleted(false), view: 'index' } }
URL Mappings
“/todos"(resources:"todo") "/pending"(controller: 'todo', action: 'pending')
JSON Viewimport com.example.Todomodel { Todo todo} json { hal.links(todo) id todo.id description todo.description completed todo.completed}
Working with the Angular JS profile
The Angular JS Profile
• Extends the REST profile.
• Adds project setup for AngularJS.
• Code generation for AngularJS.
• Scaffolding coming soon.
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 hibernate,json-views todo
| Application created at /tmp/todo
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
Dziękuję bardzo!
Álvaro Sánchez-Mariscal