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
Registries can implement custom authentication strategies. Check with your registry administrator for specific requirements.
76
+
Registries can implement custom authentication strategies beyond basic username/password authentication. Custom authentication allows for integration with enterprise systems like LDAP, OAuth, or other identity providers.
77
+
78
+
#### How Custom Authentication Works
79
+
80
+
Custom authentication plugins must implement two functions:
81
+
82
+
1.**`validate`**: Validates the authentication configuration
83
+
2.**`middleware`**: Returns an Express middleware function for handling authentication
84
+
85
+
#### Basic Plugin Structure
86
+
87
+
```javascript
88
+
module.exports.validate=function (publishAuth) {
89
+
// Validate the configuration
90
+
if (!publishAuth.requiredField) {
91
+
return {
92
+
isValid:false,
93
+
message:"Missing required field: requiredField",
94
+
};
95
+
}
96
+
97
+
return {
98
+
isValid:true,
99
+
};
100
+
};
101
+
102
+
module.exports.middleware=function (authConfig) {
103
+
// Return Express middleware function
104
+
returnfunction (req, res, next) {
105
+
// Your authentication logic here
106
+
// Call next() on success, or send error response on failure
107
+
next();
108
+
};
109
+
};
110
+
```
111
+
112
+
#### LDAP Authentication Example
113
+
114
+
The [oc-auth-ldap](https://github.com/andyroyle/oc-auth-ldap) plugin demonstrates LDAP integration:
115
+
116
+
```javascript
117
+
"use strict";
118
+
119
+
var ActiveDirectory =require("activedirectory");
120
+
var basicAuth =require("basic-auth-connect");
121
+
var ad;
122
+
123
+
module.exports.validate=function (publishAuth) {
124
+
if (!publishAuth.url||!publishAuth.baseDN) {
125
+
return {
126
+
isValid:false,
127
+
message:"oc-auth-ldap misconfiguration: url and baseDN are required",
-**Custom plugins**: Any npm package that exports `validate` and `middleware` functions
163
+
-**Local modules**: Path to local authentication modules
164
+
165
+
#### Creating Your Own Authentication Plugin
166
+
167
+
1.**Create the plugin structure**:
168
+
169
+
```javascript
170
+
// my-auth-plugin.js
171
+
module.exports.validate=function (config) {
172
+
// Validate configuration
173
+
return { isValid:true };
174
+
};
175
+
176
+
module.exports.middleware=function (config) {
177
+
returnfunction (req, res, next) {
178
+
// Authentication logic
179
+
next();
180
+
};
181
+
};
182
+
```
183
+
184
+
2.**Package as npm module** (optional):
185
+
186
+
```json
187
+
{
188
+
"name": "oc-auth-custom",
189
+
"version": "1.0.0",
190
+
"main": "index.js"
191
+
}
192
+
```
193
+
194
+
3.**Configure in registry**:
195
+
```javascript
196
+
{
197
+
publishAuth: {
198
+
type:require('./my-auth-plugin'),
199
+
// your custom config
200
+
}
201
+
}
202
+
```
203
+
204
+
#### Troubleshooting Custom Authentication
205
+
206
+
-**Check plugin exports**: Ensure your plugin exports both `validate` and `middleware` functions
207
+
-**Validate configuration**: The `validate` function should return `{ isValid: true }` for valid configs
208
+
-**Test middleware**: Use `--dryRun` to test authentication without publishing
209
+
-**Check registry logs**: Contact your registry administrator for server-side authentication errors
210
+
211
+
For more examples and advanced authentication scenarios, check with your registry administrator or refer to the [OpenComponents authentication documentation](https://github.com/opencomponents/oc).
Copy file name to clipboardExpand all lines: website/static/schema.json
+25-25Lines changed: 25 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -24,35 +24,35 @@
24
24
"https://staging-registry.com"
25
25
]
26
26
},
27
-
"preload": {
28
-
"description": "List of component dependencies to preload. Preloading components can improve performance by fetching dependencies before they are needed.",
29
-
"type": "array",
30
-
"items": {
31
-
"type": "string",
32
-
"description": "Component name or path to preload"
33
-
},
34
-
"example": [
35
-
"header",
36
-
"footer",
37
-
"common-ui"
38
-
]
39
-
},
40
-
"routes": {
41
-
"description": "Custom routing configuration for components. Allows defining custom URL patterns and mappings for component rendering.",
42
-
"type": "object",
43
-
"additionalProperties": {
44
-
"type": "string",
45
-
"description": "Route pattern mapped to component name or path"
46
-
},
47
-
"example": {
48
-
"/custom-header": "header-component",
49
-
"/api/*": "api-wrapper"
50
-
}
51
-
},
52
27
"development": {
53
28
"description": "Development-specific configuration settings for local development and testing.",
54
29
"type": "object",
55
30
"properties": {
31
+
"preload": {
32
+
"description": "List of component dependencies to preload. Preloading components can improve performance by fetching dependencies before they are needed.",
33
+
"type": "array",
34
+
"items": {
35
+
"type": "string",
36
+
"description": "Component name or path to preload"
37
+
},
38
+
"example": [
39
+
"header",
40
+
"footer",
41
+
"common-ui"
42
+
]
43
+
},
44
+
"routes": {
45
+
"description": "Custom routing configuration for components. Allows defining custom URL patterns and mappings for component rendering.",
46
+
"type": "object",
47
+
"additionalProperties": {
48
+
"type": "string",
49
+
"description": "Route pattern mapped to component name or path"
50
+
},
51
+
"example": {
52
+
"/custom-header": "header-component",
53
+
"/api/*": "api-wrapper"
54
+
}
55
+
},
56
56
"fallback": {
57
57
"description": "Fallback configuration for when components cannot be found in the local registry. Allows specifying a fallback registry URL and optionally using its client library.",
0 commit comments