8000 Access principal in success view by mmoayyed · Pull Request #674 · apereo/cas · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Access principal in success view #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 15, 2014
Merged

Access principal in success view #674

merged 12 commits into from
Oct 15, 2014

Conversation

mmoayyed
Copy link
Member

This fixes #669

@mmoayyed mmoayyed added this to the 4.1 milestone Aug 23, 2014
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 3d5912e on Unicon:principal-success-view-669 into * on Jasig:master*.

@@ -44,7 +44,7 @@ screen.confirmation.message=Click <a href="{0}">here</a> to go to the applicatio

#Generic Success Screen Messages
screen.success.header=Log In Successful
screen.success.success=You have successfully logged into the Central Authentication Service.
screen.success.success=You, {0}, have successfully logged into the Central Authentication Service.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to do that for other languages as well. Would you mind opening an issue for that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect

@leleuj
Copy link
Contributor
leleuj commented Aug 25, 2014

+1 with a few comments

Conflicts:
	cas-server-webapp/src/main/webapp/WEB-INF/webflow/login/login-webflow.xml
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 816b667 on Unicon:principal-success-view-669 into * on Jasig:master*.

@battags
Copy link
Contributor
battags commented Sep 2, 2014

Is there a reason we're adding official support via this API (which made sense to do when it was an add-on) versus better built-in support on the CentralAuthenticationService interface itself?

@mmoayyed
Copy link
Member Author
mmoayyed commented Sep 2, 2014

Scott, how do you envision CAS (CentralAuthenticationService) be changed to support this?

@mmoayyed
Copy link
Member Author

Bump

@battags
Copy link
Contributor
battags commented Sep 17, 2014

Sorry this got lost in my inbox :-(. I guess I'm really asking if we're building this into CAS proper why aren't we thinking about how we can augment the CentralAuthenticationService interface. What do we get from using something like AuthenticationSupport? I think AuthenticationSupport made sense when it was a Unicon add-on, you couldn't go around mucking with interfaces in core. But if we deem this functionality to be important, we would want to encapsulate it behind our main service interface, right?

@mmoayyed
Copy link
Member Author

Sure, I would welcome augmentations to the CAS interface; I am just not sure or seeing how any changes to the interface body would allow access to principal in this particular view. I am just not seeing the link. The op is pretty view-specific and does not have much to do with CAS interface itself. Maybe an option would be to add a method to the interface, to return the principal from a TGT and have that method be invoked by the view. That's marginally relevant at best.

The AuthenticationSupport API is useful in some ways, because it allows one to construct an authentication object from a TGT without direct access and plugging in a ticket registry instance. That's about it; a layer of abstraction that encapsulates and makes it easier for this PR, or other possible extensions who'd want to peek into an authentication object.

@leleuj
Copy link
Contributor
leleuj commented Sep 17, 2014

Conceptually speatking, I think both interfaces do not the share the same objectives: one is protocol-oriented while the other one is authentication-oriented. Might be worth keeping both.

Conflicts:
	cas-server-webapp/src/main/webapp/WEB-INF/spring-configuration/applicationContext.xml
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) when pulling 29c5f64 on Unicon:principal-success-view-669 into 73af271 on Jasig:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) when pulling 8e04f7c on Unicon:principal-success-view-669 into 73af271 on Jasig:master.

@mmoayyed
Copy link
Member Author

Bump.

@battags have you had a chance to review this? Do the comments make sense?

@battags
Copy link
Contributor
battags commented Sep 29, 2014

The reason I'm against the AuthenticationSupport interface is that basically its intended so we can say we don't access the ticket registry directly but really it just accesses the ticket registry directly with no intention of any business logic. The CAS API is intended to be the business layer for ensuring our business logic gets executed when interacting with tickets.

@mmoayyed
Copy link
Member Author

I hear you. At the same time, the business logic really "is" to get into the registry and grab the authentication/principal from the TGT. Looking over this once more, we might be able to do away with this interface. One possible option might be to allow AuthenticationViaFormAction to put the principal into a webflow scope and later on make it available to the view. That class seems like it has everything we need to make this happen, as it already references the registry and pulls the TGT object out.

How does that sound?

@battags
Copy link
Contributor
battags commented Sep 29, 2014

But there's more business logic that should be executed. We shouldn't return a principal to you if the ticket is expired, etc.

Is there a reason not to have a getTicketGrantingTIcket (or getSession if we want to generalize the words to not be CAS specific) on the CentralAuthenticationService interface? Because really AuthenticationViaForm should not be going into the registry directly either :-)

@mmoayyed
Copy link
Member Author

That would be fine too; I just had in mind similar to @leleuj that we'd want to keep that interface to be solely about protocol-specific functions and no other auxiliary cases. Putting those additional checks and etc in the new method would be reassuring as double safety, because I think the generic-success view is only presented if the TGT is valid all around, right? We have got other actions that execute prior to rendering that view that check for the ticket's validity.

P.S: getTicketGrantingTicket makes better sense to me, as the rest of the codebase is geared towards that kind of terminology for now. Introducing a session concept, at this point, would be a bit confusing in view of everything else that deals with a TGT vocabulary.

@mmoayyed
Copy link
Member Author
mmoayyed commented Oct 7, 2014

Thinking about this a bit more: I am trying to envision what the getTicketGrantingTIcket() on the CAS interface would be like; it would have to be invoked as an on-entry action when the view renders right? and it would also make the TGT available to the view, from which authentication and then principal would be gleaned? Granted, the flow itself perhaps can be configured to set flowscope attributes for principal, but if getTicketGrantingTIcket() returns null for some reason, wouldn't the flow crash with an NPE when trying to set principal on the flowscope? It seems like we'd have to execute a bunch of code to get the principal across to the view and that would also require a proxy abstraction like the AuthenticationSupport? or am I off here?

@battags
Copy link
Contributor
battags commented Oct 8, 2014

You'd possibly require some view level equivalent of a controller (or most likely you could also handle that purely via webflow logic) -- if you want to call that controller/view equivalent AuthenticationSupport I've got no problem with that other than that I think that's a poor name for something encapsulating view level logic :-). But that's completely different than ensuring that business logic is actually executed which is not the responsibility of any layer other than the CentralAuthenticationService. You can't get to a TGT unless its valid and the only thing that checks validity is a service layer. The registry is just for storage/retrieval.

@mmoayyed
Copy link
Member Author
mmoayyed commented Oct 8, 2014

Sounds good, thanks for the suggestion. I like the view level equivalent approach, and will try to get something implemented to that effect.

@mmoayyed
Copy link
Member Author
mmoayyed commented Oct 8, 2014

So, I have included a new method on the CAS interface to return the ticket granting ticket, and a flow action to pass the principal from that TGT onto the flow, plus some tests cases to prove this all works!

@@ -202,22 +202,17 @@ public CentralAuthenticationServiceImpl(final TicketRegistry ticketRegistry,
@Transactional(readOnly = false)
@Override
public List<LogoutRequest> destroyTicketGrantingTicket(final String ticketGrantingTicketId) {
Assert.notNull(ticketGrantingTicketId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do these changes have to do with the issue? Is it because you created that getTicketGrantingTicket method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; there were a bunch of calls in CASImpl to get the TGT from the registry; all pretty much doing the same thing a getTicketGrantingTicket. So I made sure all of that is routed to getTicketGrantingTicket now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing I wanted to note/call out here (can't remember if I did) was that unless Spring changed their proxying, if getTicketGrantingTicket() had an @transactional(readonly=true) on it and we called it from within another method the internal call wouldn't be through the proxy.

@battags
Copy link
Contributor
battags commented Oct 9, 2014

+1 just a few minor comments/questions

@mmoayyed
Copy link
Member Author

Any other comments/suggestions? this looks good to everyone?

@mmoayyed
Copy link
Member Author

P.S: Oh, forgot to mention that I did account for Scott's comments.

@battags
Copy link
Contributor
battags commented Oct 13, 2014

No other suggestions just called out one thing with respect to transactions that may or may not be a concern. :-)

@mmoayyed
Copy link
Member Author

Good call. I'll account for the change before merging in.

mmoayyed pushed a commit that referenced this pull request Oct 15, 2014
@mmoayyed mmoayyed merged commit d74adb0 into apereo:master Oct 15, 2014
@mmoayyed mmoayyed deleted the principal-success-view-669 branch October 15, 2014 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0