# OpenID Connect

*Article Topics:* [*Members*](/getting-started/common-topics/members.md)*,* [*Setup*](/getting-started/common-topics/setup.md)

NATS can be used as an OpenID Connect Server (OP). This is another option for member authentication. In order to utilize this feature, you will need to use an OpenID Connect client. When developing this feature, we used the [mod\_auth\_openidc](https://github.com/OpenIDC/mod_auth_openidc/tree/v2.4.11.2) apache module. Here is an [example ](/nats-admin/members/further-reading/mod_auth_openidc.md#example-virtual-host-settings)implementation. Unlike the standard OpenID Connect Server (OP) implementation, consent for the surfer to provide protected details (like username and email) to the client (members area) is implied.

## Setup

1. Go to the NATS configuration admin -> surfer and scroll down to the 'Member OpenID Connect Server' section.
2. Enable the ENABLE\_MEMBER\_OPENID config option.
3. Provide a list of all ips defined on your member area server(s) by entering it into the MEMBER\_OPENID\_SECURE\_IPS field.
4. Enter the password (make one up) that your member area(s) will use for the token endpoint authentication into the MEMBER\_OPENID\_CLIENT\_SECRET field. If you are using [mod\_auth\_openidc](/nats-admin/members/further-reading/mod_auth_openidc.md) as the client, this is the value you will need for the OIDCClientSecret field.
5. Decide what domain (and protocol) you will use for the authorization (login) page as well as the token and the userinfo endpoints.
6. Determine what claims you want returned.

{% hint style="info" %}
Confirm there is a value set for MEMBER\_OPENID\_SIGNING\_KEY\_ID. If it is not set, contact TMM Support to generate the signing key for you.
{% endhint %}

&#x20; 7\.  Set up an OpenID Connect client in your member's area(s).

## Additional Configuration Options

* **MEMBER\_OPENID\_EXPIRED\_LOGIN** - Enabling this option will allow expired members to login. You will be able to differentiate active members from expired members by using the status claim. It will have a value of 1 for active members and 2 for expired members.
* **MEMBER\_OPENID\_SETUP\_ERROR\_SHOW\_TEMPLATE** - Enabling this option will display a NATS site template when a configuration error occurs instead of redirecting back to the members area. An example of a configuration error would be leaving the ENABLE\_MEMBER\_OPENID option disabled.
* **MEMBER\_OPENID\_AUTH\_CODE\_DURATION** - This option determines the length of time (in seconds) that the auth code (from the authorization endpoint aka the login page) is good for.
* **MEMBER\_OPENID\_ACCESS\_TOKEN\_DURATION** - This option determines the length of time (in seconds) that the access token (from the token endpoint) is good for.
* **MEMBER\_OPENID\_SIGN\_USERINFO\_REPLY** - Enabling this option will cause NATS OpenID Connect Server (OP) to sign the userinfo endpoint reply (in the same way that id\_token is signed in the token endpoint reply) and return a JSON Web Token instead of a JSON encoded array. If you are using [mod\_auth\_openidc](/nats-admin/members/further-reading/mod_auth_openidc.md) as the client, you will need to set the OIDCUserInfoSignedResponseAlg field.
* **MEMBER\_OPENID\_RETURN\_REFRESH\_TOKEN** - Disabling this option will prevent NATS OpenID Connect Server (OP) from generating and returning refresh tokens when creating new access tokens.
* **MEMBER\_OPENID\_INCLUDE\_IDTOKEN\_ON\_REFRESH** - Enabling this option will make NATS return the id\_token when generating a new access token from a refresh token.
* **MEMBER\_OPENID\_ACCESS\_TOKEN\_FORMAT** - This option determines the format of the access token value return (string or signed JWT).
* **MEMBER\_OPENID\_REFRESH\_TOKEN\_FORMAT** - This option determines the format of the refresh token value return (string or signed JWT).
* **MEMBER\_OPENID\_REFRESH\_TOKEN\_DURATION** - This option determines the length of time (in seconds) that the refresh token (from the token endpoint) is good for. This value needs to be greater than the MEMBER\_OPENID\_ACCESS\_TOKEN\_DURATION value.
* **THROTTLE\_LOGIN**, **THROTTLE\_LOGIN\_MAX\_COUNT**, **THROTTLE\_LOGIN\_TIME\_LIMIT** - These work like the other [throttling ](/using-nats/one-off-articles/throttling.md)settings and apply to the authorization endpoint.

**The following options are useful for debugging, but for security reasons we recommend leaving them disabled in production environments:**

* **MEMBER\_OPENID\_DESCRIPTIVE\_LOGIN\_ERROR** - Enabling this option will display a descriptive error message on the login page when the authentication fails. Some of the example error messages include 'Incorrect username!' and 'Incorrect password!'. If this option is disabled, regardless of the reason for failed authentication, members will receive the 'Login Failed!' error message.
* **MEMBER\_OPENID\_REDIECT\_ERROR\_DETAIL** - Enabling this option will provide a detailed error description when a configuration error occurs at the authorization endpoint.
* **MEMBER\_OPENID\_POST\_ERROR\_DETAIL** - Enabling this option will provide a detailed error description on token and userinfo endpoint errors.

## Authorization Domain

You have a couple of options when deciding what domain (and protocol) will be used for the authorization (login) page, as well as the token and the userinfo endpoints.

1. You can use the main NATS url. In this case, the value of the **PROJECT\_HOSTNAME** config setting will be used for the domain, and the protocol will be determined by the **PROJECT\_HOSTNAME\_DISPLAY\_HTTPS** config setting.
2. You can provide a single domain (and protocol) to use via the **MEMBER\_OPENID\_DOMAIN** config setting. This is very similar to the option above, except that it will be different than the main NATS domain.
3. You can use each site's link domain. To do this, you will need to enable the **MEMBER\_OPENID\_DYNAMIC\_DOMAIN** config option.
4. You can make a custom authorization domain for each site. This is very similar to the option above, except that it will be different than the domain of the join page (login.yoursite.com instead of join.yoursite.com). You will need to set up each of these domains in a similar way that you set up your [link domains.](/using-nats/nats-admin-features/linkdomain.md)

## Claims

The id\_token that is generated by the token endpoint contains only the sub claim. The value is the NATS member id for the successfully authenticated member. The userinfo endpoint contains a variety of other claims. NATS OpenID Connect Server (OP) will return all claims that you enabled. Here is the breakdown of claims that the NATS OpenID Connect Server (OP) can return:

* Default:
  * sub (NATS memberid)
  * username
* Enabling **MEMBER\_OPENID\_BASE\_INFO** will return:
  * email
  * firstname
  * lastname
  * trial (1 if in trial, 0 otherwise)
  * status (1 if active, 2 if expired)
  * siteid
* Enabling **MEMBER\_OPENID\_JOIN\_EXPIRE\_INFO** will return a JSON encoded array named join\_expire containing the following fields (all UNIX timestamps):
  * joined
  * expired
  * expires
  * nats\_expires
  * biller\_expires
* Enabling **MEMBER\_OPENID\_IDENTIFIER\_INFO** will return a JSON encoded array named identifier containing the following fields:
  * identid (internal NATS identifier id)
  * loginid (id of the affiliate)
  * campaignid
  * programid
  * optoinid
  * siteid
  * tourid
  * countryid
  * adtoolid
  * billerid
  * subid1
  * subid2
  * promotionalid
* Enabling **MEMBER\_OPENID\_ADDRESS\_INFO** will return a JSON encoded array named address containing the following fields:
  * address1
  * address2
  * city
  * state
  * zip
  * country
* Enabling **MEMBER\_OPENID\_CUSTOM\_INFO** will return a JSON encoded array named customs containing the custom1..10 fields
* Enabling **MEMBER\_OPENID\_PASSTHROUGH\_INFO** will return a JSON encoded array named passthroughs containing the passthroughs1..5 fields (affiliate passthroughs)

## Additional Troubleshooting

* If you are running FastCGI and receiving errors about missing the Authorization header, you may want to add the following line to your htaccess files: SetEnvIf Authorization "(.\*)" **HTTP\_AUTHORIZATION**=$1
* You might have to restart your NATS web server after any changes since the output of the call to the NATS .well-known/member-openid-configuration file can be cached

## Related Articles

{% content-ref url="/pages/2cRnn9yt1yt8AEMV3PW2" %}
[mod\_auth\_openidc](/nats-admin/members/further-reading/mod_auth_openidc.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.toomuchmedia.com/nats-admin/members/further-reading/openid-connect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
