# Authorising API Endpoints

Tokens issued by IAS are [JSON Web Tokens (JWT)](https://datatracker.ietf.org/doc/html/rfc7519) which are cryptographically signed to prevent tampering.

If you are creating a Resource Server that accepts Access Tokens issued by IAS you MUST validate tokens properly:

<figure><img src="/files/a7B9TOnllyIjojBIAmD6" alt=""><figcaption><p>Authorising APIs Flow</p></figcaption></figure>

1. The Client calls the Resource Server with an Authorization header containing a bearer JWT Access Token issued by IAS.
2. The Resource Server checks if it has a cached RSA public key matching the incoming Access Token. If not, it requests a JSON Web Key Set (JWKS) from IAS.
3. IAS returns all of the public keys for its tokens in a JWKS response.
4. The Resource Server MUST validate the signature of the Access Token JWT using the RSA public key from the JWKS.
5. The Resource Server MUST validate Access Token Claims to see if it was issued (”iss”) by IAS, that it is valid (”nbf” and ”exp”) and at least one Resource Server's scope is listed in the token’s "scope" claim.
6. The Resource Server MAY further authorise the requested resources based on Claims from the Access Token, eg “scope” and “nationalId”.
7. The Resource Server returns the requested Resources.

### Library Configuration

Authorisation libraries often support the following parameters to validate bearer tokens:

* `Scope` which scope is required to call the endpoint.
* `Issuer` or `Authority`, the base URL of IAS (see below).
* If your library does not supports OIDC discovery:
  * `JWKS Endpoint`, for IAS this is `${Issuer}/.well-known/openid-configuration/jwks`


---

# 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.devland.is/products/auth/authorising-apis.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.
