You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keyrings are a DevRev-specific mechanism for managing authentication with external services. Keyrings are called **Connections** in the DevRev app.
2
2
3
-
Keyrings provide a secure way to store and manage credentials for external services within your DevRev snap-in. This eliminates the need to expose sensitive information like passwords or access tokens directly within your code or configuration files, enhancing overall security.
3
+
Keyrings provides a secure way to store and manage credentials for external services within your DevRev snap-in. This eliminates the need to expose sensitive information like passwords or access tokens directly within your code or configuration files, enhancing overall security.
4
4
5
-
Keyrings are defined in the snap-in manifest under the `keyrings` section. They can be categorized into two main types:
5
+
For more information, refer to [Keyrings](/snapin-development/references/manifest#keyrings) in the snap-in manifest. They can be categorized into two main types:
6
6
7
7
1.**Default keyrings**:
8
-
-**Organization scoped keyrings**: These are secrets used by the entire organization, for example a Slack token for a workspace.
9
-
-**User scoped keyrings**: These are secrets for a single user, for example the token to interact with a single person's Google Calendar.
8
+
-**Organization scoped keyrings**: These are secrets used by the entire organization, for example, a Slack token for a workspace.
9
+
-**User scoped keyrings**: These are secrets for a single user, for example, the token to interact with a single person's Google Calendar.
10
10
11
11
<Calloutintent="note">
12
12
During installation, the user will be prompted to provide credentials for each keyring.
@@ -39,7 +39,7 @@ Breakdown:
39
39
40
40
- **display_name**: The name that's shown to the user when they're asked to provide a keyring.
41
41
42
-
All userscoped keyrings are optional in the snap-in, and developers must handle the case where a userscoped keyring isn't found.
42
+
All user-scoped keyrings are optional in the snap-in, and developers must handle the case where a user-scoped keyring isn't found.
43
43
44
44
<Callout intent="note">
45
45
If you are using version 1 of the manifest, you can omit the organization key in the keyring definition and directly provide the keyring definition as a list. All keyring defined in manifest version 1 are organization-scoped.
@@ -48,12 +48,12 @@ Additionally, the keyword `connections` is used instead of `keyrings` in manifes
48
48
49
49
2. **Developer scoped keyrings**: These are secrets accessible and usable only by the developer creating the snap-in, typically used for personal development workflows.
50
50
51
-
```yaml
52
-
developer_keyrings:
53
-
- name: my-secret-developer
54
-
description: A secret for the developer to use during development
55
-
display_name: Developer secret token
56
-
```
51
+
```yaml
52
+
developer_keyrings:
53
+
- name: my-secret-developer
54
+
description: A secret for the developer to use during development
55
+
display_name: Developer secret token
56
+
```
57
57
Breakdown:
58
58
59
59
- **name**: A unique identifier for the keyring in the snap-in.
@@ -62,38 +62,45 @@ Breakdown:
62
62
63
63
- **display_name**: The name that's shown to the user when they're asked to provide a keyring.
64
64
65
-
66
65
## Enable external service connections with keyring types
67
66
68
67
While DevRev offers pre-defined keyring types for common services, you can leverage this mechanism further to create custom types for specific service integrations.
69
68
70
-
71
69
### Pre-defined keyring types:
72
70
73
71
- **devrev-snap-in-secret**: Stores simple string tokens utilized by the snap-in itself.
74
72
75
73
- **devrev-atlassian-jira-oauth**: Facilitates OAuth connections for integrating with Jira.
- **devrev-github-oauth**: Facilitates OAuth connections for integrating with GitHub.
92
+
88
93
```text
89
94
scopes: repo admin:repo_hook admin:org notifications user write:discussion
90
95
```
91
96
- **devrev-zendesk-oauth**: Facilitates OAuth connections for integrating with Microsoft.
97
+
92
98
```text
93
99
scopes: read tickets:write
94
100
```
95
101
96
102
Manifest Declaration:
103
+
97
104
```yaml
98
105
keyrings:
99
106
organization:
@@ -109,135 +116,170 @@ While DevRev offers pre-defined keyring types for common services, you can lever
109
116
- devrev-google-calendar-oauth
110
117
display_name: Your secret token
111
118
```
112
-
113
-
### Reuse pre-defined keyring types:
114
-
While DevRev offers pre-defined keyring types for common services, these types provide further customization options for specific use cases. This section explores how you can leverage these predefined types and tailor them to your needs:
115
-
116
-
- **Client credentials**: These are credentials associated with your application, typically obtained from the service provider's developer console.
117
-
- **Scopes**: These define the specific permissions your application requests from the service.
118
-
119
-
1. Creating a developer keyring
120
-
121
-
- 1.1 **CLI command**:
119
+
3. **Custom keyring types for OAuth**:
120
+
121
+
Developer Keyring:
122
+
- The `developer_keyrings` type allows the creation of keyrings that hold sensitive information like client IDs and client secrets required for OAuth authorization with external services. These keyrings are intended for development environments and should not be used in production due to security concerns.
123
+
Here's an example configuration snippet demonstrating a `developer_keyring` named `custom-oauth-credentials`:
124
+
125
+
```yaml
126
+
developer_keyrings:
127
+
- name: custom-oauth-credentials
128
+
description: A secret for the developer to use during development
129
+
display_name: Developer secret token
130
+
```
131
+
132
+
To create a developer keyring, follow these steps:
133
+
- Replace `$CLIENT_CREDENTIALS` in the following command with your actual OAuth client ID and client secret combined into a JSON string.
134
+
- Execute Command: Run the following command, replacing `<name of the keyring>` with your desired keyring name.
Replace `$CLIENT_CREDENTIALS` with your actual OAuth client credentials.
126
-
127
-
- 1.2 **Manifest declaration**:
128
-
```yaml
129
-
developer_keyrings:
130
-
- name: my-oauth-secret
131
-
description: A secret for the developer to use during development
132
-
display_name: Developer secret token
137
+
echo $CLIENT_CREDENTIALS | devrev developer_keyring create oauth-secret <name of the keyring>
133
138
```
134
-
2. Customize predefined keyring type in manifest
135
-
``` yaml
136
-
keyring_types:
137
-
- id: reference-oauth-example-connection
138
-
name: Example OAuth Connection
139
-
description: A custom keyring type for Example OAuth connections.
140
-
kind: OAuth2
141
-
scopes:
142
-
- name: read
143
-
description: Read access to Example resources
144
-
value: read
145
-
- name: write
146
-
description: Write access to Example resources
147
-
value: write
148
-
is_optional: true
149
-
oauth_secret: my-oauth-secret
150
-
reference_keyring: devrev-example-oauth
151
-
```
152
-
**Breakdown** :
153
-
- **id**: A unique identifier for your custom type.
154
-
- **name**: A human-readable name for users.
155
-
- **description**: A clear explanation of the type's purpose.
156
-
- **kind**: Specifies the authentication method (here, OAuth2). Currently, only OAuth2 is supported.
157
-
- **scopes**: Adjust scopes as needed based on your requirements.
158
-
- **oauth_secret**: References the developer keyring where your credentials are stored.
159
-
- **reference_keyring**: Utilizes pre-defined Example OAuth logic for handling the OAuth flow.
160
-
161
-
3. Keyring usage in manifest
139
+
140
+
<Callout intent="note">
141
+
The keyring will be passed while `snap_in_version` is being created.
142
+
</Callout>
143
+
144
+
Keyring usage in manifest:
145
+
162
146
```yaml
163
-
keyrings:
164
-
organization:
165
-
- name: my-secret-org-token
166
-
description: Enables access to organization-wide resources (e.g., Slack workspace)
167
-
types:
168
-
- reference-oauth-example-connection
169
-
display_name: Organization secret token
147
+
keyrings:
148
+
organization:
149
+
- name: example connection
150
+
description: Enables access to organization-wide resources (e.g., Slack workspace)
151
+
types:
152
+
- custom-example-connection
153
+
display_name: Organization secret token
154
+
user:
155
+
- name: example connection
156
+
description: Enables access to organization-wide resources (e.g., Slack workspace)
157
+
types:
158
+
- custom-example-connection
159
+
display_name: Organization secret token
170
160
```
161
+
162
+
3.1. **Reusing Predefined keyring_type with Custom Scopes**:
163
+
Here's an example of a custom keyring type for an existing OAuth2 keyring type while customizing the required scopes for your specific external service.
164
+
165
+
```yaml
166
+
keyring_types:
167
+
- id: custom-example-connection
168
+
name: Example OAuth Connection
169
+
description: A custom keyring type for Example OAuth connections.
170
+
kind: OAuth2
171
+
oauth_secret: custom-oauth-credentials # Developer keyring that contains OAuth2 client ID and client secret. Shall be of keyring type `oauth-secret`.
172
+
reference_keyring: devrev-example-oauth # Predefined keyring type to be used as a reference for the custom keyring type
173
+
scopes:
174
+
- name: read
175
+
description: Read access to Example resources
176
+
value: read
177
+
- name: write
178
+
description: Write access to Example resources
179
+
value: write
180
+
is_optional: true
181
+
```
182
+
183
+
3.2. **Custom keyring type definition**:
184
+
This approach defines a new, entirely custom keyring type with complete control over the OAuth flow configuration.
185
+
186
+
```yaml
187
+
keyring_types:
188
+
- id: custom-example-connection // Unique identifier for your custom type, used in the `keyring` section of the manifest.
189
+
name: "Example Connection"
190
+
description: "Example connection"
191
+
kind: "Oauth2"
192
+
scopes: # Configuration for the scopes required by the external service for authorization
193
+
- name: "read"
194
+
description: "Read access to Example resources"
195
+
value: "read"
196
+
- name: "write"
197
+
description: "Write access to Example resources"
198
+
value: "write"
199
+
is_optional: true
200
+
scope_delimiter: ","# Delimiter used to separate scopes in the authorization request
201
+
oauth_secret: custom-oauth-credentials # Developer keyring that contains OAuth2 client ID and client secret. Shall be of keyring type `oauth-secret`.
202
+
authorize: # Configuration for the authorization request
203
+
type: "config"
204
+
grant_type: "authorization_code"
205
+
auth_url: "https://example.com/oauth/authorize"
206
+
token_url: "https://example.com/oauth/token"
207
+
organization_data: # Configuration for fetching organization data
description: A custom keyring type for connections with multiple fields.
259
+
kind: secret
260
+
secret_config: # Configuration for the secret fields required for the connection
261
+
fields:
262
+
- id: token
263
+
name: token
264
+
description: Token for connection
265
+
- id: username
266
+
name: username
267
+
description: Username for connection
268
+
- id: password
269
+
name: password
270
+
description: Password for connection
271
+
```
217
272
273
+
<Callout intent="note">
218
274
219
-
Breakdown:
275
+
**Supported keywords in keyring_type configuration**:
276
+
The supported keywords that can be dynamically inserted into URLs, headers, and query parameters within your custom keyring type configuration.
277
+
- **[ACCESS_TOKEN]**: The access token obtained during the OAuth flow.
278
+
- **[REFRESH_TOKEN]**: The refresh token obtained during the OAuth flow.
279
+
- **[CLIENT_ID]**: The client ID obtained from the OAuth client credentials.
280
+
- **[CLIENT_SECRET]**: The client secret obtained from the OAuth client credentials.
281
+
- **[SCOPE]**: The scope of the OAuth flow.
282
+
- **[API_KEY]**: The API key obtained from the basic flow.
283
+
</Callout>
220
284
221
-
- **id**: A unique identifier for your custom type.
222
-
- **name**: User-friendly name displayed in the manifest.
223
-
- **description**: Clear explanation of the type's purpose.
224
-
- **kind**: Specifies the authentication method (OAuth2).
225
-
- **scopes**: Permissions requested from Example (adjust based on your needs).
226
-
- **oauth_secret**: References the developer keyring containing your credentials.
227
-
228
-
Additional configuration:
229
-
230
-
- **authorize**: Defines the OAuth authorization flow.
231
-
- **type**: Set to "config" as configuration details are provided. Currently, only "config" is supported.
232
-
- **auth_url**: URL for user authorization.
233
-
- **token_url**: URL to obtain access and refresh tokens.
234
-
- **grant_type**: Grant type used in the authorization request. Currently, only "authorization_code" is supported.
235
-
236
-
- **organization_data**: Retrieves organization information after successful authorization.
237
-
- **refresh**: Defines how to refresh access tokens when they expire.
238
-
- **revoke**: Defines how to revoke access tokens when necessary.
239
-
- **url**: Endpoint for fetching organization data.
240
-
- **method**: HTTP method for the request.
241
-
- **headers**: Required headers for the request.
242
-
- **query_parameters**: Optional query parameters for the request.
243
-
- **response_jq**: JQ expression to extract relevant data from the response.
285
+
For examples of how to use keyrings in your snap-in, refer to the [Keyring API documentation](https://github.com/devrev/snap-in-examples/tree/main/13-keyring-type).
0 commit comments