mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-24 13:48:45 +00:00
docs: rework documentation site (#1589)
* initial commit * inital changes * commit WIP Information Architecture * commit a working state * add static assets and project * add org and fix img names * add plausible * remove img * change sidebar to easier mgmt * add openid oauth and domains * lint md * quickstarts * add auth flow * identity brokering * remove site * fix broken links * extend footer * extend readme * fix: styling * fix: zitadel logo on index * styling * border * fix: nav * fix: nav * fix: index * fix: rename architecture to concepts * fix: introductions * fix: introductions * fix: introductions * fix: get started * fix: user manual * fix: zitadel architecture * fix: dead links * add favicon Co-authored-by: fabi <[email protected]> Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
co-authored by
fabi
Livio Amstutz
parent
c7e7ef8e74
commit
dfc9488bb5
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: Get started
|
||||
---
|
||||
|
||||
Most applications need to know the identity of a user allowing to securely store user data in the cloud and provide the same personalised experience across all of the user's devices.
|
||||
|
||||
ZITADEL's authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users in your application. It supports authentication using passwords and applies additional security with the help of a second factor, for example OTP, to ensure a safe and secure access.
|
||||
It additionally leverages industry standards like OAuth 2.0 and OpenID Connect such that it can be easily integrated in your custom backend.
|
||||
|
||||
This documentation demonstrates the different installation methods of ZITADEL and provides a quick start guide on how to register your organization as well as creating your first project.
|
||||
|
||||
## Trying out ZITADEL
|
||||
|
||||
### Installation Types
|
||||
|
||||
You can either use our cloud-instance [zitadel.ch](https://zitadel.ch) or deploy a dedicated **ZITADEL** instance. To get started, we recommend you to try out our free tier first.
|
||||
|
||||
### Use cloud instance zitadel.ch
|
||||
|
||||
To create a ZITADEL project, you have to register as an organization first. Click [here](https://accounts.zitadel.ch/register/org) to register.
|
||||
You will receive an email prompting you to verify your mail.
|
||||
Then go to your [Console Projects](https://console.zitadel.ch/projects) view and create a new project.
|
||||
|
||||

|
||||
|
||||
Now you can proceed adding users to your organization as well as integrating your applications. We refer to our guides as well as our [Quickstarts](../quickstarts/introduction) to do so.
|
||||
|
||||
#### Verify your domain name (optional)
|
||||
|
||||
If you verify a domain you get the benefit that your organisations users can use this domain as the **preferred logonname**.
|
||||
|
||||
#### Elect Managers
|
||||
|
||||
ZITADEL allows you to give other users control over ZITADEL Console itself. This can be restricted to some kind of write and/or read. This can be especially useful for directing administration over several users. You can have managers able to edit project settings and others able to create/add users only.
|
||||
Read the [guides](introduction) for more information.
|
||||
|
||||
> Note: ZITADEL Managers are always located on the right sidepanel of console.
|
||||
|
||||
#### Integrating an application
|
||||
|
||||
After creating your project you can start integrating your applications.
|
||||
After choosing your [project](https://console.zitadel.ch/projects) add a client application on the top of the page.
|
||||
The wizard should provide some guidance what client is the proper for you. If you are still unsure consult our [Guide Project](projects).
|
||||
@@ -0,0 +1,123 @@
|
||||
---
|
||||
title: Identity Brokering
|
||||
---
|
||||
|
||||
<table class="table-wrapper">
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
<td>Learn about identity brokering/federation and how to add an external identity provider to authenticate your users.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Learning Outcomes</td>
|
||||
<td>
|
||||
In this module you will:
|
||||
<ul>
|
||||
<li>Learn about Identity Providers</li>
|
||||
<li>Add a new identity provider</li>
|
||||
<li>Example with Google Login</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Prerequisites</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Knowledge of <a href="/docs/guides/organizations">Organizations</a></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### What is Identity Brokering and Federated Identities?
|
||||
|
||||
Federated identity management is an arrangement built upon the trust between two or more domains. Users of these domains are allowed to access applications and services using the same identity.
|
||||
This identity is known as federated identity and the pattern behind this as identity federation.
|
||||
|
||||
A service provider that specializes in brokering access control between multiple service providers (also referred to as relying parties) is called identity broker.
|
||||
Federated identity management is an arrangement that is made between two or more such identity brokers across organizations.
|
||||
|
||||
Example:
|
||||
If Google is configured as identity provider on your organization, the user will get the option to use his Google Account on the Login Screen of ZITADEL (1).
|
||||
ZITADEL will redirect the user to the login screen of Google where he as to authenticated himself (2) and is sent back after he has finished that (3).
|
||||
Because Google is registered as trusted identity provider the user will be able to login in with the Google account after he linked an existing ZITADEL Account or just registered a new one with the claims provided by Google (4)(5).
|
||||
|
||||

|
||||
|
||||
### Exercise: Register an external identity provider
|
||||
|
||||
In this exercise we will add a new Google identity provider to federate identities with ZITADEL.
|
||||
|
||||
#### 1. Create new OIDC Client
|
||||
|
||||
1. Register an OIDC Client in your preferred provider
|
||||
2. Make sure you add the ZITADEL callback redirect uris
|
||||
https://accounts.zitadel.ch/register/externalidp/callback
|
||||
https://accounts.zitadel.ch/login/externalidp/callback
|
||||
|
||||
> **Information:** Make sure the provider is OIDC 1.0 compliant with a proper Discovery Endpoint
|
||||
|
||||
Google Example:
|
||||
|
||||
1. Go to the Google Gloud Platform and choose youre project: <https://console.cloud.google.com/apis/credentials>
|
||||
2. Click on "+ CREATE CREDENTIALS" and choose "OAuth client ID"
|
||||
3. Choose Web application as Application type and give a name
|
||||
4. Add the redirect uris from above
|
||||
5. Save clientid and client secret
|
||||
|
||||

|
||||
|
||||
#### 2. Add custom login policy on your organisation
|
||||
|
||||
1. Go to your organisation settings by clicking on "Organisation" in the menu or using the following link: <https://console.zitadel.ch/org>
|
||||
2. Modify your login policy
|
||||
3. As long as you have the default policy, you can't change the policy. Click create custom policy to set your on settings.
|
||||
|
||||

|
||||
|
||||
#### 3.Configure new identity provider
|
||||
|
||||
1. Go to the identity providers section and click new
|
||||
2. Fill out the form
|
||||
- Use the issuer, clientid and client secret provided by your provider
|
||||
- The scopes will be prefilled with openid, profile and email, because this information is relevant for ZITADEL
|
||||
- You can choose what fields you like to map as the display name and as username. The fields you can choose are preferred_username and email
|
||||
(Example: For Google you should choose email for both fields)
|
||||
3. Save your configuration
|
||||
4. Link your new configuration to your login policy. By searching in the organisation category you will get you own configuration. If you choose system you can link all predefined providers.
|
||||
|
||||

|
||||
|
||||
Your user will now be able to choose Google for login instead of username/password or mfa.
|
||||
|
||||
### Knowledge Check
|
||||
|
||||
* The issuer for your identity provider is <https://issuer.zitadel.ch>
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* The identity provider has to be oAuth 2.0 compliant
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Solutions
|
||||
</summary>
|
||||
|
||||
* The issuer for your identity provider is https://issuer.zitadel.ch
|
||||
- [ ] yes
|
||||
- [x] no (The issuer is provided by your choosen identity provider. In the case of Google it's https://accounts.google.com)
|
||||
* The identity provider has to be oAuth 2.0 compliant
|
||||
- [x] yes
|
||||
- [ ] no
|
||||
|
||||
</details>
|
||||
|
||||
### Summary
|
||||
|
||||
* You can federate identities of all oAuth 2.0 compliant external identity providers
|
||||
* Configure the provider in your custom login policy
|
||||
|
||||
Where to go from here:
|
||||
|
||||
* ZITADEL Projects
|
||||
* Service users
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
title: Introduction
|
||||
---
|
||||
|
||||
With our guides you will learn everything you need to know about specific topics. You get step-by-step instructions for certain tasks and have a knowledge check at the end.
|
||||
@@ -0,0 +1,147 @@
|
||||
---
|
||||
title: Recommended authorization flows
|
||||
---
|
||||
|
||||
| | |
|
||||
| --- | --- |
|
||||
| Description | Learn about the different authentication flows and which flow we recommend you should use for your application. |
|
||||
| Learning Outcomes | In this module you will: <ul><li>Learn the basics of federated identities</li><li>Understand the basics of OAuth 2.x client profiles and their importance for authorization flows</li><li>Get a recommended flow for Web, Native, User-Agent, and API</li></ul> |
|
||||
| Prerequisites | Basic knowledge about federated identities. |
|
||||
|
||||
### Introduction
|
||||
|
||||
Before we get into setting up our first application within ZITADEL, we need to go through some basics on how to obtain an authorization with OpenID Connect 1.x and OAuth 2.x.
|
||||
|
||||
ZITADEL does not make assumptions about the application type you are about to integrate. Therefore you must qualify and define an appropriate method for your users to gain authorization to access your application (“authentication flow”). Your choice depends on the application’s ability to maintain the confidentiality of client credentials and the technological capabilities of your application. If you choose a deprecated or unfeasible flow to obtain authorization for your application, your users’ credentials may be compromised.
|
||||
|
||||
We invite you to further explore the different authorization flows in the OAuth 2.x standard. For the start we assume that you have a brand-new application (ie. without legacy requirements) and you found an reliable SDK/Library that does the heavy lifting for you.
|
||||
|
||||
So this module will only go over the basics and explain why we recommend the flow “Authorization Flow with PKCE” as default for most applications. We will also cover the case of machine-to-machine communication, ie. where there is no interactive login. Further we will guide you to further reading viable alternatives, if the default flow is not feasible.
|
||||
|
||||
### Basics of Federated Identity
|
||||
|
||||
Although Federated Identities are not a new concept ([RFC 6749](https://tools.ietf.org/html/rfc6749), “The OAuth 2.0 Authorization Framework” was released in 2012) it is important to highlight the difference between the traditional client-server authentication model and the concept of delegated authorization and authentication.
|
||||
|
||||
The aforementioned RFC provides us with some [problems and limitations](https://tools.ietf.org/html/rfc6749#section-1) of the client-server authentication, where a client requests a protected resource on the server by authenticating with the user’s credentials:
|
||||
|
||||
* Applications need to store users credentials (eg, password) for future use; compromise of any application results in compromise of the end-users credentials
|
||||
* Servers are required to support password authentication
|
||||
* Without means of limiting scope when providing the user’s credentials, the application gains overly broad access to protected resources
|
||||
* Users cannot revoke access for a single application, but only for all by changing credentials
|
||||
|
||||
So what do we want to achieve with delegated authentication?
|
||||
|
||||
* Instead of implementing authentication on each server and trusting each server
|
||||
* Users only **authenticate** with a trusted server (ie. ZITADEL), that validates the user’s identity through a challenge (eg, multiple authentication factors) and issues an **ID token** (OpenID Connect 1.x)
|
||||
* Applications have means of **validating the integrity** of presented access and ID tokens
|
||||
|
||||
* Instead of sending around the user’s credentials
|
||||
* Clients may access protected resources with an **access token** that is only valid for specific scope and limited lifetime (OAuth 2.x)
|
||||
* Users have to **authorize** applications to access certain [**scopes**](https://docs.zitadel.ch/architecture#Scopes) (eg, email address or custom roles). Applications can request [**claims**](https://docs.zitadel.ch/architecture#Claims) (key:value pairs, eg email address) for the authorized scopes with the access token or ID token from ZITADEL
|
||||
* Access tokens are bearer tokens, meaning that possession of the token provides access to a resource. But the tokens expire frequently and the application must request a new access token via **refresh token** or the user must reauthenticate
|
||||
|
||||

|
||||
|
||||
This is where the so-called “flows” come into play: There are a number of different flows on how to handle the process from authentication, over authorization, getting tokens and requesting additional information about the user.
|
||||
|
||||
Maybe interesting to mention is that we are mostly concerned with choosing the right OAuth 2.x flows (alas “authorization”). OpenID Connect extends the OAuth 2.x flow with useful features like endpoint discovery (where to ask), ID Token (who is the user, when and how did she authenticate), and UserInfo Endpoint (getting additional information about the user).
|
||||
|
||||
### Different client profiles
|
||||
|
||||
As mentioned in the beginning of this module, there are two main determinants for choosing the optimal authorization flow:
|
||||
|
||||
1. Client’s ability to maintain the confidentiality of client credentials
|
||||
2. Technological limitations
|
||||
|
||||
OAuth 2.x defines two [client types](https://tools.ietf.org/html/rfc6749#section-2.1) based on their ability to maintain the confidentiality of their client credentials:
|
||||
|
||||
* Confidential: Clients capable of maintaining the confidentiality of their credentials (e.g., client implemented on a secure server with restricted access to the client credentials), or capable of secure client authentication using other means.
|
||||
* Public: Clients incapable of maintaining the confidentiality of their credentials (e.g., clients executing on the device used by the resource owner, such as an installed native application or a web browser-based application), and incapable of secure client authentication via any other means.
|
||||
|
||||
The following table gives you a brief overview of different client profiles.
|
||||
|
||||
<table class="table-wrapper">
|
||||
<tr>
|
||||
<th>Confidentiality of client credentials</th>
|
||||
<th>Client profile</th>
|
||||
<th>Examples of clients</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">Public</td>
|
||||
<td>User-Agent</td>
|
||||
<td>Single-page web applications (SPA), generally JavaScript executed in Browser</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Native</td>
|
||||
<td>Native, Mobile, or Desktop applications</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">Confidential</td>
|
||||
<td>Web</td>
|
||||
<td>Server-side web applications such as java, .net, …</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Machine-to-Machine</td>
|
||||
<td>APIs, generally services without direct user-interaction at the authorization server</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### Our recommended authorization flows
|
||||
|
||||
We recommend using the flow **“Authorization Code with Proof Key of Code Exchange (PKCE)”** ([RFC7636](https://tools.ietf.org/html/rfc7636)) for **User-Agent**, **Native**, and **Web** clients.
|
||||
|
||||
If you don’t have any technical limitations, you should favor the flow Authorization Code with PKCE over other methods. The PKCE part makes the flow resistant against authorization code interception attack as described well in RFC7636.
|
||||
|
||||
*So what about APIs?*
|
||||
|
||||
We recommend using **“JWT bearer token with private key”** ([RFC7523](https://tools.ietf.org/html/rfc7523)) for Machine-to-Machine clients.
|
||||
|
||||
What this means is that you have to send an JWT token, containing the [standard claims for access tokens](https://docs.zitadel.ch/architecture#Claims) and that is signed with your private key, to the token endpoint to request the access token. We will see how this works in another module about Service Accounts.
|
||||
|
||||
If you don’t have any technical limitations, you should prefer this method over other methods.
|
||||
|
||||
A JWT with a private key can also be used with client profile web to further enhance security.
|
||||
|
||||
In case you need alternative flows and their advantages and drawbacks, there will be a module to outline more methods and our recommended fallback strategy per client profile that are available in ZITADEL.
|
||||
|
||||
### Knowledge Check (3)
|
||||
|
||||
* With federated identities the user sends credentials to the server holding the protected resource
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* ZITADEL will discover your client profile automatically and set the correct flow
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* When working with APIs / machine-to-machine communication its recommended to exchange a JWT that is singed with your private key for an access token
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Solutions
|
||||
</summary>
|
||||
|
||||
* With federated identities the user sends credentials to the server holding the protected resource
|
||||
- [ ] yes
|
||||
- [x] no (Users are authenticated against a centralized IDP, only access tokens are send to the requested resources)
|
||||
* ZITADEL will discover your client profile automatically and set the correct flow
|
||||
- [ ] yes
|
||||
- [x] no (ZITADEL does not make any assumptions about your application’s requirements)
|
||||
* When working with APIs / machine-to-machine communication its recommended to exchange a JWT that is singed with your private key for an access token
|
||||
- [x] yes
|
||||
- [ ] no
|
||||
|
||||
</details>
|
||||
|
||||
### Summary (3)
|
||||
|
||||
* Federated Identities solve key problems and challenges with traditional server-client architecture
|
||||
* Use “Authorization Code with Proof Key of Code Exchange (PKCE)” for User-Agent, Native, and Web clients
|
||||
* “JWT bearer token with private key” for Machine-to-Machine clients
|
||||
* There are alternative flows and fallback strategies supported by ZITADEL, if these flows are technically not possible
|
||||
|
||||
Where to go from here
|
||||
|
||||
* Applications
|
||||
* Service Accounts
|
||||
* Alternative authentication flows (aka. "The Zoo")
|
||||
@@ -0,0 +1,115 @@
|
||||
---
|
||||
title: Organizations
|
||||
---
|
||||
|
||||
|
||||
| | |
|
||||
| --- | --- |
|
||||
| Description | Learn how ZITADEL is structured around Organizations and how to create your organization and verify a domain to use with that new organization. |
|
||||
| Learning Outcomes | In this module you will: <ul><li>Learn about organizations</li><li>Create a new organization</li><li>Verify your domain name </li></ul> |
|
||||
|Prerequisites|None|
|
||||
|
||||
## What is an organization?
|
||||
|
||||
ZITADEL is organized around the idea that:
|
||||
|
||||
* Multiple organizations share the same system. In this case multiple organizations share the same service, zitadel.ch
|
||||
* organizations can grant each other rights to self-manage certain aspects of the IAM (eg, roles for access management)
|
||||
* organizations are vessels for users and projects
|
||||
|
||||

|
||||
|
||||
Organizations in ZITADEL are therefore comparable to tenants of a system or organizational units of a directory based system.
|
||||
|
||||
You can use projects within your organization to manage the security context of closely related components, such as roles, grants and authorizations for multiple clients. You can set up multiple projects within your organization.
|
||||
|
||||
ZITADEL allows you to give other organizations permission to manage certain aspects of a project within your organization on their own. This means you could set up a project with roles that should exist within your service/software, but allow another organization to allocate the roles to users within their own organization. As a service provider, you will find this feature useful, as it allows you to establish a self-service culture for your business customers.
|
||||
|
||||

|
||||
|
||||
Each organization has its own pool of usernames, which includes human and service users, for its domain (`{username}@{domainname}.{zitadeldomain}`). A username is unique within your organization. You can configure ZITADEL to use your own domain, and simplify user experience (`{loginname}@{yourdomain.tld}`).
|
||||
|
||||
There are several more modules in our documentation to go into more detail regarding organization management, projects, clients, and users. But first let’s create a new organization and verify your domain name.
|
||||
|
||||
## Exercise - Create a new organization
|
||||
|
||||
To register your organization and create a user for ZITADEL, visit zitadel.ch or directly <https://accounts.zitadel.ch/register/org> and fill in the required information.
|
||||
|
||||

|
||||
|
||||
If you already have an existing login for zitadel.ch, you need to visit the console, then click on your organization’s name in the upper left corner, and then select “New organization”.
|
||||
|
||||

|
||||
|
||||
## How ZITADEL handles usernames
|
||||
|
||||
As we mentioned before, each organization has its own pool of usernames, which includes human and service.
|
||||
|
||||
This means that, for example a user with the username road.runner, can only exist once in an organization called ACME. ZITADEL will automatically generate a "logonname" for each consisting of `{username}@{domainname}.{zitadeldomain}`, in our example road.runner@acme.zitadel.ch.
|
||||
|
||||
When you verify your domain name, then ZITADEL will generate additional logonames for each user with the verified domain. If our example organization would own the domain acme.ch and verify within the organization ACME, then the resulting logonname in our example would be road.runner@acme.ch in addition to the already generated road.runner@acme.zitadel.ch. The user can now use either logonname to authenticate with your application.
|
||||
|
||||
## Domain verification and primary domain
|
||||
|
||||
Once you have successfully registered your organization, ZITADEL will automatically generate a domain name for your organization (eg, acme.zitadel.ch). Users that you create within your organization will be suffixed with this domain name.
|
||||
|
||||
You can improve the user experience, by suffixing users with a domain name that is in your control. For that you can prove the ownership of your domain, by DNS or HTTP challenge.
|
||||
|
||||
An organization can have multiple domain names, but only one domain can be primary. The primary domain defines which login name ZITADEL displays to the user, and what information gets asserted in access_tokens (`preferred_username`).
|
||||
|
||||
Please note that domain verification also removes the logonname from all users, who might have used this combination in the global organization (ie. users not belonging to a specific organization). Relating to our example with acme.ch: If a user ‘coyote’ exists in the global organization with the logonname coyote@acme.ch, then after verification of acme.ch, this logonname will be replaced with `coyote@{randomvalue.tld}`. ZITADEL will notify users affected by this change.
|
||||
|
||||
## Exercise - Verify your domain name
|
||||
|
||||
1. Browse to your organization
|
||||
2. Click **Add Domain**
|
||||
3. To start the domain verification click the domain name and a dialog will appear, where you can choose between DNS or HTTP challenge methods.
|
||||
4. For example, create a TXT record with your DNS provider for the used domain and click verify. ZITADEL will then proceed an check your DNS.
|
||||
5. When the verification is successful you have the option to activate the domain by clicking **Set as primary**
|
||||
|
||||

|
||||
|
||||
> **_Please note:_** Do not delete the verification code, as ZITADEL will re-check the ownership of your domain from time to time
|
||||
|
||||
## Knowledge Check
|
||||
|
||||
* Users exist only within projects or clients
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* User can only login with `{username}@{domainname}.{zitadeldomain}`
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* You can delegate access management self-service to another organization
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Solutions
|
||||
</summary>
|
||||
|
||||
* Users exist only within projects or clients
|
||||
- [ ] yes
|
||||
- [x] no (users exist within organizations)
|
||||
* User can only login with `{username}@{domainname}.{zitadeldomain}`
|
||||
- [ ] yes
|
||||
- [x] no (You can validate your own domain and login with `{loginname}@{yourdomain.tld}`)
|
||||
* You can delegate access management self-service to another organization
|
||||
- [x] yes
|
||||
- [ ] no
|
||||
|
||||
</details>
|
||||
|
||||
## Summary
|
||||
|
||||
* Create your organization and a new user by visiting zitadel.ch
|
||||
* Organizations are the top-most vessel for your IAM objects, such as users or projects
|
||||
* Verify your domain in the Console to improve user experience; remember to not delete the verification code to allow recheck of ownership
|
||||
* You can delegate certain aspects of your IAM to other organizations for self-service
|
||||
|
||||
Where to go from here:
|
||||
|
||||
* Create a project
|
||||
* Setup Passwordless MFA
|
||||
* Manage ZITADEL Roles
|
||||
* Grant roles to other organizations or users
|
||||
@@ -0,0 +1,137 @@
|
||||
---
|
||||
title: Projects
|
||||
|
||||
---
|
||||
|
||||
| | |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Description | Learn the basics about applications, roles and authorizations, and how projects allow you to group these together. |
|
||||
| Learning Outcomes | In this module you will: <ul><li>Learn about projects and granted projects</li><li>Create a new project</li><li>Creating simple roles and authorizations</li><li>Create an organization grant for your project</li></ul> |
|
||||
| Prerequisites | <ul><li>ZITADEL organizations</li><li>Role Based Access Management (RBAC)</li></ul> |
|
||||
|
||||
## What is a project?
|
||||
|
||||
The idea of projects is to have a vessel for all components who are closely related to each other. Multiple projects can exist within an organization.
|
||||
|
||||

|
||||
|
||||
All applications within a project share the same roles, grants, and authorizations:
|
||||
|
||||
* **Applications** is your software that initiates the authorization flow. This could be a web app and a mobile app that share the same roles.
|
||||
* **Roles** are a means of managing user access rights for a project.
|
||||
* **Authorizations** define which users have which roles. Authorizations are also called “user grants”.
|
||||
* **Granted Organizations** can manage selected roles for your project on their own.
|
||||
|
||||

|
||||
|
||||
The goal of this module is to give you an overview, but not dive too deep into details around managing access rights and delegating management of roles to third parties. So let’s create a straightforward example project first.
|
||||
|
||||
## Exercise - Create a simple project
|
||||
|
||||
Visit <https://console.zitadel.ch/projects> or select “Projects” within your organization, then click the button to create a new project.
|
||||
|
||||

|
||||
|
||||
Enter the name “ My first project” and continue.
|
||||
|
||||
Let’s make this more interesting and add some basic roles and authorizations to your project and then confirm the scope of the roles and authorizations.
|
||||
|
||||
Jump to the section ROLES and create two new roles with the following values
|
||||
|
||||
* Key: reader
|
||||
* Display Name: Reader
|
||||
* Group: user
|
||||
|
||||
and
|
||||
|
||||
* Key: editor
|
||||
* Display Name: Editor
|
||||
* Group: user
|
||||
|
||||

|
||||
|
||||
Now, you can add roles to your own user, or you can create a new user. To create a new user, go to Users and click “New”. Enter the required contact details and save by clicking “Create”.
|
||||
|
||||

|
||||
|
||||
To grant users certain roles, you need to create authorizations. Go back to the project, and jump to the section AUTHORIZATIONS.
|
||||
|
||||

|
||||
|
||||
You can verify the role grant on the user. Select Users from the navigation menu and click on the user Coyote. Scroll down to the section AUTHORIZATION, there you should be able to verify that the user has the role ‘reader’ for your project ‘My first project’.
|
||||
|
||||

|
||||
|
||||
Now create another project (eg. “My second project”) and verify that there are no roles or authorizations on your second project.
|
||||
|
||||
## What is a granted project?
|
||||
|
||||

|
||||
|
||||
With ZITADEL you can grant selected roles within your project to an organization. The receiving organization can then create authorizations for their users on their own (self-service).
|
||||
|
||||
An example could be a service provider that offers a SaaS solution that has different permissions for employees working in Sales and Accounting. As soon as a new client purchases the service, the provider could grant the roles ‘sales’ and ‘accounting’ to that organization, allowing them to self-manage how they want to allocate the roles to their users.
|
||||
|
||||
The process of assigning certain roles by default or according to rules can be further automated by utilizing Service Users in the service provider’s business process.
|
||||
|
||||
Obviously, your organization can grant projects and receive projects. When you are granting, then the receiving organization will be displayed in the section GRANTED ORGANIZATIONS of your project.
|
||||
|
||||

|
||||
|
||||
A granted project, on the other hand, belongs to a third party, granting you some rights to manage certain roles of their project. ZITADEL Console shows granted projects in a dedicated navigation menu, to clearly separate from your organization’s projects.
|
||||
|
||||

|
||||
|
||||
Please note that you can also grant selected roles of a project to an individual user, instead of an organization. We will discuss this in more detail in a later section.
|
||||
|
||||
## Exercise - Grant a project
|
||||
|
||||
1. Visit the project that you have created before, then in the section GRANTED ORGANIZATIONS click New.
|
||||
2. Enter the domain ‘acme.zitadel.ch’, search the organization and continue to the next step.
|
||||
3. Select some roles you would like to grant to the organization ACME and confirm.
|
||||
4. You should now see ACME in the section GRANTED ORGANIZATIONS
|
||||
|
||||

|
||||
|
||||
## Knowledge Check (2)
|
||||
|
||||
* You can setup multiple projects within an organization to manage scope
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* Authorizations are define more detailed access rights within your application
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* Your projects as well as projects granted to your organization are visible within the Tab Projects of your organization
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Solutions
|
||||
</summary>
|
||||
|
||||
* You can setup multiple projects within an organization to manage scope
|
||||
- [x] yes
|
||||
- [ ] no
|
||||
* Authorizations are define more detailed access rights within your application
|
||||
- [ ] yes
|
||||
- [x] no (Authorizations link users to certain roles)
|
||||
* Your projects as well as projects granted to your organization are visible within the Tab Projects of your organization
|
||||
- [ ] yes
|
||||
- [x] no (Projects and Granted Projects are shown on different tabs)
|
||||
|
||||
</details>
|
||||
|
||||
## Summary (2)
|
||||
|
||||
* Manage scope of roles, authorizations and applications with projects
|
||||
* Create and assign roles to users of your organization within your project
|
||||
* Use project grants to enable other organizations to self-manage access rights (roles) to your applications
|
||||
|
||||
Where to go from here:
|
||||
|
||||
* Manage roles for your project
|
||||
* Grant roles to other organizations or users
|
||||
* Service Users
|
||||
* Manage IAM Roles
|
||||
* Setup a SaaS Application with granted projects (Learning Path)
|
||||
@@ -0,0 +1,211 @@
|
||||
---
|
||||
title: Service Users
|
||||
---
|
||||
|
||||
<table class="table-wrapper">
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
<td>Learn the basics about ZITADEL Service Users, how to set them up and authorize with ZITADEL.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Learning Outcomes</td>
|
||||
<td>
|
||||
In this module you will:
|
||||
<ul>
|
||||
<li>Learn about Service Users</li>
|
||||
<li>Create a Service User in ZITADEL Console</li>
|
||||
<li>Authorize a Service User with JWT signed with your private key</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Prerequisites</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Knowledge of <a href="/docs/guides/oauth-recommended-flows">Recommended Authorization Flows</a></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Human vs. Machine
|
||||
|
||||
ZITADEL supports human an machine users. We call human users simply "Users" and machine users "Service Users".
|
||||
|
||||
With Service Users you would typically secure backend services. For example in ZITADEL you would require an authenticated Service User to access the Management API. The main difference between human and machine users is the type of credentials that can be used for authentication: Human users typically logon via an login prompt, but Machine users require a non-interactive logon process.
|
||||
|
||||
## Exercise: Create a Service User
|
||||
|
||||
1. Navigate to Service Users
|
||||
2. Click on **New**
|
||||
3. Enter a user name and a display name
|
||||
|
||||

|
||||
|
||||
## Authenticating a service user
|
||||
|
||||
In ZITADEL we use the `private_jwt` (**“JWT bearer token with private key”**, [RFC7523](https://tools.ietf.org/html/rfc7523)) authorization grant for this non-interactive authentication.
|
||||
|
||||
You need to follow these steps to authenticate a service user and receive a access token:
|
||||
|
||||
1. Generate a private-public key pair in ZITADEL
|
||||
2. Create a JSON Web Token (JWT) and sign with private key
|
||||
3. With this JWT, request an OAuth token from ZITADEL
|
||||
|
||||
With this token you can make subsequent requests, just like a human user.
|
||||
|
||||
## Exercise: Get an access token
|
||||
|
||||
In this exercise we will authenticate a service user and receive an access_token to use against a API.
|
||||
|
||||
> **Information:** Are you stuck? Don't hesitate to reach out to us on [Github Discussions](https://github.com/caos/zitadel/discussions) or [contact us](https://zitadel.ch/contact/) privately.
|
||||
|
||||
### 1. Generate a private-public key pair in ZITADEL
|
||||
|
||||
Select your service user and in the section KEYS click **New**. Enter an expiration date and click **Add**. Make sure to download the json by clicking **Download**.
|
||||
|
||||

|
||||
|
||||
The downloaded json should look something like outlined below. The value of `key` contains the *private* key for your service account. Please make sure to keep this key securely stored and handle with care. The public key is automatically stored in ZITADEL.
|
||||
|
||||
```json
|
||||
{
|
||||
"type":"serviceaccount",
|
||||
"keyId":"100509901696068329",
|
||||
"key":"-----BEGIN RSA PRIVATE KEY----- [...] -----END RSA PRIVATE KEY-----\n",
|
||||
"userId":"100507859606888466"
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Create a JWT and sign with private key
|
||||
|
||||
You need to create a JWT with the following header and payload and sign it with the RS256 algorithm.
|
||||
|
||||
Header
|
||||
|
||||
```json
|
||||
{
|
||||
"alg": "RS256",
|
||||
"kid":"100509901696068329"
|
||||
}
|
||||
```
|
||||
|
||||
Make sure to include `kid` in the header with the value of `keyId` from the downloaded JSON.
|
||||
|
||||
Payload
|
||||
|
||||
```json
|
||||
{
|
||||
"iss": "100507859606888466",
|
||||
"sub": "100507859606888466",
|
||||
"aud": "https://issuer.zitadel.ch",
|
||||
"iat": [Current UTC timestamp, e.g. 1605179982],
|
||||
"exp": [UTC timestamp, max. 1 hour from iat, e.g. 1605183582]
|
||||
}
|
||||
```
|
||||
|
||||
* `iss` represents the requesting party, i.e. the owner of the private key. In this case the value of `userId` from the downloaded JSON.
|
||||
* `sub` represents the application. Set the value also to the value of `userId`
|
||||
* `aud` must be ZITADEL's issuing domain
|
||||
* `iat` is a unix timestamp of the creation signing time of the JWT, e.g. now
|
||||
* `exp` is the unix timestamp of expiry of this assertion. Must be less than 1 hour from `iat`
|
||||
|
||||
Please refer to [JWT_with_Private_Key](../apis/openidoauth/authn-methods#jwt-with-private-key) in the documentation for further information.
|
||||
|
||||
> **Information:** The `exp` claim is currently not validated, but will be with a future release. Make sure that `exp` is less than 1 hour starting from `iat`.
|
||||
|
||||
If you use Go, you might want to use the [provided tool](https://github.com/caos/zitadel-tools) to generate a JWT from the downloaded json. There are many [libraries](https://jwt.io/#libraries-io) to generate and sign JWT.
|
||||
|
||||
### 3. With this JWT, request an OAuth token from ZITADEL
|
||||
|
||||
With the encoded JWT from the prior step, you will need to craft a POST request to ZITADEL's token endpoint:
|
||||
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url https://api.zitadel.ch/oauth/v2/token \
|
||||
--header 'Content-Type: application/x-www-form-urlencoded' \
|
||||
--data grant_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer \
|
||||
--data scope='openid profile email' \
|
||||
--data assertion=eyJ0eXAiOiJKV1QiL...
|
||||
```
|
||||
|
||||
* `grant_type` should be set to `urn:ietf:params:oauth:client-assertion-type:jwt-bearer`
|
||||
* `scope` should contain any [Scopes](../apis/openidoauth/scopes) you want to include, but must include `openid`. For this example, please include `profile` and `email`
|
||||
* `assertion` is the encoded value of the JWT that was signed with your private key from the prior step
|
||||
|
||||
You should receive a successful response with `access_token`, `token_type` and time to expiry in seconds as `expires_in`.
|
||||
|
||||
```bash
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"access_token": "MtjHodGy4zxKylDOhg6kW90WeEQs2q...",
|
||||
"token_type": "Bearer",
|
||||
"expires_in": 43199
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Verify that you have a valid access toaken
|
||||
|
||||
For this example let's call the userinfo endpoint to verfiy that our access token works.
|
||||
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url https://api.zitadel.ch/oauth/v2/userinfo \
|
||||
--header 'Content-Type: application/x-www-form-urlencoded' \
|
||||
--header 'Authorization: Bearer MtjHodGy4zxKylDOhg6kW90WeEQs2q...'
|
||||
```
|
||||
|
||||
You should receive a response with your service user's information.
|
||||
|
||||
```bash
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "MyServiceUser",
|
||||
"preferred_username": "[email protected]",
|
||||
"updated_at": 1616417938
|
||||
}
|
||||
```
|
||||
|
||||
## Knowledge Check
|
||||
|
||||
* To secure backend APIs you can request an API key via ZITADEL's console
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* The JWT header must contain a property `kid` with the value of the key ID
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
* After generating a key for your service user, you must download the public key and sign your JWT with the public key
|
||||
- [ ] yes
|
||||
- [ ] no
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Solutions
|
||||
</summary>
|
||||
|
||||
* To secure backend APIs you can request an API key via ZITADEL's console
|
||||
- [ ] yes
|
||||
- [x] no (We use **“JWT bearer token with private key”**, [RFC7523](https://tools.ietf.org/html/rfc7523))
|
||||
* The JWT header must contain a property `kid` with the value of the key ID
|
||||
- [x] yes
|
||||
- [ ] no
|
||||
* After generating a key for your service user, you must download the public key and sign your JWT with the public key
|
||||
- [ ] yes
|
||||
- [x] no (The json file contains the private key. Handle with care.)
|
||||
|
||||
</details>
|
||||
|
||||
## Summary
|
||||
|
||||
* With service users you can secure machine-to-machine communication
|
||||
* Because there is no interactive logon, you need to use a JWT signed with your private key to authorize the user
|
||||
* After successful authorization you can use an access token like for human users
|
||||
|
||||
Where to go from here:
|
||||
|
||||
* Management API
|
||||
* Securing backend API
|
||||
Reference in New Issue
Block a user