-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1adabf9
Showing
9 changed files
with
183 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
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,87 @@ | ||
class WeceemSpringSecurityGrailsPlugin { | ||
// the plugin version | ||
def version = "1.0-RC1" | ||
// the version or versions of Grails the plugin is designed for | ||
def grailsVersion = "1.3.1 > *" | ||
// the other plugins this plugin depends on | ||
def dependsOn = [springSecurityCore:'1.0.1 > *'] | ||
|
||
// resources that are excluded from plugin packaging | ||
def pluginExcludes = [ | ||
"grails-app/views/error.gsp" | ||
] | ||
|
||
def author = "Marc Palmer" | ||
def authorEmail = "info@weceem.org" | ||
def title = "Bridges Weceem authentication to Spring Security" | ||
def description = '''\\ | ||
Provides the glue needed to make Weceem plugin use Spring Security for authorisation and authentication. | ||
Your application still needs to configure Spring-Security however. The domain class is expected to include "email" property. | ||
''' | ||
|
||
// URL to the plugin's documentation | ||
def documentation = "http://grails.org/plugin/weceem-spring-security" | ||
|
||
def doWithWebDescriptor = { xml -> | ||
// TODO Implement additions to web.xml (optional), this event occurs before | ||
} | ||
|
||
def doWithSpring = { | ||
// TODO Implement runtime spring config (optional) | ||
} | ||
|
||
def doWithDynamicMethods = { ctx -> | ||
// TODO Implement registering dynamic methods to classes (optional) | ||
} | ||
|
||
def doWithApplicationContext = { applicationContext -> | ||
def authenticateService = applicationContext.springSecurityService | ||
applicationContext.wcmSecurityService.securityDelegate = [ | ||
getUserName : { -> | ||
def princ = authenticateService.principal | ||
if (log.debugEnabled) { | ||
log.debug "Weceem security getUserName callback - user principal is: ${princ} (an instance of ${princ?.class})" | ||
} | ||
if (princ instanceof String) { | ||
return null | ||
} else { | ||
return princ.username | ||
} | ||
}, | ||
getUserEmail : { -> | ||
def princ = authenticateService.principal | ||
if (log.debugEnabled) { | ||
log.debug "Weceem security getUserEmail callback - user principal is: ${princ} (an instance of ${princ?.class})" | ||
} | ||
return (princ instanceof String) ? null : princ.domainClass?.email | ||
}, | ||
getUserRoles : { -> | ||
def princ = authenticateService.principal | ||
if (log.debugEnabled) { | ||
log.debug "Weceem security getUserRoles callback - user principal is: ${princ} (an instance of ${princ?.class})" | ||
} | ||
if (princ instanceof String) { | ||
return ['ROLE_GUEST'] | ||
} | ||
def auths = [] | ||
auths.addAll(princ.authorities) | ||
return auths ?: ['ROLE_GUEST'] | ||
}, | ||
getUserPrincipal : { -> | ||
authenticateService.principal | ||
} | ||
] | ||
} | ||
|
||
def onChange = { event -> | ||
// TODO Implement code that is executed when any artefact that this plugin is | ||
// watching is modified and reloaded. The event contains: event.source, | ||
// event.application, event.manager, event.ctx, and event.plugin. | ||
} | ||
|
||
def onConfigChange = { event -> | ||
// TODO Implement code that is executed when the project configuration changes. | ||
// The event is the same as for 'onChange'. | ||
} | ||
} |
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,7 @@ | ||
#Grails Metadata file | ||
#Wed Jan 05 14:43:38 GMT 2011 | ||
app.grails.version=1.3.6 | ||
app.name=WeceemSpringSecurity | ||
plugins.hibernate=1.3.6 | ||
plugins.spring-security-core=1.0.1 | ||
plugins.tomcat=1.3.6 |
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,31 @@ | ||
grails.project.class.dir = "target/classes" | ||
grails.project.test.class.dir = "target/test-classes" | ||
grails.project.test.reports.dir = "target/test-reports" | ||
//grails.project.war.file = "target/${appName}-${appVersion}.war" | ||
grails.project.dependency.resolution = { | ||
// inherit Grails' default dependencies | ||
inherits("global") { | ||
// uncomment to disable ehcache | ||
// excludes 'ehcache' | ||
} | ||
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' | ||
repositories { | ||
grailsPlugins() | ||
grailsHome() | ||
grailsCentral() | ||
|
||
// uncomment the below to enable remote dependency resolution | ||
// from public Maven repositories | ||
//mavenLocal() | ||
//mavenCentral() | ||
//mavenRepo "http://snapshots.repository.codehaus.org" | ||
//mavenRepo "http://repository.codehaus.org" | ||
//mavenRepo "http://download.java.net/maven/2/" | ||
//mavenRepo "http://repository.jboss.com/maven2/" | ||
} | ||
dependencies { | ||
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg. | ||
|
||
// runtime 'mysql:mysql-connector-java:5.1.13' | ||
} | ||
} |
Binary file not shown.
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,21 @@ | ||
<plugin name='weceem-spring-security' version='1.0-RC1' grailsVersion='1.3.1 > *'> | ||
<author>Marc Palmer</author> | ||
<authorEmail>info@weceem.org</authorEmail> | ||
<title>Bridges Weceem authentication to Spring Security</title> | ||
<description>\ | ||
Provides the glue needed to make Weceem plugin use Spring Security for authorisation and authentication. | ||
|
||
Your application still needs to configure Spring-Security however. The domain class is expected to include "email" property. | ||
</description> | ||
<documentation>http://grails.org/plugin/weceem-spring-security</documentation> | ||
<resources> | ||
<resource>BuildConfig</resource> | ||
<resource>Config</resource> | ||
<resource>DataSource</resource> | ||
<resource>UrlMappings</resource> | ||
</resources> | ||
<dependencies> | ||
<plugin name='springSecurityCore' version='1.0.1 > *' /> | ||
</dependencies> | ||
<behavior /> | ||
</plugin> |
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,10 @@ | ||
// | ||
// This script is executed by Grails after plugin was installed to project. | ||
// This script is a Gant script so you can use all special variables provided | ||
// by Gant (such as 'baseDir' which points on project base dir). You can | ||
// use 'ant' to access a global instance of AntBuilder | ||
// | ||
// For example you can create directory under project tree: | ||
// | ||
// ant.mkdir(dir:"${basedir}/grails-app/jobs") | ||
// |
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,5 @@ | ||
// | ||
// This script is executed by Grails when the plugin is uninstalled from project. | ||
// Use this script if you intend to do any additional clean-up on uninstall, but | ||
// beware of messing up SVN directories! | ||
// |
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,10 @@ | ||
// | ||
// This script is executed by Grails during application upgrade ('grails upgrade' | ||
// command). This script is a Gant script so you can use all special variables | ||
// provided by Gant (such as 'baseDir' which points on project base dir). You can | ||
// use 'ant' to access a global instance of AntBuilder | ||
// | ||
// For example you can create directory under project tree: | ||
// | ||
// ant.mkdir(dir:"${basedir}/grails-app/jobs") | ||
// |