wearebob
wearebob

Reputation: 415

SAML protected resource

I am trying to protect a resource using SAML. There are three actors at play: identity provider (IDP, outside of my control), service provider (SP, I happen to be using spring-security-saml, but this question is not specific to that), and the protected resource (PR, some protected endpoint in a service outside of the SP).

There are two scenarios that I need to support:

  1. The user attempts to access the PR for the first time, without any kind of session.
  2. The user attempts to access the PR again, when they have previously accessed it.

There is ample guidance on how scenario 1 should work as it is the standard way to use SAML from what I've seen. Scenario 2 seems to be less standard though and I have yet to find any definitive documentation on how it should be handled.

In scenario 1, the flow seems to be standard:

It is scenario 2 that I am less clear on, my thinking is the following:

My questions are:

Upvotes: 0

Views: 158

Answers (1)

codebrane
codebrane

Reputation: 4650

There can be two conditions for accessing the PR.

  1. A valid application session created by PR with a specified time before it needs to be renewed.
  2. A valid SAML token on which to base the application session.

The PR could take the view that as long as the SAML token is valid then the application session is valid. Or it could decide it wants to create a new session every 10mins, which means redirecting to the IdP to get a new SAML token on which to base the new application session. It depends on the resource being protected. In a sensitive resource, medical data perhaps, the session should be managed accordingly.

In terms of SAML token validity, the IdP issues the token for a set period of time using Response/Conditions/NotBefore and Response/Conditions/NotOnOrAfter which are shown in the examples. There is also Response/AuthnStatement/SessionNotOnOrAfter which can be used to check validity. This:

Gets or sets the time instant at which the session between the principal identified by the subject and the SAML authority issuing this statement must be considered ended

from here. This effectively limits the PR session as the IdP "disowns" the user after this time. e.g. a public walk-in access request for an hour's access to PR. NotOnOrAfter refers to the assertion while SessionNotOnOrAfter refers to the user. After SessionNotOnOrAfter the IdP might not authenticate the user depending on policy etc.

If the PR needs to renew the application session, it could ask the SP to validate the SAML token, which could involve working out whether NotOnOrAfter is in the past. If it is, then the SP would start the process with the IdP again to get a new SAML token. If an IdP is dealing with a sensitive PR, it may release attributes for a limited time, depending how access is granted at its end.

Upvotes: 2

Related Questions