|
| 1 | +# Overview |
| 2 | + |
| 3 | +This plugin provides the same API endpoints as the Dify Chat/Workflow API, but uses OpenID Connect authentication instead of Dify's API key authentication. |
| 4 | + |
| 5 | +You can use the endpoints created by this plugin to provide per-user authentication to the API. |
| 6 | + |
| 7 | +# Features |
| 8 | + |
| 9 | +## OpenID Connect authentication |
| 10 | + |
| 11 | +This plugin uses OpenID Connect authentication to authenticate users. You can access the API with the access token obtained by authenticating with OpenID Connect. |
| 12 | + |
| 13 | +## User parameter replacement |
| 14 | + |
| 15 | +You can also replace the `user` parameter specified in the original API with OpenID Connect authenticated claim data. For example, if you replace it with an email address, the user's email address will be displayed on the Dify app log screen. |
| 16 | + |
| 17 | +## Input claim data to the Chat/Workflow App |
| 18 | + |
| 19 | +Plugin automatically inputs the claim data obtained by OpenID Connect authentication into the Chat/Workflow App. You can use the claim data in the Chat/Workflow App. |
| 20 | + |
| 21 | +To use the claim data in the Chat/Workflow App, you need to specify the claim data name to the Start node's `input` parameter. For example, if you specify `__oidc_email` to the `input` parameter, you can use the email address in the Chat/Workflow App. |
| 22 | + |
| 23 | +# Configuration |
| 24 | + |
| 25 | +## 1. Install the plugin |
| 26 | + |
| 27 | +Install the plugin by clicking on the **Install** button. |
| 28 | + |
| 29 | +## 2. Add a endpoint |
| 30 | + |
| 31 | +Open the plugin, and click on the **+** button. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +Input the OpenID Connect configuration and the API endpoint you want to relay, and click on the **Save** button. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +## 3. Access the endpoint |
| 40 | + |
| 41 | +Now you can use the endpoint you created. You can see the list of API endpoints. |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +For example, the original Dify API endpoint for sending a chat message is `https://api.dify.ai/v1/chat-messages`. |
| 46 | + |
| 47 | +```shell |
| 48 | +curl -X POST 'https://api.dify.ai/v1/chat-messages' \ |
| 49 | +--header 'Authorization: Bearer {api_key}' \ |
| 50 | +--header 'Content-Type: application/json' \ |
| 51 | +--data-raw '{ |
| 52 | + "inputs": {}, |
| 53 | + "query": "What are the specs of the iPhone 13 Pro Max?", |
| 54 | + "response_mode": "streaming", |
| 55 | + "conversation_id": "", |
| 56 | + "user": "abc-123", |
| 57 | + "files": [ |
| 58 | + { |
| 59 | + "type": "image", |
| 60 | + "transfer_method": "remote_url", |
| 61 | + "url": "https://cloud.dify.ai/logo/logo-site.png" |
| 62 | + } |
| 63 | + ] |
| 64 | +}' |
| 65 | +``` |
| 66 | +In this scnario, the OpenID Connect API Proxy endpoint for sending a chat message is `https://daemon-plugin.dify.dev/SUF6pe2H3CccPBwY7H.../chat-messages`. |
| 67 | + |
| 68 | +```shell |
| 69 | +curl -X POST 'https://daemon-plugin.dify.dev/SUF6pe2H3CccPBwY7H.../chat-messages' \ |
| 70 | +--header 'Authorization: Bearer {OpenID Connect Access Token}' \ |
| 71 | +--header 'Content-Type: application/json' \ |
| 72 | +--data-raw '{ |
| 73 | + "inputs": {}, |
| 74 | + "query": "What are the specs of the iPhone 13 Pro Max?", |
| 75 | + "response_mode": "streaming", |
| 76 | + "conversation_id": "", |
| 77 | + "user": "abc-123", |
| 78 | + "files": [ |
| 79 | + { |
| 80 | + "type": "image", |
| 81 | + "transfer_method": "remote_url", |
| 82 | + "url": "https://cloud.dify.ai/logo/logo-site.png" |
| 83 | + } |
| 84 | + ] |
| 85 | +}' |
| 86 | +``` |
| 87 | + |
| 88 | +# Report Issues and Contributing |
| 89 | + |
| 90 | +Please report any issues to the [GitHub repository](https://github.com/fujita-h/dify-plugin-oidc-api-proxy). |
| 91 | +This plugin is open-source and contributions are welcome. |
0 commit comments