<a id="lifescience-aai"></a>

# Lifescience AAI

<a id="backend-class"></a>

## Backend class

For Django, add this class path to `AUTHENTICATION_BACKENDS`. For other
integrations, use the same class path in the framework-specific backend
setting.

| Backend name   | Class path                                                  |
|----------------|-------------------------------------------------------------|
| `life_science` | `social_core.backends.lifescience.LifeScienceOpenIdConnect` |

Lifescience’s OpenID Connect (OIDC) backend requires the following minimum
configuration:

```default
SOCIAL_AUTH_LIFE_SCIENCE_KEY = '<client_id>'
SOCIAL_AUTH_LIFE_SCIENCE_SECRET = '<client_secret>'
```

<a id="scopes"></a>

## Scopes

The default scopes will include the user’s email.
You can request additional claims, for example:

```default
SOCIAL_AUTH_LIFE_SCIENCE_SCOPE = ['eduperson_entitlement']
```

and you can prevent the inclusion of the default scopes using:

```default
SOCIAL_AUTH_LIFE_SCIENCE_IGNORE_DEFAULT_SCOPE = True
```

<a id="migrating-from-removed-backends"></a>

## Migrating from removed backends

The ELIXIR AAI (`elixir`) and temporary Life Science Login EOSC
(`life_science_eosc`) backends were removed. Their class paths no longer
import, so remove them from the backend configuration and use the
`life_science` backend instead.

Authentication looks up associations by provider name, so existing
associations saved under a removed backend name are not found by the
`life_science` backend. Unless the stored associations are migrated, returning
users are treated as new social accounts, and can be stopped by local account
conflict checks. See [Identifier migration](../configuration/identifier-migration.html.md) for how
associations are matched.

<a id="from-life-science-eosc"></a>

### From `life_science_eosc`

The EOSC backend used the same Life Science Login endpoint and the `sub`
identifier as `life_science`, so existing associations stay valid:

1. Rename the settings from the `SOCIAL_AUTH_LIFE_SCIENCE_EOSC_` prefix to
   `SOCIAL_AUTH_LIFE_SCIENCE_`, for example
   `SOCIAL_AUTH_LIFE_SCIENCE_EOSC_KEY` to `SOCIAL_AUTH_LIFE_SCIENCE_KEY`.
   The removed backend page showed `SOCIAL_AUTH_LIFESCIENCE_EOSC_OIDC_*`
   names, which the backend never read; working configurations use the
   `SOCIAL_AUTH_LIFE_SCIENCE_EOSC_` prefix or the global settings.
   Make sure the registered client allows the redirect URI of the
   `life_science` backend, which contains the new backend name.
2. Change the provider of stored associations from `life_science_eosc` to
   `life_science` in a data migration, before users log in with the new
   configuration.

The provider and UID pair must stay unique. Check for accounts that already
have a `life_science` association with the same UID and resolve them
manually; the rename must not attach an association to a different local user.
With Django, for example:

```default
from social_django.models import UserSocialAuth

old_provider = "life_science_eosc"  # or "elixir"
old = UserSocialAuth.objects.filter(provider=old_provider)
conflicts = UserSocialAuth.objects.filter(
    provider="life_science",
    uid__in=old.values("uid"),
)
if conflicts.exists():
    raise RuntimeError("Resolve duplicate Life Science associations first")
old.update(provider="life_science")
```

<a id="from-elixir"></a>

### From `elixir`

ELIXIR AAI was replaced by Life Science Login, which uses a different issuer.
Register the service as a Life Science Login client and configure the new
credentials as shown above.

Only rename stored `elixir` associations to `life_science`, using the
example above with `old_provider = "elixir"`, after confirming that Life
Science Login returns the same `sub` value that ELIXIR AAI returned for each
account. Otherwise, leave the old associations in place and let existing users
connect their Life Science account while logged in to their local account, or
use account recovery.
