Build a Basic CRUD Application with Grails and Okta

Build a Basic CRUD Application with Grails and Okta

This tutorial adds secure controllers with Grails, OAuth 2.0, and Okta.

I am trying to integrate a grails application with okta. I followed this example in git hub where I see you as one of the contributor.

I have some isuues when I tried this. This example has a requirement where in I need to create/link the remote oauth2 account to local user account after successful authentication by okta. I do not want the overhead of maintaining a local user table again. Is there any way I can surpass this? And just go to the home controller page directly bases on the user roles. I am able to get the group claim in the okta jsonn output. How do I map this user response to Grails domain user/role class? Please help me with this

Could you please please help me with this?

This tutorial is super old and very out of date so it’s not going to be a great guide on how to integrate OAuth in a current Grails application. The tutorial was written as a server-side web application that assumed local user accounts would be created so that they could be linked to other object instances, which is generally the model that the Grails framework favored. Take a look at the Authentication section of the Grails documentation.

This doc page for the Spring Security Core Open ID plugin shows the use case you are asking about. Look under the 3.2 Plain OpenID header.

Grails is built on Spring, so you can use Spring Security as well. Spring has a lot of handy annotations, such as @PreAuthorize that you can use to implement method-level security based on OAuth 2.0 and OIDC. But this will require that you have Okta (or another OAuth 2.0 and OIDC provider) properly configured.

Here’s another link that might help you with Grails and Spring Security. It’s also, unfortunately, pretty old. 2013.

I believe we’ll be adding a new Grails tutorial soon that will update all of this.

Please let me know if that helps or if you need more info.

Andrew

Hi Andrew, I want to mock okta login , do you have any examples on mocking okta login for running integration tests in grails? I integrated grails and okta with grails spring security oauth2 plugin

Hey Andrew, did the Grails tutorial or the spring tutorial ever get an updated version? Both seem outdated, the Spring one I’ve been trying to do uses com.okta.spring:okta-spring-boot-starter:1.4.0, which results in a java.lang.NoClassDefFoundError: org/springframework/security/core/AuthenticatedPrincipal error.

Hi Logan,

No, we did not create an updated version. You can see all our Grails posts on the Okta developer blog at https://developer.okta.com/blog/tags/grails.

You might try entering an issue in the Okta Spring Boot starter project with steps to reproduce.

Hey mraible, for my use case I am stuck with Grails 3, and I found Okta’s tutorial here that fits my use case:

However, in the tutorial, a plugin is created for it and referenced, and it was hosted here (initially on Bintray, now Github):

I really need to make use of this plugin, and was curious about what licensing and usage your plugin falls under, if it is open-source, MIT, etc, or if you don’t have set licensing yet, if you’d be willing to apply a license to it so that I may use it correctly in my own project. I looked around the repo, and didn’t see any info, so if possible, please let me know what proper use this falls underneath.

Thank you!

Hi Logan,

I created an issue to add a license in hopes that Andrew reads it.

FWIW, he moved to Nepal last summer and is no longer writing tutorials and examples for us.

If he doesn’t respond in a few days, I’d recommend forking the repo and adding your own license.