Skip to content

docs: rework "admin/authentication" page + PKI authentication docs #9236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

bpmct
Copy link
Member

@bpmct bpmct commented Aug 22, 2023

@Emyrk brought up that this page was getting a bit out of hand, and I agree. Would appreciate folks thoughts on the new format.

Closes #9188

Before merging

I'd appreciate a review in the meantime.


Navigate to your Coder host and run the following command to start up the Coder
The most common way to authenticate with OIDC providers is with a `client_secret`. Navigate to your Coder host and run the following command to start up the Coder
server:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding subheadings?

  1. CLI
  2. System Service
  3. Helm

Copy link
Member Author

@bpmct bpmct Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im in favor of this!


Once the key and certificate are uploaded, you can run Coder with the files. Navigate to your Coder host and run the following command to start up the Coder server:

```console
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same concept of subheadings here.


First, [register a GitHub OAuth app](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/). GitHub will ask you for the following Coder parameters:

- **Homepage URL**: Set to your Coder deployments [`CODER_ACCESS_URL`](https://coder.com/docs/v2/latest/cli/server#--access-url) (e.g. `https://coder.example.com`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Homepage URL**: Set to your Coder deployments [`CODER_ACCESS_URL`](https://coder.com/docs/v2/latest/cli/server#--access-url) (e.g. `https://coder.example.com`)
- **Homepage URL**: Set to your Coder deployments [`CODER_ACCESS_URL`](https://coder.com/docs/v2/latest/cli/server.md#--access-url) (e.g. `https://coder.example.com`)

Even if this is a valid URL, our URL checker gives a 404 if .md is missing.

@@ -1,7 +1,5 @@
# Authentication

[OIDC with Coder Sequence Diagram](https://raw.githubusercontent.com/coder/coder/138ee55abb3635cb2f3d12661f8caef2ca9d0961/docs/images/oidc-sequence-diagram.svg).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where should this image be referenced?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I link to it later in the doc under "How it works"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Once complete, restart your server. GitHub authentication should appear on your log-in screen 🎉

![Log in with GitHub button](https://user-images.githubusercontent.com/22407953/261880741-87bfb1cb-7ea3-41b5-8eef-200552157cda.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with a relative image URL.
Also, you can use the excellent VS Code Doc Writer profile to preview your changes better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I like to preview with the coder site too

First, [register a GitHub OAuth app](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/). GitHub will ask you for the following Coder parameters:

- **Homepage URL**: Set to your Coder deployments [`CODER_ACCESS_URL`](https://coder.com/docs/v2/latest/cli/server#--access-url) (e.g. `https://coder.example.com`)
- **User Authorization Callback URL**: Set to `https://coder.example.com/api/v2/users/oauth2/github/callback`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my testing, it is enough to set it to https://coder.example.com or even https://example.com if you want multiple coder deployments on different subdomains to use the same GitHub OAuth app.

As per my understanding, Coder doesn't use the callback URL and sends a redirect_uri that is of the correct form.

See, we are doing it here.

redirectURL, err := accessURL.Parse("/api/v2/users/oauth2/github/callback")

@deansheather for confirmation, please.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this section should not be under auth directory as it is not an auth method but a feature on top of OIDC/SAML. May be we should have a subdirectory OIDC under auth directory and move this along with setting up OIDC.

These are my thoughts, and they are not very important. If you feel the current flow and organization are right. Please ignore this comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that makes sense to me too. Like "Identity Providers" can be a subsection under OIDC and have each one listed.

- **Homepage URL**: Set to your Coder deployments [`CODER_ACCESS_URL`](https://coder.com/docs/v2/latest/cli/server#--access-url) (e.g. `https://coder.example.com`)
- **User Authorization Callback URL**: Set to `https://coder.example.com/api/v2/users/oauth2/github/callback`

> Note: If you want to allow multiple coder deployments hosted on subdomains e.g. coder1.example.com, coder2.example.com, to be able to authenticate with the same GitHub OAuth app, then you can set **User Authorization Callback URL** to the `https://example.com`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Note: If you want to allow multiple coder deployments hosted on subdomains e.g. coder1.example.com, coder2.example.com, to be able to authenticate with the same GitHub OAuth app, then you can set **User Authorization Callback URL** to the `https://example.com`
> [!NOTE]
> If you want to allow multiple coder deployments hosted on subdomains, e.g., `coder1.example.com`, `coder2.example.com`, to be able to authenticate with the same GitHub OAuth app, then you can set **User Authorization Callback URL** to the `https://example.com`

@@ -0,0 +1,42 @@
# Active Directory Federation Services OIDC with Coder (ADFS)

> **Note:** Tested on ADFS 4.0, Windows Server 2019
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> **Note:** Tested on ADFS 4.0, Windows Server 2019
> ![NOTE]
> Tested on ADFS 4.0, Windows Server 2019

Comment on lines +141 to +145
<blockquote class="warning">
<p>
Only <b>Azure AD</b> has been tested with this method. Other OIDC providers may not work, as most providers add additional requirements ontop of the standard that must be implemented. If you are using another provider and run into issues, please leave an issue on our <a href="https://github.com/coder/coder/issues">Github</a>.
</p>
</blockquote>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that sometimes we use these HTML blockquotes and sometimes GitHub Style blockquote.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I grabbed this warning from another page. I was unaware we had two methods 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other method is I am not sure if we support. I asked Bruno if he can add it.


In the Users page `https://coder.example.com/users`, create a new user with `Login Type: none`:

![Create new user](https://user-images.githubusercontent.com/22407953/262183871-9a9070fa-ca35-4816-9990-465b16b94fe4.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace image path with realative

CODER_OIDC_ICON_URL="https://upload.wikimedia.org/wikipedia/commons/f/fa/Microsoft_Azure.svg"
```

![Custom OIDC text and icon](https://user-images.githubusercontent.com/22407953/261882846-1ce9c076-1247-4929-b082-72252b1f21c4.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image path

Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. I think we can always keep tweaking, but this is an improvement for sure.

Comment on lines +141 to +145
<blockquote class="warning">
<p>
Only <b>Azure AD</b> has been tested with this method. Other OIDC providers may not work, as most providers add additional requirements ontop of the standard that must be implemented. If you are using another provider and run into issues, please leave an issue on our <a href="https://github.com/coder/coder/issues">Github</a>.
</p>
</blockquote>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I grabbed this warning from another page. I was unaware we had two methods 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that makes sense to me too. Like "Identity Providers" can be a subsection under OIDC and have each one listed.


The access_type parameter has two possible values: "online" and "offline." By default, the value is set to "offline". This means that when a user authenticates using OIDC, the application requests offline access to the user's resources, including the ability to refresh access tokens without requiring the user to reauthenticate.

To enable the `offline_access` scope, which allows for the refresh token functionality, you need to add it to the list of requested scopes during the authentication flow. Including the `offline_access` scope in the requested scopes ensures that the user is granted the necessary permissions to obtain refresh tokens.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we provide the example?

CODER_OIDC_SCOPES=openid,profile,email,offline_access

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if we also include an example

returned by the upstream identity provider in a message containing the
string `got oidc claims`, as well as the user info returned.

The following information is also avalible via a [sequence diagram](https://raw.githubusercontent.com/coder/coder/138ee55abb3635cb2f3d12661f8caef2ca9d0961/docs/images/oidc-sequence-diagram.svg) for visual learners.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

returned by the upstream identity provider in a message containing the
string `got oidc claims`, as well as the user info returned.

The following information is also avalible via a [sequence diagram](https://raw.githubusercontent.com/coder/coder/138ee55abb3635cb2f3d12661f8caef2ca9d0961/docs/images/oidc-sequence-diagram.svg) for visual learners.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to main branch now imo.

Suggested change
The following information is also avalible via a [sequence diagram](https://raw.githubusercontent.com/coder/coder/138ee55abb3635cb2f3d12661f8caef2ca9d0961/docs/images/oidc-sequence-diagram.svg) for visual learners.
The following information is also avalible via a [sequence diagram](https://raw.githubusercontent.com/coder/coder/main/docs/images/oidc-sequence-diagram.svg) for visual learners.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is stored in docs/images. We plan to remove the absolute link and use relative link for images too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Comment on lines +116 to +120
<blockquote class="warning">
<p>
Only <b>Azure AD</b> has been tested with this method. Other OIDC providers may not work, as most providers add additional requirements ontop of the standard that must be implemented. If you are using another provider and run into issues, please leave an issue on our <a href="https://github.com/coder/coder/issues">Github</a>.
</p>
</blockquote>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I probably did this, but move this up. The previous sentence and the content after this should be continous.

From there, you can create a long-lived token on behalf of the passwordless user using the [Create token API key](../../api/users.md#create-token-api-key):

```sh
# Replace API_KEY with a token from https://coder.example.com/cli-auth
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Replace API_KEY with a token from https://coder.example.com/cli-auth
# Replace API_KEY with a token from https://coder.example.com/cli-auth
# The logged in user needs to have the requisite permissions to create an API
# key on behalf of another user.


```sh
# Replace API_KEY with a token from https://coder.example.com/cli-auth
curl -X POST http://coder-server:8080/api/v2/users/coder-bot/keys/tokens \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
curl -X POST http://coder-server:8080/api/v2/users/coder-bot/keys/tokens \
curl -X POST http://coder-server:8080/api/v2/users/<machine_username>/keys/tokens \

@matifali
Copy link
Member

A general comment is we should use shell for all code blocks that we expect users to copy and paste and console for where we are also showing the outputs of a command.
@bpmct if you can change all sh to shell to be aligned with upcoming changes in #9245

@github-actions github-actions bot added the stale This issue is like stale bread. label Sep 1, 2023
@github-actions github-actions bot closed this Sep 5, 2023
@bpmct bpmct reopened this Sep 5, 2023
@github-actions github-actions bot removed the stale This issue is like stale bread. label Sep 6, 2023
@github-actions github-actions bot added the stale This issue is like stale bread. label Sep 14, 2023
@github-actions github-actions bot closed this Sep 17, 2023
@github-actions github-actions bot deleted the bpmct/auth-refactor branch February 23, 2024 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This issue is like stale bread.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add docs for OIDC PKI Auth
3 participants