-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added docs for login flows for user and client. Added protected confi…
…rm page in the OauthController. Added BootStrap to test interaction with provider and client. Fixed bug with filter position not being loaded correctly on startup.
- Loading branch information
1 parent
434cf9b
commit 4d9277d
Showing
6 changed files
with
181 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import org.springframework.security.oauth2.provider.BaseClientDetails; | ||
import grails.util.Environment; | ||
|
||
class BootStrap { | ||
def grailsApplication | ||
def clientDetailsService | ||
|
||
def init = { servletContext -> | ||
// Add client to oauth provider | ||
def client = new BaseClientDetails() | ||
client.clientId = "clientId" | ||
client.clientSecret = "clientSecret" | ||
client.authorizedGrantTypes = ["authorization_code", "refresh_token", "client_credentials"] | ||
clientDetailsService.clientDetailsStore = [ | ||
"clientId":client | ||
] | ||
} | ||
def destroy = { | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
grails-app/controllers/grails/plugins/springsecurity/oauthProvider/OauthController.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,23 @@ | ||
package grails.plugins.springsecurity.oauthProvider | ||
|
||
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils | ||
import grails.plugins.springsecurity.Secured | ||
|
||
class OauthController { | ||
def verificationCodeFilter | ||
def clientDetailsService | ||
|
||
/** | ||
* Show the confirm page | ||
*/ | ||
@Secured(["IS_AUTHENTICATED_REMEMBERED"]) | ||
def confirm = { | ||
def config = SpringSecurityUtils.securityConfig | ||
def clientAuth = verificationCodeFilter.authenticationCache.getAuthentication(request, response) | ||
|
||
String postUrl = "${request.contextPath}${config.oauthProvider.user.authUrl}" | ||
[postUrl: postUrl, approvalParameter: config.oauthProvider.user.approvalParameter, | ||
approvalParameterValue: config.oauthProvider.user.approvalParameterValue, | ||
client:clientDetailsService.loadClientByClientId(clientAuth.getClientId())] | ||
} | ||
} |
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,67 @@ | ||
<head> | ||
<meta name='layout' content='main' /> | ||
<title>Login</title> | ||
<style type='text/css' media='screen'> | ||
#login { | ||
margin:15px 0px; padding:0px; | ||
text-align:center; | ||
} | ||
#login .inner { | ||
width:260px; | ||
margin:0px auto; | ||
text-align:left; | ||
padding:10px; | ||
border-top:1px dashed #499ede; | ||
border-bottom:1px dashed #499ede; | ||
background-color:#EEF; | ||
} | ||
#login .inner .fheader { | ||
padding:4px;margin:3px 0px 3px 0;color:#2e3741;font-size:14px;font-weight:bold; | ||
} | ||
#login .inner .cssform p { | ||
clear: left; | ||
margin: 0; | ||
padding: 5px 0 8px 0; | ||
padding-left: 105px; | ||
border-top: 1px dashed gray; | ||
margin-bottom: 10px; | ||
height: 1%; | ||
} | ||
#login .inner .cssform input[type='text'] { | ||
width: 120px; | ||
} | ||
#login .inner .cssform label { | ||
font-weight: bold; | ||
float: left; | ||
margin-left: -105px; | ||
width: 100px; | ||
} | ||
#login .inner .login_message {color:red;} | ||
#login .inner .text_ {width:120px;} | ||
#login .inner .chk {height:12px;} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id='login'> | ||
<div class='inner'> | ||
<g:if test='${flash.message}'> | ||
<div class='login_message'>${flash.message}</div> | ||
</g:if> | ||
<div class='fheader'>Please Confirm</div> | ||
<div>You hereby authorize <b>${client.clientId}</b> to access your protected resources.</div> | ||
<form action='${postUrl}' method='POST' id='confirmationForm' class='cssform'> | ||
<p> | ||
<input name='${approvalParameter}' type='hidden' value='${approvalParameterValue}' /> | ||
<label><input name="authorize" value="Authorize" type="submit" /></label> | ||
</p> | ||
</form> | ||
<form action='${postUrl}' method='POST' id='denialForm' class='cssform'> | ||
<p> | ||
<input name='${approvalParameter}' type='hidden' value='not_${approvalParameterValue}' /> | ||
<label><input name="deny" value="Deny" type="submit" /></label> | ||
</p> | ||
</form> | ||
</div> | ||
</div> | ||
</body> |