-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from AtlasOfLivingAustralia/develop
PR for 3.1.2 release
- Loading branch information
Showing
25 changed files
with
408 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 3 additions & 9 deletions
12
grails-app/controllers/au/org/ala/collectory/AdminController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
grails-app/controllers/au/org/ala/collectory/AdminRoleInterceptor.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2023 Atlas of Living Australia | ||
* All Rights Reserved. | ||
* | ||
* The contents of this file are subject to the Mozilla Public | ||
* License Version 1.1 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a copy of | ||
* the License at http://www.mozilla.org/MPL/ | ||
* | ||
* Software distributed under the License is distributed on an "AS | ||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* rights and limitations under the License. | ||
*/ | ||
|
||
package au.org.ala.collectory | ||
|
||
import org.apache.http.HttpStatus | ||
|
||
|
||
class AdminRoleInterceptor { | ||
|
||
CollectoryAuthService collectoryAuthService | ||
|
||
AdminRoleInterceptor(){ | ||
match(controller: 'admin') | ||
match(controller: 'manage') | ||
match(controller: 'gbif', actionName:'healthCheck') | ||
match(controller: 'gbif', actionName:'healthCheckLinked') | ||
match(controller: 'gbif', actionName:'downloadCSV') | ||
} | ||
|
||
boolean before() { | ||
// add an exception for /manage/ and /manage/index/ as it is redirected from /admin/ - which should be visible to all logged in users. | ||
if(controllerName == "manage" && (actionName == "index" || actionName == "list")){ | ||
return true | ||
} | ||
|
||
// check against configured gbifRegistrationRole for admin gbif methods | ||
if(controllerName == "gbif" && collectoryAuthService?.userInRole(grailsApplication.config.gbifRegistrationRole)){ | ||
return true | ||
} | ||
|
||
// check roles using userInRoles.userInRole method. also returns true if user has the application configured ROLE_ADMIN. | ||
if (collectoryAuthService?.userInRole(grailsApplication.config.ROLE_ADMIN)) { | ||
return true | ||
} | ||
response.sendError(HttpStatus.SC_UNAUTHORIZED) | ||
return false | ||
} | ||
|
||
|
||
|
||
boolean after() { true } | ||
|
||
void afterView() { | ||
// no-op | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
grails-app/controllers/au/org/ala/collectory/EditRoleInterceptor.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2023 Atlas of Living Australia | ||
* All Rights Reserved. | ||
* | ||
* The contents of this file are subject to the Mozilla Public | ||
* License Version 1.1 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a copy of | ||
* the License at http://www.mozilla.org/MPL/ | ||
* | ||
* Software distributed under the License is distributed on an "AS | ||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* rights and limitations under the License. | ||
*/ | ||
|
||
package au.org.ala.collectory | ||
|
||
import org.apache.http.HttpStatus | ||
|
||
|
||
class EditRoleInterceptor { | ||
|
||
CollectoryAuthService collectoryAuthService | ||
|
||
EditRoleInterceptor(){ | ||
match(controller: 'collection') | ||
match(controller: 'institution') | ||
match(controller: 'contact') | ||
match(controller: 'licence', action: 'list') | ||
match(controller: 'licence', action: 'create') | ||
match(controller: 'licence', action: 'edit') | ||
match(controller: 'licence', action: 'show') | ||
match(controller: 'licence', action: 'save') | ||
match('controller':'providerGroup') | ||
match('controller':'providerMap') | ||
match('controller':'providerCode') | ||
match('controller':'dataResource') | ||
match('controller':'dataProvider') | ||
match('controller':'dataHub') | ||
match('controller':'reports') | ||
} | ||
|
||
boolean before() { | ||
// check roles using userInRoles.userInRole methods also returns true if user has the application configured ROLE_ADMIN. | ||
if (collectoryAuthService?.userInRole(grailsApplication.config.ROLE_EDITOR)) { | ||
return true | ||
} | ||
response.sendError(HttpStatus.SC_UNAUTHORIZED) | ||
return false | ||
} | ||
|
||
|
||
|
||
boolean after() { true } | ||
|
||
void afterView() { | ||
// no-op | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.