-
Notifications
You must be signed in to change notification settings - Fork 116
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
Showing
31 changed files
with
648 additions
and
36 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 |
---|---|---|
|
@@ -15,3 +15,4 @@ grails-app/i18n | |
|
||
#Generated by test script | ||
foo/ | ||
/out |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The Spring Security Rest plugin fires events exactly like Spring Security Core does. |
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,16 @@ | ||
You can set up event notifications in two ways. The sections that follow describe each approach in more detail. | ||
|
||
* Register an event listener, ignoring events that do not interest you. Spring allows only partial event subscription; you use generics to register the class of events that interest you, and you are notified of that class and all subclasses. | ||
* Register one or more callback closures in @grails-app/conf/Config.groovy@ that take advantage of the plugin's @grails.plugin.springsecurity.rest.RestSecurityEventListener@. The listener does the filtering for you. | ||
|
||
h4. AuthenticationEventPublisher | ||
|
||
Spring Security Rest publishes events using an [AuthenticationEventPublisher|http://docs.spring.io/spring-security/site/docs/3.2.x/apidocs/org/springframework/security/authentication/AuthenticationEventPublisher.html] which in turn fire events using the [ApplicationEventPublisher|http://docs.spring.io/spring/docs/3.1.x/javadoc-api/org/springframework/context/ApplicationEventPublisher.html]. By default no events are fired since the @AuthenticationEventPublisher@ instance registered is a @grails.plugin.springsecurity.rest.authentication.NullRestAuthenticationEventPublisher@. But you can enable event publishing by setting @grails.plugin.springsecurity.useSecurityEventListener = true@ in @grails-app/conf/Config.groovy@. | ||
|
||
You can use the @useSecurityEventListener@ setting to temporarily disable and enable the callbacks, or enable them per-environment. | ||
|
||
h4. Token Creation | ||
|
||
Currently the Spring Security Rest plugin supports a single event in addition to the default spring security events. The event is fired whenever a new token is created. See @grails.plugin.springsecurity.rest.RestTokenCreationEvent@ | ||
|
||
*Note:* Every time a token is successfully submitted, an @AuthenticationSuccessEvent@ will be fired. |
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,13 @@ | ||
Alternatively, enable events with @grails.plugin.springsecurity.useSecurityEventListener = true@ and register one or more callback closure(s) in @grails-app/conf/Config.groovy@ and let @SecurityEventListener@ do the filtering. | ||
|
||
Implement the event handlers that you need, for example: | ||
|
||
{code} | ||
grails.plugin.springsecurity.useSecurityEventListener = true | ||
|
||
grails.plugin.springsecurity.onRestTokenCreationEvent = { e, appCtx -> | ||
// handle RestTokenCreationEvent | ||
} | ||
{code} | ||
|
||
None of these closures are required; if none are configured, nothing will be called. Just implement the event handlers that you need. |
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,26 @@ | ||
Enable events with @grails.plugin.springsecurity.useSecurityEventListener = true@ and create one or more Groovy or Java classes, for example: | ||
|
||
{code} | ||
package com.foo.bar | ||
|
||
import org.springframework.context.ApplicationListener | ||
import grails.plugin.springsecurity.rest.RestTokenCreationEvent | ||
|
||
class MySecurityEventListener | ||
implements ApplicationListener<RestTokenCreationEvent> { | ||
|
||
void onApplicationEvent(RestTokenCreationEvent event) { | ||
// The access token is a delegate of the event, so you have access to an instance of @grails.plugin.springsecurity.rest.token.AccessToken@ | ||
} | ||
} | ||
{code} | ||
|
||
Register the class in @grails-app/conf/spring/resources.groovy@: | ||
|
||
{code} | ||
import com.foo.bar.MySecurityEventListener | ||
|
||
beans = { | ||
mySecurityEventListener(MySecurityEventListener) | ||
} | ||
{code} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Define the following block in your @Config.groovy@: | ||
|
||
{code} | ||
grails { | ||
plugin { | ||
springsecurity { | ||
|
||
rest { | ||
|
||
oauth { | ||
|
||
frontendCallbackUrl = { String tokenValue -> "http://my.frontend-app.com/welcome#token=${tokenValue}" } | ||
|
||
cas { | ||
|
||
client = org.pac4j.cas.client.CasClient | ||
casLoginUrl = "https://my.cas-server.com/cas/login" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
{code} | ||
|
||
Set @casLoginUrl@ to the login URL of your CAS server. |
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.