简体   繁体   中英

Grails - how to create a second domain controller that is public

I'm still pretty new to the grails framework and working on legacy application based on grails 2.

I have a domain controller allowing authenticated users to do all basic CRUD actions (create, read, update and delete), with "Read" including list and show. I need to create another controller/view now allowing any user (non authenticated ones too) to be able to read only (list and show).

I looked around but could not find any "tuto" to do so ...then here's my question: What would be the best approach to complete this task?

I looked into 2 options: Option 1 Modifying the current domain controller (class level) @secured annotation in order to annotate only create, update and delete methods. I tried to do so, but it seems like I still have to authenticate which I suspect is related to SpringSecurity "grails.plugin.springsecurity.controllerAnnotations.staticRules" config that I may need to modify too.

Option 2 Create a new controller from scratch (but I guess I can't ask Grails to generate a second domain controller for the same class) then it means quite some work to build up all the data I need.

I'm not even sure if any of the 2 options above is recommended... has anyone faced this problematic (I'm sure many have) and if so ... what was the recommended approach?

Thanks.

I have a project that use the USER_ROLE to give access to different people to different parts of the project. But people still need to login.

I also have another project in C#. There is 2 copies of the same project. The public project is a copy of the main project. However, the public project is accessing the VIEWs set up from the database. It is not accessing the actual tables. So, the public project can have only read only access to a subset of the database records. It is only reading the VIEWs.

I am new to Grails. I don't know if you can set up the domain to access a view or not.

I am thinking outside the box. For your project, is it possible for you to create a new "public-read-only" project. Copy and paste the parts from the main project to the new "public-read-only" project that you want to give people to access.

In this case, your new project is a subset of the main project but it is accessing the records from the actual database tables.

What do you think?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM