SAML2.0 SSO with the WSO2 Identity Server? - java

I need to use WSO2 Identity server with SAML for SSO for my internal application. I came across this beautiful
SAML2.0 SSO with the WSO2 Identity Server article
But i have two questions on this article which i am not sure how works
1) In 5th step it is said "Now the user is being redirected to IDP again. Now the IDP realize this user is already authenticated hence it would issue
a SAML Assertion without prompting any authentication challenge."
How will the IDP realize that user is already authenticated ?
As per my understanding it must be done based on session. Does it mean when authentication request goes from service provider 1 to Identity server (SP1 redirects the request to IS thru browser ), IS will first authenticate the credentials and if successful keep the user object under session.
Now when second authentication request goes to IS thru SP2, same session ID is sent (provided request is sent from another of same browser), IS fins already a user object associated with this session, so trust him. Is this understanding correct?
2)In step 2 it is said that " Now the SP1 can validate the SAML Assertion issued by IDP and let the user log-in. "
what is the specific field/value (under SAML response sent by IP) , SP1 will verify?
3) Where user credentials are stored. Is it on IS side or Service provider side?

Just explain how it works with WSO2IS 5.0.0
When user is authenticated to IDP by providing credentials. WSO2IS creates an authenticated session for user and cookie with is associated with the authenticated session set in to the user's browser. Cookie name would be commonAuthId. you can also find it in your browser once you are authenticated with WSO2IS using SSO. Then user is trying to access another SP using same browser, cookie would be sent in to the WSO2IS and it identifies that there is an authenticated session related to the cookie.
Usually, SP validates the SAML2 Response and Assertion. There are several validations that you can do. But most common would be
Signature of the SAML2 Response and SAML2 Assertion
Validity period SAML2 Response and SAML2 Assertion.
Audience restriction validation in SAML2 Assertion
Destination url and Recipient value
Normally Username would be extracted from the Subject identifier value. Also there may be attributes in the attribute statement, which SP can retrieve and do some validation over them as well.
End users are authenticated to the IDP. So credentials must be in IDP not with the SP. It is one of idea of SSO. Maintains the credentials in one place. WSO2IS is default shipped with LDAP based user store. Therefore end user credentials are stored in the LDAP server. However WSO2IS can be deployed with any existing user stores that you like

Related

Is it possible to have dp iniated SSO and sp Initated SSO can co exist in spring saml web app?

I am having a spring SAML application where user will be initiated from the idp at the first time login and during manager override screen, sp will initiate the sso request for the manager to idp. During this situation, the browser will store two idp cookie session of base user and his manager, Or manager's sso idp cookie session will override the existing base user sso cookie session?
Both user uses the same idp provider (ex:Okta)
i have searched a lot over the internet and nothing gives an answer.
Kindly advice.
Typically so called 'session cookies' are stored in the browser's memory and send to the 'server'. If the 'server' sees this cookie, it consideres the user to be authenticated and does not prompt for further authentication. If the 'base user' and the 'manager' use the same browser, the 'manager' will not be propmpted for authentication.
This standard behavior can only be changed, when the attribute ForceAuthn is set to true in the SAML AuthnRequest sent in SP-initiated SSO flow, the IdP must always prompt for authentication.

Websphere 9, how to check incoming ltpatoken2

Good day
I have an incoming request to my application based on websphere 9 with ltpatoken2 cookie.
Previously, the ltpa key was exported from my websphere and add to another server. The option Application security was enabled.
How I can check, at websphere or at my application, that the token is exists and correct?
And my application should be not avialable for requests without token.
In WebSphere 9, if request contains a LTPA cookie, LTPA cookie will be processed automatically. Inside your application code, if you call API com.ibm.websphere.security.auth.WSSubject.getRunAsSubject(), you will see a subject created form the ltpa token if LTPA token is presented and is also valid.
And you will see unauthenticated subject if ltpa is missing or invalid. Or inside your application, if you call HttpServletRequest.getPrincipal().getName(), you will see a user name represented by the LTPA cookie if it presents and valid, and you will see principal name or see unauthenticated user name if LTPA is missing or invalid.
There's no API to inspect that token, but you can test it implicitly. You can capture browser traffic with Firefox or Chrome developer tools, then after successful login, using either the browser tools or curl, send a modified request without the cookie, or with a bad cookie value, and you should get an authentication challenge since the cookie's not there.
The easiest would be to just add security constraints to your web.xml protecting whole application (you will find many examples), and map security role to All authenticated. Then your application will be available only, if user is already logged in (so the LTPA token exists and is correct), otherwise it will redirect you to login page that you can include in your application and redirect user somewhere, informed that he is not logged in, or whatever you want to do in case there is no valid LTPA token.

Avoid SPNEGO authentication for each request

I have a webserver which is using Jetty underneath along with SPNEGO authenticator and login service. I am using Firefox to connect to this webserver and can see that authentication is happening properly. But the issue is for each request from web client authentication is happening again and again, rather than only at first request. Does Jetty store any information to differentiate between an authenticated and unauthenticated user ? If not then can someone please help to recommend how I can achieve that? Also what it means to logout a user already authenticated using SPNEGO ?
The problem is not SPNEGO authentication but how you are managing session.
Once authenticated create a HTTP session and add the user's details to the session, and using a Filter check that there is a valid session is present if not do the authentication else skip the authentication.

SSO OAuth2Authentication session and server side http request

I am interested in opportunity to make server side http request to web server implementing same SSO authentication.
So assume I have: hello.org and hey.com that point to the same SSO server.
After I logged in hello.org I obtained:
OAuth2Authentication authenticationObject = (OAuth2Authentication) principal;
Now I would like to fire http request from hello.org server to hey.com
Request.Get("hey.com/get_data").execute().returnContent().asString();
But I hit authentication error code 401.
How can I retrieve all required tokens from OAuth object and make my request be authenticated?
the site hello.org is not supposed to call hey.com using the token provided to the client calling hello.org. That token is to be seen as a contract between the authenticated user and hello.org.
The hello.org server needs it's own client that is authorized to access hey.com.
So one common way to solve this is to create a "hello.org to hey.com" client with either key or certificate authentication against the sso provider, and then call hey.com with the token provided there, and then relay the info back to the user of hello.org.
Now that is if you want to call hey.com via hello.org and the user is unaware that hey.com was ever involved in the information provision.
If you on the other hand want to let the user access both hello.org and hey.com by signing in via hello.org you should check out either OpenId or SAML since bare bones Oauth isn't really designed for SSO or resource sharing.

SSO using saml2.0 in opensaml

We have 4 applications. And we want to implement SSO across these apps. I have several doubts regarding this. We were suggested to use opensaml.
Query 1:
The username and password entered by the user is sent by client(Ex.Front-end) to the middleware and then the middleware send this information to the SSO server,Then in this case
Is the user a principal??
Is the middleware a Service Provider?
Is the SSO server a Identity Provider?
Query 2:
Now when an user logins in one of the application then we should connect to Identity Provider to initiate the SSO, what parameters(Mandatory) should be sent the by us to SSO server??
Query 3:
When After getting response from SSO server, Should middleware keep the token for future reference?
Query 4:
Now if the another user hits another application then it should be identified that there is sso working on. How to identify that?
Should the middleware hit the SSO server for that?
Kindly resolve above queries.
1) Yes, the 'middleware' you describe is the Service Provider and the 'SSO server' is the Identity Provider.
2) When the user attempts a protected resource on the Service Provider, it will redirect the browser to the Identity Provider. If the browser does not have an active session with the Identity Provider the user will be prompted for login details.
Following which the browser will be redirected back to the Service Provider along with the SAML response authenticating the user. After verifying the SAML response the Service Provider will redirect to the protected resource.
Once the user is authenticated the Service Provider can keep it's own session to save redirecting to the Identity Provider for every request.
3) The Service Provider (middleware) would not normally keep the SAML response from the Identity Provider, instead it can set up it's own session. For example in .Net this can be down via Forms Authentication.
4) When the user tries to access another Service Provider, the browser will be redirected to the Identity Provider. As the user already has an active session, the Identity Provider will redirect back to the Service Provider with the SAML repsonse. The service provider will then redirect to the protected resource and optionally create it's own session.
This happens seamlessly to the user, and they are effectively logged straight into the second Service Provider.
Also which platform are you using for development? If you are using .NET or Java then I can recommend the open source library OIOSAML. It includes working examples of both Service and Identity Providers so you can see how things work.
What IDP are you thinking of using?
In the SAML world, all the URL's, certificates etc. are exchanged via metadata.
So in the IDP you would import sp.xml and in the SP you would import idp.xml.
For Java, you would need some kind of SAML stack on your SP side.
Refer: SAML stack and Java equivalent to WIF.

Categories

Resources