Using a Controller and Restcontroller to allow users to access any page - spring

I am using Spring Framework to build a webapp. I have a restcontroller that verifies the user (Google oAuth) and sends responses to the page to determine if the user is valid. There is another page on the site, however, called storage. If the user wanted to go straight to mysite.com/storage. How would I send the user to that page? I tried having a regular controller to direct the user there but I get a circular path error. What is the right practice here? Am I missing anything? Thanks. let me know if you need more information.

Related

Spring Social LinkedIn - how to conditionally redirect or pass parameters?

We're using Spring Social LinkedIn in a single page javascript app to authenticate a user. We're able to successfully authenticate against LinkedIn, but we're having trouble getting that to integrate with our javascript app. It actually breaks down into two issues:
Issue 1:
We're using one API key for a set or related apps - and we use a single sign-in process. We need a way to identifiy which app the user came from and to send them back to the right app after logging in. The problem we're having is LinkedIn only allows one redirect URL and I don't believe it can carry any parameters (that would probably be the solution if it's possible to carry a parameter like the identifier of the app they're in). Do you know of a way to conditionally redirect the person after login?
Issue 2:
When the user is authenticated, we store the user info in our database, but after that we need the log the user into our app and provide the user with a token. Is there a way after the LinkedIn authentication completes to trigger another call to the server to request the token?

BreezeJS + Asp.Net Web Api Security

I have been looking at BreezeJS and I want to try it but I searched a lot and still cannot understand how security is handled while using Breeze. Here is what I know:
According to a post on IdeaBlade forums (creators of BreezeJS), we only need a single Api Controller for all of our entities. The Api controller will contain one MetaData method, one Get method for each entity, one Save method, one Delete method. So this way we only need one EntityManager on client side configured with one service endpoint.
My questions:
My understanding of "single controller for all entities" is correct?
If my understanding is correct then how can we apply security on our controller? If I want a user with certain role to access only certain entities, I obviously cannot put an Authorize filter on my controller or method. May be I want a certain user to have read-only access while other users having read-write access on a certain entity. May be I only want to return aggregated data to user while restricting access to full details.
Please help. Thanks.

check for username against password in base controller mvc 3

I want to know how can I force a user to log in the the application again if the page is being opened in new tab or new browser.
Edit:-
My apologies I misunderstood the requirement.
I am authenticating the user in my log-in page but not anywhere else. So what is happening because of that, even if i log out of application and type url say bla.com/apple I can access my application.
I figured to prevent this from happening, I have to write a base controller that checks for the right user. Am I moving in the right direction.
Thanks
Addressing the edit -
Authentication can be handled per controller or on individual actions. Simple place the [Authorize] attribute appropriately. This assumes however that somewhere an authentication token is being set. [Authorize] checks against the HttpContext's current User (an IPrincipal).
You mentioned above that you're just validating against a local username and password, in one place, so I'm guessing that no token (session, cookie) are being set?
You have a few options here to get that token stored and persisted across requests:
ASP.Net integrated membership provider (Intro)
A custom MembershipProvider (Example)
Full-on custom flow. (Example)
Each has ups and downs and depends on how exactly you want to handle on-boarding your users. It's hard to answer more specifically because it can be a very large topic (and a very broad question).
Here's the official pages for MVC security.

How do I access authorized user properties in the WebSphere application Lawson?

I'm assisting another developer with adding a link to a page in a product called Lawson that we use in-house. I need to pass the authenticated user's employee ID to an HTML page we're bolting on. I'm still looking at existing pages on the server, but thought I'd ask: does anyone know how the Javascript object that represents the authenticated user works? It looks like something server-side must be dynamically creating a Javascript object that has useful properties. It is usually called 'AuthUser'. I want to add the necessary JS references to my new page to support this object and access its properties. Does anyone have any experience with that? Thanks!
If you are in a portal session, you can access this in javascript through attributes of portalWnd.oUserProfile:
alert(portalWnd.oUserProfile.getAttribute("id"))
This will give you the logged in user's short username. Many other attributes are available. To see a complete list, log into a portal session and then replace the URL with:
http://YOURPORTALSERVER/servlet/Profile
I'm not sure what you mean by "bolting on", but if you want to pass an attribute to an external page launched from a Portal session, you could create a user shortcut via Portal preferences using something like:
javascript:window.open("http://yourserver/yourpage.html?user=" + portalWnd.oUserProfile.getAttribute("id"))
as the target and process in yourpage.html like a normal GET method form.
If you are still puzzling over this all these months later, provide some specifics if you need more guidance.

How to make a particular action publicly available while keeping everything else private

I was able to successfully implement FormsAuthentication and use the Authorize Attribute to control which roles are authorized to access the different controllers and actions. I want to allow one particular action to be publicly available but It always send me to the login form.
I've tried using
[Authorize(Users="?")]
or
[Authorize(Users="*")]
but both send me to the login form.
however
[Authorize(Users="Admin")]
will only send non admin user to the login form as expected. Is this possible to do? Thank you.
I was able to accomplish what I wanted to do by following this article: http://blogs.msdn.com/b/rickandy/archive/2011/05/02/securing-your-asp-net-mvc-3-application.aspx

Resources