WS-Trust tutorials

Copied from the id-proto-debugger release 0.9.5 user guide, which is the debugger this service embeds. Its addresses are the embedded ones: the debugger is https://localhost:8444/ and its api https://localhost:8444/api. Accessing the debugger says how to reach, enable and disable it.

Each tutorial is one way the WS-Trust workflow is used. Start from wstrust_tools.html (the WS-Trust Protocol card). The fields are in reference.md. What the messages are is in protocol.md.

The pictures were taken against iya-sts at https://localhost:8081/sts, as the account guide-wstrust. In product mode the Password field is an application password scoped to WS-Trust, not the account password. It is typed into the field and is not stored. The pictures show that field masked. Another security token service has its own accounts and its own rule for AppliesTo. What iya-sts requires in product mode is in setup-iya-sts.md.

Initiate STS Call From stays on Backend (proxy) in every walk below. The STS URL then has to be reachable from the api.

Issue a bearer token

WS-Trust 1.4 Issue. The token is a SAML 2.0 bearer assertion for urn:wstrust:test:rp. The caller is a UsernameToken.

  1. Set STS URL to the service. An empty field is filled with https://localhost:8081/sts on this deployment. Load reads what the service publishes about itself, when it publishes anything.

    The STS URL

  2. Leave WS-Trust Version on 1.4, Operation on Issue, Token Type on SAML 2.0, and Key Type on Bearer. AppliesTo is the relying party the token is for. Lifetime (minutes) is 60 unless you change it. On iya-sts in product mode that audience has to be registered before Issue or Renew will answer.

    Issue request fields

  3. Under Credentials / WS-Security, leave Credential on UsernameToken. Type the account. On iya-sts in product mode, type an application password scoped to WS-Trust, not the account password. Password Type stays PasswordText. The password is not written to storage.

    UsernameToken, password masked

  4. Leave Initiate STS Call From on Backend (proxy). Validate STS TLS certificate (backend) stays on when the api trusts the service. Generated Request is the SOAP that will be sent. Press Send Request.

    Backend send and the request

    If the status line says the certificate was refused, the api does not trust that service’s certificate. Clear Validate STS TLS certificate (backend) and press Send Request again. A stack that issued the api and the service from one root does not need this. The picture is that refusal on a service whose certificate is not the debugger’s.

    The certificate refusal

  5. wstrust_response.html opens on the answer. Response (RSTR) is the RequestSecurityTokenResponse.

    The Issue response

  6. Issued Token, on Token XML, is the SAML assertion inside RequestedSecurityToken. The box indents that assertion so it can be read. The indent is not part of what the service signed. Copy copies the assertion as it was issued, which is what OnBehalfOf and ActAs have to present when the service checks the signature.

    The issued assertion

  7. Fields is the same answer in rows: the operation, the SOAP and HTTP status, the token type, the key type, AppliesTo, and the lifetime.

    The response fields

Copy the assertion from Token XML. Renew, Validate, Cancel, and the delegation walks paste it back.

Renew, validate, and cancel

The three operations that act on a token you already hold. Paste the assertion from the issue walk into Target Token. Authenticate again with the same UsernameToken. The audience stays the one the token was issued for.

  1. Set Operation to Renew and paste the assertion into Target Token. It is sent as RenewTarget.

    Renew and the target token

  2. Press Send Request. The response carries a new lifetime. Fields shows it beside the status.

    The Renew response

  3. Set Operation to Validate, paste the token you want checked (the renewed one, if Renew replaced it), and send. Fields shows the status code. A token the service still accepts is valid.

    Validate status

  4. Set Operation to Cancel, paste that token, and send. Fields shows the cancel status. A later Validate of the same token is the service’s decision. This service reports it cancelled.

    Cancel status

Renew in product mode needs the same registered AppliesTo as Issue. Validate and Cancel are not asked for one.

Sign the request

Digitally sign the request with Credential set to None. The signature is the authentication. Also sign the Timestamp stays on. The certificate is in KeyInfo.

On iya-sts in product mode that certificate has to be one the service already holds for this account, or a leaf its message-signing CA issued. Generate Keys produces a key the service has never seen, and the call is refused. Issue a message-signing certificate for the account and paste the PKCS#8 private key and the certificate into the signing fields. The steps are in setup-iya-sts.md. Do not send a UsernameToken beside the signature unless it names that same account.

  1. Tick Digitally sign the request. Leave Also sign the Timestamp on and Signature Algorithm on RSA-SHA256. The picture is those controls. The private key is on the page below them and is not in the picture.

    Signing switched on

  2. AppliesTo stays urn:wstrust:test:rp. Press Send Request. The response is an Issue of a bearer assertion, and the caller was the signature rather than a password.

    Response to a signed Issue

Leave Save this key pair on if the next walk should decrypt with this key. The private key is stored only while that box is checked.

An encrypted issued token

Some services encrypt an element of the token they issue. On iya-sts that is the relying party’s response map, not a query on the STS URL and not wst:EncryptWith. For urn:wstrust:test:rp, set wstrustEncryptResponse to true and add this as one value of wstrustEncryptResponseElements:

//*[local-name()='Assertion' and namespace-uri()='urn:oasis:names:tc:SAML:2.0:assertion']

The request has to be signed, with the key from the signed walk. Credential stays None. STS URL stays https://localhost:8081/sts. iya-sts encrypts the SAML 2.0 assertion to the BinarySecurityToken on that signature, and the token comes back as xenc:EncryptedData. In product mode a missing certificate, or a certificate whose keyUsage is only digitalSignature, is a SOAP fault, and the assertion is not sent in the clear. Generate Keys writes no keyUsage, so that certificate may be the recipient.

  1. Press Send Request. Issued Token is an EncryptedData, not an assertion.

    The encrypted token

  2. Press Decrypt. The decryption key is the private key that signed the request, when that key was saved and it is the recipient. The content key is in the response security header, and Decrypt reads it from the response. Token XML becomes the assertion.

    The assertion after Decrypt

  3. The status line says the decrypt succeeded.

    Decrypt succeeded

Set wstrustEncryptResponse back to false before the next call. The STS URL does not change. The field is stored, and the next Issue to this AppliesTo stays encrypted until the switch is off.

OnBehalfOf and ActAs

Two Issue calls. Each presents a token the service already issued, and asks for a new one for a different audience. OnBehalfOf is impersonation: the new token is about the subject of the token you present. ActAs is composite delegation: the new token says both who asked and who they acted as. ActAs is a WS-Trust 1.4 control.

The pictures use a bearer assertion just issued for urn:wstrust:test:rp, then ask for https://esb.example.com and https://soap1.example.com. On iya-sts those audiences are registered applications. The caller authenticates again as guide-wstrust, the same account the first token is about. What product mode requires of that caller, and of the two audiences, is in setup-iya-sts.md. None of it is a control on this page.

  1. Issue a fresh bearer token, as in the first walk. Copy the assertion.
  2. Set AppliesTo to the next audience. Tick OnBehalfOf (delegation) and paste the assertion into OnBehalfOf token. Credential is UsernameToken for the same account. Signing stays off.

    OnBehalfOf request

  3. Press Send Request. Issued Token is a new assertion for that audience.

    Token from OnBehalfOf

  4. Copy that assertion. Set AppliesTo to a third audience. Clear OnBehalfOf and tick ActAs (WS-Trust 1.4). Paste the assertion into ActAs token. Authenticate as the same account.

    ActAs request

  5. Press Send Request. Issued Token is a new assertion for that audience. The picture is the start of it. Further down, an ActAs assertion names the subject and each party that acted, in a SAML 2.0 Delegation Restriction. OnBehalfOf does not add the caller there, so the relying party sees the subject.

    Token from ActAs