# SAMLSSO with a web application

[SAMLSSO](Plugin-SAMLSSO.md) signs somebody in through your identity provider. This page is for when what that person may see is not in a directory but in an application of your own: a customer portal, an order system. After the sign-in, the server asks that application for the person's settings and folders, through the [WebApplication plugin](Plugin-WebApplication.md).

The provider answers "who is this". Your application answers "what do they get".

## How the two are linked

A plugin passes an accepted login on to another plugin when its configuration is **named** after it: the other plugin's name, a tilde, and the name of one of that plugin's configurations.

| Name of the SAMLSSO configuration | Calls |
|---|---|
| `WebApplication~` | the first configuration of WebApplication |
| `WebApplication~MyApp` | the configuration of WebApplication that is named `MyApp` |

The idea, with its details, is on the page [SAMLSSO with LDAP roles](Plugin-SAMLSSO-LDAP.md#how-plugins-are-linked).

## Setting it up

### The application side

1. In **WebApplication**, **Add** a configuration and name it, say, `MyApp`.
2. Give it the three addresses of your application, as on the [WebApplication page](Plugin-WebApplication.md).
3. **Leave it not enabled**, so that it does not answer ordinary password logins. Called by name, it works all the same.

There is no password to pass on: the person signed in at the provider. Your application gets the name. So the calls cannot be made "as the user"; give **HTTP Username** and **HTTP Password** a fixed account of your application that may ask about any user, and put `{username}` into the addresses or the post data:

```text
https://portal.example.com/crush/user?name={username}
```

### The SAML side

1. In **SAMLSSO**, untick **Enabled** on the first configuration.
2. **Add** a configuration named `WebApplication~MyApp`.
3. Set up the provider in it and tick **Enabled**.
4. Set **SAMLSSO Cache Time** to `-1`.

## What happens at a sign-in

1. The person signs in at the provider. SAMLSSO checks the signed message and takes the name.
2. SAMLSSO calls WebApplication, configuration `MyApp`.
3. WebApplication calls your application's three addresses for that name, and builds the user from the answers.
4. If your application does not know the name, the sign-in is refused.

## Things to know

- **Protect the three addresses.** They hand out any user's folders to whoever may call them. Accept calls only from the server, over HTTPS, with the fixed account.
- **The name the provider sends must be a name your application knows.** Choose the Name ID at the provider to fit: usually the email address.
- **A slow application makes slow sign-ins.**
- **For groups from a directory** in place of an application: [SAMLSSO with LDAP roles](Plugin-SAMLSSO-LDAP.md).

## Not tried for this page

Nothing was linked on the test server: it had no identity provider and no application to answer. The page follows the earlier documentation and the two plugins' screens.
