Categories
Moving to Grails

Analyzing your code with CodeNarc

CodeNarc analyzes Groovy code for defects, bad practices, inconsistencies, style issues and more. A flexible framework for rules, rulesets and custom rules means it’s easy to configure CodeNarc to fit into your project. Build tool, framework support, and report generation are all enterprise ready. This is the description you find on the CodeNarc home page: […]

Categories
Moving to Grails

Logging from a library

I sometimes create libraries with less overhead than the e.g. a grails plugin. Applying the same logging as grails is done with these steps: add dependencies add configuration files for testing build.gradle: Then create the src/test/resources directory: In this case I configured test logging with logback-test.xml. For some reason I could not make logback-test.groovy work. […]

Categories
Moving to Grails

Logging from tests

Following up on the logging blog post. When creating and later running tests it could be equally helpful with some good logs. Configuring test logging is done with either logback-test.groovy or logback-test.xml which should be placed in the resources directory within the test directory. logback-test.groovy And then setting up the integration test something like: @Slf4j […]

Categories
Moving to Grails

Logging

Grails logging is described in the docs: http://docs.grails.org/latest/guide/single.html#logging Grails logging is built on top of logback: http://logback.qos.ch/ Why/What log? In development and testing I use logs as a supplement to debuggers. The logging is configured to be more verbose. In production debugging is not available, so logging is your tool for investigating a situation and […]

Categories
Moving to Grails

Spring security core with groups

In this blog post I will look into assigning roles through groups. Group assignment becomes more interesting with: increasing user count increasing role count users with similar access needs Overview There are three basic domains when configuring spring security for groups. User Role RoleGroup We also have these many-to-many helper domains: Each user can be […]

Categories
Grails

Spring security – multitenant

In this post I will demonstrate how to configure Spring security with a per tenant user database. In order to make it work we will need: Custom UserDetailsService Rewrite the UserPasswordEncoderListener Initialize per tenant beans First lets create the application and add security. Import the new project into IDEA. Edit build.gradle: Initialize spring security core […]

Categories
Grails Moving to Grails

Making SystemPropertyTenantResolver work

I use SystemPropertyTenantResolver for testing purposes. One use-case is building a simple app to see how some aspects of multitenancy works. The other use-case is testing with Spock. Minimum necessary code to setup multitenancy and select one tenant. First in application.yml enable multitenancy. Then in application.yml define datasources for each tenant. In this example the […]

Categories
Moving to Grails

2FA – with Google Authenticator

This blog post builds on the post “Security – Authentication”. The grails part of this blog is an adaption of this guide. I found some java code to use with Google authenticator and made it work. The blog post will end with a runnable sample application. Adding fields to store authenticator secret We will need […]

Categories
Moving to Grails

Security – authentication

In this blog post I will look into authentication. XPages has a built-in authentication mechanism. In order to enable authentication I edited the application’s ACL, removing anonymous access and adding the appropriate users / groups. Grails does not have built-in authentication. The documentation chapter on Authentication describes how to implement your own authentication using interceptors, […]

Categories
Moving to Grails

Grails development environment

In this blog post I will look into my development environment. IDE Eclipse I did a preliminary test GGTS which worked right out of the box. Unfortunately GGTS is made for Grails 2.x and is no longer maintained. Eclipse can be used with Grails 3, and probably Grails 4 following e.g. this guide: https://objectcomputing.com/news/2018/03/02/grails-development-eclipse It […]