Skip to content

Commit 4dfb23f

Browse files
committed
Enhance plugin packaging workflow and add detailed README for OpenID Connect API Proxy
1 parent 2b37527 commit 4dfb23f

File tree

7 files changed

+113
-12
lines changed

7 files changed

+113
-12
lines changed

.github/workflows/package-and-release.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,32 @@ jobs:
4646
exit 1
4747
fi
4848
echo "dir_name=$dir_name" >> $GITHUB_OUTPUT
49-
- name: Get plugin name from manifest.yaml
50-
id: get_plugin_name
49+
- name: Get plugin info from manifest.yaml
50+
id: get_plugin_info
5151
run: |
52+
plugin_author=$(yq -r '.author | select(.)' manifest.yaml)
53+
if [ -z "$plugin_author" ]; then
54+
echo "Plugin author not found in manifest.yaml"
55+
exit 1
56+
fi
5257
plugin_name=$(yq -r '.name | select(.)' manifest.yaml)
5358
if [ -z "$plugin_name" ]; then
5459
echo "Plugin name not found in manifest.yaml"
5560
exit 1
5661
fi
62+
plugin_version=$(yq -r '.version | select(.)' manifest.yaml)
63+
if [ -z "$plugin_version" ]; then
64+
echo "Plugin version not found in manifest.yaml"
65+
exit 1
66+
fi
67+
echo "plugin_author=$plugin_author" >> $GITHUB_OUTPUT
5768
echo "plugin_name=$plugin_name" >> $GITHUB_OUTPUT
69+
echo "plugin_version=$plugin_version" >> $GITHUB_OUTPUT
5870
- name: Package the plugin
5971
id: package
6072
run: |
6173
dir_name="${{ steps.get_repo_dir_name.outputs.dir_name }}"
62-
plugin_name="${{ steps.get_plugin_name.outputs.plugin_name }}"
74+
plugin_name="${{ steps.get_plugin_info.outputs.plugin_author }}-${{ steps.get_plugin_info.outputs.plugin_name }}_${{ steps.get_plugin_info.outputs.plugin_version }}"
6375
plugin_file="../${plugin_name}.difypkg"
6476
echo "Packaging $plugin_name..."
6577
dify plugin package ../$dir_name -o $plugin_file

README.difypkg.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
![](./_assets/img_add_endpoint.jpg)
34+
35+
Input the OpenID Connect configuration and the API endpoint you want to relay, and click on the **Save** button.
36+
37+
![](./_assets/img_endpoint_setting.jpg)
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+
![](./_assets/img_endpoint_list.jpg)
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.

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# OpenID Connect API Proxy
44

55
[![GitHub Repo](https://img.shields.io/badge/GitHub_Repo-fujita--h/dify--plugin--oidc--api--proxy-blue?logo=github)](https://github.com/fujita-h/dify-plugin-oidc-api-proxy)
6-
![GitHub Release](https://img.shields.io/github/v/release/fujita-h/dify-plugin-oidc-api-proxy)
7-
![GitHub License](https://img.shields.io/github/license/fujita-h/dify-plugin-oidc-api-proxy)
6+
[![GitHub Release](https://img.shields.io/github/v/release/fujita-h/dify-plugin-oidc-api-proxy)](https://github.com/fujita-h/dify-plugin-oidc-api-proxy/releases)
7+
[![GitHub License](https://img.shields.io/github/license/fujita-h/dify-plugin-oidc-api-proxy)](https://github.com/fujita-h/dify-plugin-oidc-api-proxy/blob/main/LICENSE)
88

99
This plugin relays the API provided by Dify chat/workflow with OpenID Connect authentication enabled.
1010

@@ -30,6 +30,10 @@ Plugin automatically inputs the claim data obtained by OpenID Connect authentica
3030

3131
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.
3232

33+
## Configuration and Usage
34+
35+
See [Plugin README](./README.difypkg.md) for configuration and usage details.
36+
3337
## Contributing
3438

35-
This plugin is open-source and contributions are welcome. Please visit the GitHub repository to contribute.
39+
This plugin is open-source and contributions are welcome.

_assets/icon.svg

Lines changed: 0 additions & 6 deletions
This file was deleted.

_assets/img_add_endpoint.jpg

13 KB
Loading

_assets/img_endpoint_list.jpg

68 KB
Loading

_assets/img_endpoint_setting.jpg

30.9 KB
Loading

0 commit comments

Comments
 (0)