<a id="openid"></a>

# OpenID

<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                                |
|----------------|-------------------------------------------|
| `openid`       | `social_core.backends.open_id.OpenIdAuth` |

[OpenID](http://openid.net/) support is simpler to implement than [OAuth](http://oauth.net/). Google and Yahoo
providers are supported by default, others are supported by POST method
providing endpoint URL.

The generic OpenID backend stores the identity URL asserted by the provider as
the user’s unique identifier. Because this identifier is protocol-derived
rather than selected from a response mapping, the generic `ID_KEY` setting
does not apply.

<a id="session-and-provider-binding"></a>

## Session and provider binding

All OpenID backends require a positive assertion to match backend-scoped
discovery state from the browser session that initiated authentication. When
the framework supports restoring sessions, only a session identifier carried
by the provider-signed `openid.return_to` can select that session. Missing or
mismatched state requires the user to restart authentication.

The generic `openid` backend remains provider-selectable because the
application user supplies its provider URL. Backends configured for one
provider additionally require the callback and verified provider endpoints to
match the exact HTTPS endpoint discovered at initiation. This applies to the
bundled Ubuntu, openSUSE, Yandex, Launchpad, Fedora, Belgium eID, OpenStack,
OpenInfra, LiveJournal, and Steam backends.

Custom backends with a fixed `URL` receive provider binding automatically.
A custom backend that computes a fixed-provider URL in `openid_url()` must
override `requires_openid_provider_binding()` to return `True`. Provider
discovery URLs and discovered provider endpoints must use HTTPS; there is no
setting to disable this validation. Custom strategies that implement session
restoration must restore the complete OpenID session state and update
session-derived pipeline arguments, including the authenticated user.

[OpenID](http://openid.net/) backends can store extra data in `UserSocialAuth.extra_data` field
by defining a set of values names to retrieve from any of the used schemas,
AttributeExchange and SimpleRegistration. As their keywords differ we need
two settings.

Settings is per backend, so we have two possible values for each one. Name
is dynamically checked using uppercase backend name as prefix:

```default
SOCIAL_AUTH_<uppercase backend name>_SREG_EXTRA_DATA
SOCIAL_AUTH_<uppercase backend name>_AX_EXTRA_DATA
```

Example:

```default
SOCIAL_AUTH_GOOGLE_SREG_EXTRA_DATA = [(..., ...)]
SOCIAL_AUTH_GOOGLE_AX_EXTRA_DATA = [(..., ...)]
```

Settings must be a list of tuples mapping value name in response and value
alias used to store. A third value (boolean) is supported to, it’s purpose is
to signal if the value should be discarded if it evaluates to `False`, this
is to avoid replacing old (needed) values when they don’t form part of current
response. If not present, then this check is avoided and the value will replace
any data.

<a id="username"></a>

## Username

The [OpenID](http://openid.net/) backend will check for a `username` key in the values returned by
the server, but default to `first-name` + `last-name` if that key is
missing. It’s possible to indicate the username key in the values If the
username is under a different key with a setting, but backends should have
defined a default value. For example:

```default
SOCIAL_AUTH_FEDORA_USERNAME_KEY = 'nickname'
```

This setting indicates that the username should be populated by the
`nickname` value in the Fedora [OpenID](http://openid.net/) provider.
