Skip to content
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

Docs: Plugins Revamp #506

Merged
merged 22 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1078740
(docs): Re-structuring the sidebar for plugins, renaming pages, and a…
dericksozo Jul 18, 2024
f69be34
Adding a draft of the database configuration plugin guide.
dericksozo Jul 24, 2024
8c5785d
(docs): Fixing the error.
dericksozo Jul 24, 2024
f6eeade
(docs): Adding the new authentication plugin guide.
dericksozo Jul 25, 2024
d530b17
(docs): Fixing the error
dericksozo Jul 25, 2024
f3176de
Merge branch 'main' into docs/plugins-revamp
dericksozo Jul 30, 2024
af9025a
(docs): Implementing Paz's feedback.
dericksozo Jul 31, 2024
0384967
Merge branch 'docs/plugins-revamp' of https://github.com/amplication/…
dericksozo Jul 31, 2024
6572d5e
Merge branch 'main' into docs/plugins-revamp
dericksozo Aug 5, 2024
7403889
Merge branch 'main' into docs/plugins-revamp
dericksozo Aug 12, 2024
c3095ef
(docs): 1. Re-writing the plugins page to make it more clear. Includi…
dericksozo Aug 12, 2024
18d2120
(docs): Fixing the errors.'
dericksozo Aug 12, 2024
fecf7bc
Merge branch 'main' into docs/plugins-revamp
dericksozo Aug 20, 2024
5579885
(docs): Implementing all of Paz's feedback.
dericksozo Aug 20, 2024
e07aa60
(docs): Adding the real authentication examples back into this docume…
dericksozo Aug 20, 2024
bd07801
(docs): Fixing the spelling issue.
dericksozo Aug 20, 2024
83068a3
(docs): Implementing Paz's feedback and making the authentication plu…
dericksozo Aug 22, 2024
659bc3d
(docs): Improiving the tabs component with a query string and also gr…
dericksozo Aug 22, 2024
db7611a
(docs): Implementing Paz's feedback.
dericksozo Sep 2, 2024
3d244f0
(docs): Implementing Paz's feedback.
dericksozo Sep 17, 2024
f9d7e74
Merge branch 'main' into docs/plugins-revamp
dericksozo Sep 17, 2024
df3c2ed
(docs): Fixing the sidebars.js file.
dericksozo Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/dictionary/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,5 @@ passwordless
Appsettings
appsettings
Codespaces
Keycloak
Keycloak
thirdparty
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 23 additions & 20 deletions docs/getting-started/plugins.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
---
id: plugins
title: Plugins Explained
description: Learn how to use Amplication plugins that extend the functionality of your generated application.
description: Learn how to use Amplication plugins to extend the functionality of your generated service.
sidebar_label: Plugins Explained
slug: /getting-started/plugins
pagination_next: plugins/overview
pagination_prev: getting-started/community-plugins
---

Amplication uses _Plugins_ to extend the functionality of your service.
Amplication uses _Plugins_ to extend the functionality of your generated service. These software additions allow developers to customize the default behavior of [Amplication's code generation process](/plugins/plugin-architecture/), providing hooks into various stages of service creation.

Amplication offers a wide range of community-created plugins that are open-source and available on GitHub. You also have the flexibility to develop your own [custom plugins](/plugins/overview/) so you can tailor your generated service to meet youe exact requirements.

You can enable certain plugins when you first create your service.
For example, if you choose MySQL as your database, the _MySQL DB_ plugin will be enabled.
If you choose to turn on authentication for your service, that will enable Authentication-related plugins.

To see all community-created plugins, first visit the _Plugins_ tab in your service's dashboard and click on _All Plugins_ on the left sidebar.
Your installed plugins are shown on the _Installed Plugins_ tab.
Plugins can be manually enabled or disabled on either of these tabs.

The source code of all community Amplication plugins are [available on GitHub](https://github.com/amplication/plugins).
Besides the plugins created by the Amplication team and the community, you can [develop your own custom plugins](/plugins/overview/).

:::tip
[Amplication's AI](/amplication-ai) can help you find new plugins for your service, and even install them automatically, with a single request.

Ask Jovu: `Which plugins do you recommend for adding caching capabilities to my Amplication service?`
:::

## Viewing Open-Source Plugin Code

All Amplication plugins are open-source and available on GitHub.
You can find the plugin source code for each individual plugin in Amplication's [`plugins`](https://github.com/amplication/amplication-plugins) repository.

## Node.js and .NET Plugins

Amplication supports both Node.js and .NET for code generation. Plugins are technology-specific.
Expand All @@ -42,17 +32,23 @@ Node.js plugins integrate seamlessly with the Node.js ecosystem and popular fram

## How To Install a Plugin

To install a plugin:
To see all community-created plugins, first visit the _Plugins_ tab in your Amplication dashboard.

1. In the _All Plugins_ page, click **Install** for the required plugin.
To install an individual plugin:

![](./assets/all-plugins.png)
1. On the left sidebar in the Plugins page, you can browse by _Plugin Categories_ categories like Database, Authentication, and more, or click on _All Plugins_ to see the complete list.
2. Click the **Install** button next to the desired plugin.
3. The plugin's toggle will switch to its _on_ state, indicating it's now active.
4. You can view all your installed plugins in the _Installed Plugins_ tab.
5. To see a plugin's source code on GitHub, select **View on GitHub** next to the installed plugin.

2. This will turn on the plugin's toggle into its _on_ state.
Plugins can be manually enabled or disabled from both the _All Plugins_ and _Installed Plugins_ tabs.

3. Go to the _Installed Plugins_ page. The installed plugins are listed.
![](./assets/all-plugins-and-categories.png)

4. To see the plugin's code on GitHub, select **View on GitHub**.
:::tip
Explore different plugin categories to discover plugins that can enhance specific parts of your service, such as database management, authentication, or API functionality.
:::

## How To Uninstall a Plugin

Expand Down Expand Up @@ -91,6 +87,13 @@ By default, the latest version of the plugin will be available in the list of pl
Each version of the Plugin has its own settings, so when you replace the version you also replace its settings.
:::

## How To View Open-Source Plugin Code

All Amplication plugins are open-source and available on GitHub.
You can find the plugin source code for each individual plugin in Amplication's [`plugins`](https://github.com/amplication/amplication-plugins) repository.

Besides the plugins created by the Amplication team and the community, you can [develop your own custom plugins](/plugins/overview/).

## How To Develop a Custom Plugin

To add more functionality, you can develop your own plugins, or can use plugins developed by the community, as they become available.
Expand Down
210 changes: 170 additions & 40 deletions docs/how-to/authentication-plugin-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,46 @@ pagination_next: getting-started/authentication

# Handle Authentication and Authorization in your Service

Authentication and authorization are important parts of your Amplication service. Amplication provides flexible options for implementing these security measures.
Authentication and authorization are crucial components of your Amplication service.

This guide will walk you through the process of updating your authentication and authorization setup in your Amplication-generated service.
By following this guide and exploring the examples, you'll be well-equipped to implement authentication and authorization in your Amplication-generated service using the authentication plugin that best suits your needs.

## Adding Authentication to Your Service

If you initially created your service without authentication, you can still add it later. Here are the key steps:
Before adding any specific authentication plugin, you must first enable the Authentication Entity in your service:
PazYanoverr marked this conversation as resolved.
Show resolved Hide resolved

1. Go to your service's Plugins page.
2. Navigate to the "Authentication" category in the left sidebar.
3. Choose and add an Auth Provider plugin (e.g., JWT, Auth0, etc.) that suits your needs.
4. Install the "NestJS Auth Module" plugin if it's not already installed. It's a pre-requisite if you're adding Authentication to a Node.js service.
5. Configure the Authentication Entity in your service settings.
1. Go to your service's Entities page.
2. Locate or create an entity to serve as your Authentication Entity (commonly named "User").
PazYanoverr marked this conversation as resolved.
Show resolved Hide resolved
3. In the entity's settings, enable the "Authentication Entity" option.
PazYanoverr marked this conversation as resolved.
Show resolved Hide resolved

For detailed instructions on this process, refer to the [Authentication Entity documentation](https://docs.amplication.com/user-entity).
:::note
The Authentication Entity **is required** to enable authentication on your service. For detailed instructions, refer to the [Authentication Entity documentation](https://docs.amplication.com/user-entity).
:::

After adding the required plugins, you'll need to:
1. Configure your authentication settings in the plugin options.
Once you have an Authentication Entity set up, follow these steps to add authentication:

1. Navigate to your service's Plugins page.
2. Go to the "Authentication" category in the left sidebar.
3. For Node.js services, ensure you install the "NestJS Auth Module" plugin first.
4. Choose and add an Auth Provider plugin that suits your needs (e.g., JWT, Auth0, Supertokens, etc.).
PazYanoverr marked this conversation as resolved.
Show resolved Hide resolved

After adding the required Authentication plugins:
1. Configure your authentication settings in the plugin options page (See the [Examples](#examples) section below).
2. Add authenticated users to your system.
3. Set up roles and permissions for authorization.
3. Set up [roles and permissions](/configure-roles-and-permissions/) for authorization.

## Available Authentication Plugins

Amplication offers several authentication plugins to choose from. Each plugin has its own configuration options and setup process.

### Node.js

1. [Auth0 Auth Provider](https://auth0.com/)
2. Basic Auth Provider
3. [JWT Auth Provider](https://jwt.io/)
4. [KeyCloak Auth Provider](https://www.keycloak.org/)
5. [SAML Auth Provider](https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language)
6. [Supertokens Auth Provider](https://supertokens.com/)
1. [JWT Auth Provider](https://jwt.io/)
2. [Auth0 Auth Provider](https://auth0.com/)
3. [Supertokens Auth Provider](https://supertokens.com/)
4. [SAML Auth Provider](https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language)
5. Basic Auth Provider
6. [KeyCloak Auth Provider](https://www.keycloak.org/)

#### JWT Auth Provider

Expand All @@ -66,9 +73,20 @@ Amplication offers several authentication plugins to choose from. Each plugin ha
- Uses Passport SAML strategy and generates JWT tokens for authorization.
- For usage details, check the [SAML Auth Provider GitHub README](https://github.com/amplication/plugins/tree/master/plugins/auth-saml).

### .NET
#### Basic Auth Provider

- Enables a straightforward authentication scheme built into the HTTP protocol. - Requires sending user's credentials in the form of a username and password, encoded in base64, included in the Authorization header of the request.
PazYanoverr marked this conversation as resolved.
Show resolved Hide resolved

#### KeyCloak Auth Provider

- Integrates KeyCloak authentication and authorization into your service.
- Provides single sign-on (SSO) capabilities and support for various identity protocols.
- Requires setup of a KeyCloak server and configuration of a KeyCloak realm.
- For detailed setup instructions and configuration options, refer to the [KeyCloak Auth Provider GitHub README](https://github.com/amplication/plugins/tree/master/plugins/auth-keycloak).

### .NET

For .NET services, ASP.NET Core Identity is currently the primary authentication option.
For .NET services, ASP.NET Core Identity is the primary authentication option.

#### ASP.NET Core Identity

Expand All @@ -82,36 +100,148 @@ If you're using a .NET service, refer to the [.NET Auth Core Identity plugin doc
4. Regularly update and rotate authentication secrets and keys.
5. Follow the principle of least privilege when assigning roles and permissions.

## Disable Authentication On Your Service

If you no longer need authentication on a specific service, you can disable it.

1. Visit your service's Plugins page and toggle the Authentication-related plugins into the off state.
2. Delete the User entity from your list of entities.
3. Re-build your project and commit your changes to your preferred git provider.

## Examples
PazYanoverr marked this conversation as resolved.
Show resolved Hide resolved

Here are some examples of how to use authentication in your service:
Let's look at detailed examples for some of the available authentication plugins:
PazYanoverr marked this conversation as resolved.
Show resolved Hide resolved

### JWT Auth Provider

The JWT Auth Provider adds JSON Web Token (JWT) authentication and authorization to your service.

#### Configuration

### JWT Authentication
```json
{
"settings": {
"tokenExpiresIn": 3600,
"refreshTokenExpiresIn": 604800,
"grantType": "PASSWORD",
"jwtSecretKey": "Change_ME!!!"
}
}
```

When using JWT authentication, the process typically includes:
- `tokenExpiresIn`: Expiration time of the access token in seconds (default: 3600)
- `refreshTokenExpiresIn`: Expiration time of the refresh token in seconds (default: 604800)
- `grantType`: The grant type for token generation (default: "PASSWORD")
- `jwtSecretKey`: Secret key for JWT signing (default: "Change_ME!!!")

1. Sending a login request to the server with username and password to get a JWT token.
2. Adding an authentication header with the JWT token to every subsequent request.
For detailed configuration, visit the [JWT Auth Provider GitHub README](https://github.com/amplication/plugins/tree/master/plugins/auth-jwt).

#### REST API Example
### Auth0 Auth Provider

```bash
curl -X 'POST' \
'https://[server-url]/api/login' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"username": "admin",
"password": "admin"
}'
The Auth0 Auth Provider integrates Auth0 authentication and authorization into your service.

#### Configuration

```json
{
"settings": {
"useManagementApi": true,
"managementParams": {
"identifier": "https://{TENANT_NAME}.{REGION}.auth0.com/api/v2/",
"accessToken": "{ACCESS_TOKEN}",
"actionName": "Add user details to access token",
"clientName": "Custom SPA",
"apiName": "Custom API",
"audience": "http://example.com"
}
}
}
```

#### GraphQL API Example
- `useManagementApi`: Set to `true` to use the Auth0 Management API
- `managementParams`: Configuration for the Management API
- `identifier`: The identifier of the Auth0 Management API
- `accessToken`: The access token of the Auth0 Management API
- `actionName`: The name of the action to create in Auth0
- `clientName`: The name of the client to create in Auth0
- `apiName`: The name of the API to create in Auth0
- `audience`: The audience/identifier of the API

For setup instructions and configuration options, check the [Auth0 Auth Provider GitHub README](https://github.com/amplication/plugins/tree/master/plugins/auth-auth0).

### Supertokens Auth Provider

The Supertokens Auth Provider adds Supertokens authentication to your service, supporting various authentication recipes.

#### Configuration

```json
{
"settings": {
"apiDomain": "http://localhost:3000",
"appName": "Amplication App",
"websiteDomain": "http://localhost:3001",
"websiteBasePath": "/auth",
"apiBasePath": "/api/auth",
"connectionUri": "https://try.supertokens.com",
"apiGatewayPath": "",
"apiKey": "",
"supertokensIdFieldName": "supertokensId",
"recipe": {
"name": "email-password"
}
}
}
```

```ts
mutation {
login(credentials: { username: "admin", password: "admin" }) {
accessToken
- `apiDomain`: The API domain for Supertokens
- `appName`: The name of your application
- `websiteDomain`: The website domain for Supertokens
- `websiteBasePath`: The base path for authentication on the website
- `apiBasePath`: The base path for authentication API endpoints
- `connectionUri`: The URI for connecting to the Supertokens core
- `supertokensIdFieldName`: The field name to store the Supertokens user ID
- `recipe`: The authentication recipe to use (e.g., "emailpassword", "passwordless", "thirdparty")

For detailed configuration and usage, refer to the [Supertokens Auth Provider GitHub README](https://github.com/amplication/plugins/tree/master/plugins/auth-supertokens).

### Keycloak Auth Provider

The Keycloak Auth Provider integrates Keycloak authentication and authorization into your service.

#### Configuration

```json
{
"settings": {
"port": 8080,
"realmID": "amplication-sample-realm",
"clientID": "amplication-server",
"realmName": "Amplication Sample Realm",
"clientName": "Amplication Server",
"clientDescription": "Sample client for Amplication Server",
"adminUsername": "admin",
"adminPassword": "admin",
"recipe": {
"emailFieldName": "email",
"verifyEmail": false,
"registrationAllowed": true,
"payLoadMapping": {
"username": "name",
"name": "name"
}
}
}
}
```

- `port`: The port on which to run the Keycloak server
- `realmID`: The ID of the Keycloak realm to use
- `clientID`: The ID of the Keycloak client to use
- `realmName`: The name of the Keycloak realm
- `clientName`: The name of the Keycloak client
- `adminUsername`: The username for the Keycloak admin user
- `adminPassword`: The password for the Keycloak admin user
- `recipe`: Configuration for the authentication recipe

For detailed setup instructions and configuration options, refer to the [Keycloak Auth Provider GitHub README](https://github.com/amplication/plugins/tree/master/plugins/auth-keycloak).
6 changes: 3 additions & 3 deletions docs/how-to/choose-configure-update-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: choose-configure-update-database
title: How To Choose, Configure, and Update Your Database
description: Learn how to choose, configure, and update your Amplication database using plugins.
sidebar_label: How To Choose, Configure, and Update Your Database
sidebar_label: Database Plugin Guide
slug: /plugins/guides/database
---

Expand All @@ -22,10 +22,10 @@ Amplication supports multiple database options. Here are the steps to choose you

1. When [creating a new service](/first-service/) using the wizard in Amplication, you'll be required to select a database. If you're using [Jovu](/amplication-ai/) to create your service, you can specify a different database than the default.
2. Choose from the available options, which may include:
- Microsoft SQL Server (default for .NET)
- PostgreSQL (default for Node.js)
PazYanoverr marked this conversation as resolved.
Show resolved Hide resolved
- MySQL
- Microsoft SQL Server
- MongoDB
- MySQL

Consider factors such as your team's familiarity with the database, scalability needs, and specific feature requirements when making your choice.

Expand Down
Loading