Skip to content

Commit bdf6444

Browse files
update schema
1 parent 42665fa commit bdf6444

File tree

2 files changed

+161
-26
lines changed

2 files changed

+161
-26
lines changed

website/docs/components/publishing-to-a-registry.md

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,142 @@ oc publish my-component/ --username=your-username --password=your-password
7373

7474
### Custom Authentication
7575

76-
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+
return function (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",
128+
};
129+
}
130+
131+
ad = new ActiveDirectory(publishAuth);
132+
return {
133+
isValid: true,
134+
};
135+
};
136+
137+
module.exports.middleware = function (authConfig) {
138+
return basicAuth(function (username, password, callback) {
139+
return ad.authenticate(username, password, callback);
140+
});
141+
};
142+
```
143+
144+
#### Registry Configuration
145+
146+
To use custom authentication, configure your registry with the `publishAuth` setting:
147+
148+
```javascript
149+
// registry configuration
150+
{
151+
publishAuth: {
152+
type: require('oc-auth-ldap'),
153+
url: 'ldap://your-ldap-server.com',
154+
baseDN: 'dc=company,dc=com'
155+
}
156+
}
157+
```
158+
159+
#### Available Authentication Types
160+
161+
- **`basic`**: Built-in basic authentication (default)
162+
- **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+
return function (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).
77212

78213
## CLI Options
79214

website/static/schema.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,35 @@
2424
"https://staging-registry.com"
2525
]
2626
},
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-
},
5227
"development": {
5328
"description": "Development-specific configuration settings for local development and testing.",
5429
"type": "object",
5530
"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+
},
5656
"fallback": {
5757
"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.",
5858
"type": "object",

0 commit comments

Comments
 (0)