> ## Documentation Index
> Fetch the complete documentation index at: https://namespace.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Identity Federation with CircleCI

Namespace maintains a direct integration with CircleCI, allowing any of your CircleCI workflows to interact with Namespace resources.
Whether you run builds, create previews, or access your workspace, you can seamlessly connect your CircleCI jobs to Namespace.

## From CircleCI

Namespace federates with CircleCI using [OpenID Connect](https://circleci.com/docs/openid-connect-tokens/) to generate short-lived access tokens.

After a one-time setup, your workflows can access Namespace indefinitely, without relying on pre-shared keys which can be more easily compromised.

<Steps titleSize="h3">
  <Step title="Associate your CircleCI organization with Namespace">
    1. **Find your CircleCI Organization ID** in [Organization Settings > Overview](https://app.circleci.com/settings/organization) in the CircleCI web application.
    2. **Email support** at [support@namespace.so](mailto:support@namespace.so) with both your Organization ID and your Namespace workspace ID from the [Dashboard](https://cloud.namespace.so/workspace/settings).
  </Step>

  <Step title="Initialize access to Namespace">
    After the association is complete, simply add the setup step to your CircleCI job.
    Subsequent steps can now access Namespace resources.

    <Info>
      The Namespace team will release a Circle CI Orb in the future to simplify these steps.
    </Info>

    ```yaml {10-15} theme={null}
    version: 2.1

    jobs:
      test:
        docker:
          - image: cimg/base:stable
        steps:
          - checkout
          - run:
              name: Configure access to Namespace
              command: |
                curl -H 'CI: true' -fsSL https://get.namespace.so/cloud/install.sh | sh

                nsc auth exchange-circleci-token
          - run:
              name: Use Namespace
              command: |
                nsc bazel setup --remote=false --bazelrc /etc/bazel.bazelrc

    workflows:
      main:
        jobs:
          - test
    ```
  </Step>
</Steps>

## Using Remote Builders

Namespace provides high-performance Remote Builders that can significantly speed up your Docker builds in CircleCI workflows.
The easiest way to use Namespace Remote Builders is through the

`namespacelabs/build`
orb, which handles all the configuration automatically.

<Steps titleSize="h3">
  <Step title="Add the orb to your CircleCI configuration">
    ```yaml theme={null}
    orbs:
      build: namespacelabs/build@0.2.1
    ```
  </Step>

  <Step title="Configure the Namespace Remote Builder environment">
    ```yaml {3} theme={null}
    steps:
      - checkout
      - build/setup
    ```
  </Step>

  <Step title="Use the Remote Builder">
    When invoking `docker build`, pass `namespace` as `--builder` to `buildx`:

    ```bash theme={null}
    docker buildx build --builder namespace .
    ```
  </Step>
</Steps>

### Complete example

```yaml theme={null}
version: 2.1

orbs:
  build: namespacelabs/build@0.2.1

jobs:
  docker-build:
    docker:
      - image: cimg/base:stable
    steps:
      - checkout
      - build/setup
      - run:
          name: Build and push Docker image
          command: |
            docker buildx build --builder namespace .

workflows:
  build:
    jobs:
      - docker-build
```
