> For the complete documentation index, see [llms.txt](https://specs.govstack.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://specs.govstack.global/overview/23q4/security-requirements/7-auth-services.md).

# 7 Authorization Services

In order to enable the delivery of GovStack use cases, a mechanism must be defined that provides the appropriate level of access to the various building blocks by different users and organizations. This includes defining information sharing across service or organizational boundaries, enforcing appropriate roles and permissions for users, allowing user session information to be passed between building blocks, and enforcing secure access between Building Blocks (either co-located within a service, or across applications/organizations using an Information Mediator).

*Note: Additional technical detail and example scenarios can be found in this* [Authentication and Cross-BB Authorization](https://govstack-global.atlassian.net/wiki/spaces/GH/pages/239370263/Authentication+and+Cross-BB+Authorization) *document*

### 7.1 Key Requirements <a href="#key-requirements" id="key-requirements"></a>

* Authentication and IAM/Roles/Permissions should be managed by an Authorization Service (functionality extracted from current Security spec) using well-defined standards like OpenID Connect (OIDC).
  * This service will handle login, defining roles and permissions, and returning a set of roles/permissions for a user session
  * This service may be implemented as a standalone Building Block or as part of the Application that is controlling the user flow.
* After user login and retrieval of roles/permissions for that user
  * The Application is responsible for managing any outbound calls based on the roles/permissions for that user - whether to internal BBs or cross-organizational requests through IM.
  * The Application will manage the API keys/credentials needed to access any local BB APIs that it calls
  * We *will not* pass user/session information when making API calls to local BBs
  * We *will not* pass JWT tokens or roles when making API calls through Information Mediator
* JWT/tokens need to be exchanged between different UIs/applications - If we need to pass control over to another app to fill in some information (giving consent, etc) - use OIDC
* The Information Mediator is used to facilitate communication between different organizations. The authorization and level of access is defined at the organization level, not the user level (ie. this particular organization has permission to access this set of data)
  * The security server will hold/manage credentials and API keys that are needed for accessing remote services
  * An organization can also allow access to an individual user based on a foundational ID
* IM is needed when going outside of a local network (ie. across the internet)

### **7.2 Accessing the API of an existing DPG or Product which is functioning as a Building Block:**

* Set up an account/set of credentials in the other DPG/application that allows access to the APIs
* The authorization services (either within the application or separate functionality) will hold the login credentials in some type of secret storage (.env file or similar mechanism)
* When calling an API in the DPG, the Application should first call the DPG login API (there must be an API exposed for login) and then hold the token that is needed for API calls
* The Application will pass the appropriate token on subsequent API calls to the DPG

### 7.3 User Role and Permission Management

Within a GovStack implementation, an Identity and Access Management (IAM) or Role-Based Access Control (RBAC) system must be in place. This will define the level of access and permissions that a particular user (or group of users) will have within the GovStack system. The requirements for IAM/RBAC are described in Section 8.2 of this security specification

### 7.4 Definitions <a href="#definitions" id="definitions"></a>

**Service**: An API or endpoint provided by a Building Block or internal microservice of the Application

**Application**: One or more Building Blocks that may be combined with a UI and/or internal services which implement some business logic to provide a set of related services.

**Use Case/User Journey:** A system involving one or more UX components that allows a user to access multiple services which may be co-located or require the use of an information mediator to access a set of services/applications.

**Organization**: An entity that maintains one or more applications or services that may be consumed by other organizations

**User**: An individual that is accessing a particular application or set of services

**Information Mediator**: Connects applications across the internet, allowing services that are owned by different organizations to share data securely and using agreed-upon rules

**Foundational Identity**: a unique identifier for an entity that corresponds with a national identification system

**Functional Identity**: a login or user account that is associated with a particular application or set of services

**Session**: a set of information (or token) that provides context to a particular user interaction with an application (ie. keeping track of a logged-in user and what they have permission to do while they are logged in for a particular period of time)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://specs.govstack.global/overview/23q4/security-requirements/7-auth-services.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
