* New translations iis-server.md (Vietnamese) docs(website): new translations * New translations iis-server.md (Vietnamese) docs(website): new translations * New translations install.md (Vietnamese) docs(website): new translations * New translations install.md (Vietnamese) docs(website): new translations * New translations install.md (Vietnamese) docs(website): new translations * New translations kubernetes.md (Vietnamese) docs(website): new translations * New translations kubernetes.md (Vietnamese) docs(website): new translations * New translations auth.md (Polish) docs(website): new translations * New translations cli.md (Polish) docs(website): new translations * New translations config.md (Polish) docs(website): new translations * New translations contributing.md (Polish) docs(website): new translations * New translations dev-plugins.md (Polish) docs(website): new translations * New translations dev-plugins.md (Polish) docs(website): new translations * New translations notifications.md (Polish) docs(website): new translations * New translations protect-your-dependencies.md (Polish) docs(website): new translations * New translations en.json (Polish) docs(website): new translations * New translations en.json (Polish) docs(website): new translations * New translations puppet.md (Polish) docs(website): new translations * New translations en.json (Polish) docs(website): new translations * New translations install.md (Vietnamese) docs(website): new translations * New translations install.md (Italian) docs(website): new translations * New translations install.md (Polish) docs(website): new translations * New translations install.md (Russian) docs(website): new translations * New translations install.md (Korean) docs(website): new translations * New translations install.md (Portuguese) docs(website): new translations * New translations install.md (Spanish) docs(website): new translations * New translations install.md (Arabic) docs(website): new translations * New translations install.md (Chinese Simplified) docs(website): new translations * New translations install.md (Portuguese, Brazilian) docs(website): new translations * New translations install.md (Japanese) docs(website): new translations * New translations install.md (French) docs(website): new translations * New translations install.md (German) docs(website): new translations * New translations kubernetes.md (Vietnamese) docs(website): new translations * New translations kubernetes.md (Vietnamese) docs(website): new translations * New translations logger.md (Vietnamese) docs(website): new translations * New translations logger.md (Vietnamese) docs(website): new translations * New translations node-api.md (Vietnamese) docs(website): new translations * New translations dev-plugins.md (Russian) docs(website): new translations * New translations dev-plugins.md (Russian) docs(website): new translations * New translations dev-plugins.md (Russian) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations docker.md (Vietnamese) docs(website): new translations * New translations en.json (Vietnamese) docs(website): new translations * New translations en.json (Italian) docs(website): new translations * New translations en.json (Polish) docs(website): new translations * New translations en.json (Portuguese) docs(website): new translations * New translations en.json (Russian) docs(website): new translations * New translations en.json (Korean) docs(website): new translations * New translations en.json (Portuguese, Brazilian) docs(website): new translations * New translations en.json (Spanish) docs(website): new translations * New translations en.json (Chinese Simplified) docs(website): new translations * New translations en.json (German) docs(website): new translations * New translations en.json (Japanese) docs(website): new translations * New translations en.json (Arabic) docs(website): new translations * New translations en.json (French) docs(website): new translations * New translations logo.md (Arabic) docs(website): new translations * New translations logo.md (Chinese Simplified) docs(website): new translations * New translations logo.md (French) docs(website): new translations * New translations logo.md (German) docs(website): new translations * New translations logo.md (Italian) docs(website): new translations * New translations logo.md (Japanese) docs(website): new translations * New translations logo.md (Korean) docs(website): new translations * New translations logo.md (Polish) docs(website): new translations * New translations logo.md (Portuguese) docs(website): new translations * New translations logo.md (Portuguese, Brazilian) docs(website): new translations * New translations logo.md (Russian) docs(website): new translations * New translations logo.md (Spanish) docs(website): new translations * New translations logo.md (Vietnamese) docs(website): new translations * New translations web.md (Vietnamese) docs(website): new translations * New translations web.md (Italian) docs(website): new translations * New translations web.md (Polish) docs(website): new translations * New translations web.md (Russian) docs(website): new translations * New translations web.md (Portuguese) docs(website): new translations * New translations web.md (Korean) docs(website): new translations * New translations web.md (Portuguese, Brazilian) docs(website): new translations * New translations web.md (Spanish) docs(website): new translations * New translations web.md (Chinese Simplified) docs(website): new translations * New translations web.md (German) docs(website): new translations * New translations web.md (Japanese) docs(website): new translations * New translations web.md (Arabic) docs(website): new translations * New translations web.md (French) docs(website): new translations * New translations auth.md (Polish) docs(website): new translations * New translations en.json (Polish) docs(website): new translations * New translations ansible.md (Hindi) docs(website): new translations * New translations reverse-proxy.md (Hindi) docs(website): new translations * New translations logo.md (Hindi) docs(website): new translations * New translations chef.md (Hindi) docs(website): new translations * New translations puppet.md (Hindi) docs(website): new translations * New translations ci.md (Hindi) docs(website): new translations * New translations what-is-verdaccio.md (Hindi) docs(website): new translations * New translations node-api.md (Hindi) docs(website): new translations * New translations windows.md (Hindi) docs(website): new translations * New translations web.md (Hindi) docs(website): new translations * New translations use-cases.md (Hindi) docs(website): new translations * New translations uplinks.md (Hindi) docs(website): new translations * New translations test.md (Hindi) docs(website): new translations * New translations ssl.md (Hindi) docs(website): new translations * New translations server.md (Hindi) docs(website): new translations * New translations repositories.md (Hindi) docs(website): new translations * New translations auth.md (Hindi) docs(website): new translations * New translations protect-your-dependencies.md (Hindi) docs(website): new translations * New translations plugins.md (Hindi) docs(website): new translations * New translations packages.md (Hindi) docs(website): new translations * New translations notifications.md (Hindi) docs(website): new translations * New translations logger.md (Hindi) docs(website): new translations * New translations kubernetes.md (Hindi) docs(website): new translations * New translations install.md (Hindi) docs(website): new translations * New translations iis-server.md (Hindi) docs(website): new translations * New translations docker.md (Hindi) docs(website): new translations * New translations dev-plugins.md (Hindi) docs(website): new translations * New translations contributing.md (Hindi) docs(website): new translations * New translations config.md (Hindi) docs(website): new translations * New translations cli.md (Hindi) docs(website): new translations * New translations build.md (Hindi) docs(website): new translations * New translations en.json (Hindi) docs(website): new translations * New translations auth.md (Polish) docs(website): new translations * New translations auth.md (Polish) docs(website): new translations * New translations build.md (Polish) docs(website): new translations * New translations cli.md (Polish) docs(website): new translations * New translations ci.md (Polish) docs(website): new translations * New translations chef.md (Polish) docs(website): new translations * New translations config.md (Spanish) docs(website): new translations * New translations config.md (Spanish) docs(website): new translations * New translations config.md (Polish) docs(website): new translations * New translations config.md (Polish) docs(website): new translations * New translations config.md (Polish) docs(website): new translations * New translations config.md (Polish) docs(website): new translations * New translations contributing.md (Polish) docs(website): new translations * New translations contributing.md (Polish) docs(website): new translations * New translations dev-plugins.md (Polish) docs(website): new translations * New translations dev-plugins.md (Polish) docs(website): new translations * New translations dev-plugins.md (Polish) docs(website): new translations * New translations dev-plugins.md (Polish) docs(website): new translations * New translations iis-server.md (Polish) docs(website): new translations * New translations config.md (Spanish) docs(website): new translations * New translations config.md (Spanish) docs(website): new translations * New translations config.md (Spanish) docs(website): new translations * New translations logo.md (Spanish) docs(website): new translations * New translations docker.md (Spanish) docs(website): new translations * New translations web.md (Spanish) docs(website): new translations * New translations logo.md (Spanish) docs(website): new translations * New translations docker.md (Spanish) docs(website): new translations * New translations docker.md (Spanish) docs(website): new translations * New translations docker.md (Spanish) docs(website): new translations * New translations docker.md (Spanish) docs(website): new translations * New translations docker.md (Spanish) docs(website): new translations * New translations docker.md (Spanish) docs(website): new translations * New translations docker.md (Spanish) docs(website): new translations * New translations dev-plugins.md (Spanish) docs(website): new translations * New translations dev-plugins.md (Spanish) docs(website): new translations * New translations dev-plugins.md (Spanish) docs(website): new translations * New translations en.json (Italian) docs(website): new translations * New translations en.json (Polish) docs(website): new translations * New translations en.json (Vietnamese) docs(website): new translations * New translations en.json (Russian) docs(website): new translations * New translations en.json (Korean) docs(website): new translations * New translations en.json (Portuguese) docs(website): new translations * New translations en.json (Spanish) docs(website): new translations * New translations en.json (Portuguese, Brazilian) docs(website): new translations * New translations en.json (Arabic) docs(website): new translations * New translations en.json (Chinese Simplified) docs(website): new translations * New translations en.json (Japanese) docs(website): new translations * New translations en.json (French) docs(website): new translations * New translations en.json (German) docs(website): new translations * New translations en.json (Hindi) docs(website): new translations * New translations en.json (Polish) docs(website): new translations * New translations iis-server.md (Polish) docs(website): new translations * New translations iis-server.md (Polish) docs(website): new translations * New translations iis-server.md (Polish) docs(website): new translations * New translations iis-server.md (Polish) docs(website): new translations * New translations install.md (Polish) docs(website): new translations * New translations kubernetes.md (Polish) docs(website): new translations * New translations kubernetes.md (Polish) docs(website): new translations * New translations logger.md (Polish) docs(website): new translations * New translations notifications.md (Polish) docs(website): new translations * New translations packages.md (Polish) docs(website): new translations * New translations node-api.md (Polish) docs(website): new translations * New translations logo.md (Polish) docs(website): new translations * New translations config.md (Polish) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations docker.md (Russian) docs(website): new translations * New translations iis-server.md (Russian) docs(website): new translations * New translations iis-server.md (Russian) docs(website): new translations * New translations iis-server.md (Russian) docs(website): new translations * New translations en.json (Korean) docs(website): new translations * New translations en.json (Korean) docs(website): new translations * New translations en.json (Korean) docs(website): new translations * New translations en.json (Korean) docs(website): new translations * New translations iis-server.md (Russian) docs(website): new translations * New translations iis-server.md (Russian) docs(website): new translations * New translations iis-server.md (Russian) docs(website): new translations * New translations install.md (Russian) docs(website): new translations * New translations install.md (Russian) docs(website): new translations * New translations contributing.md (Italian) docs(website): new translations * New translations contributing.md (Korean) docs(website): new translations * New translations contributing.md (Vietnamese) docs(website): new translations * New translations contributing.md (Hindi) docs(website): new translations * New translations contributing.md (Portuguese) docs(website): new translations * New translations contributing.md (Russian) docs(website): new translations * New translations contributing.md (Spanish) docs(website): new translations * New translations contributing.md (Arabic) docs(website): new translations * New translations contributing.md (Chinese Simplified) docs(website): new translations * New translations contributing.md (Portuguese, Brazilian) docs(website): new translations * New translations contributing.md (Japanese) docs(website): new translations * New translations contributing.md (Polish) docs(website): new translations * New translations contributing.md (French) docs(website): new translations * New translations contributing.md (German) docs(website): new translations * New translations logger.md (Italian) docs(website): new translations * New translations logger.md (Korean) docs(website): new translations * New translations logger.md (Polish) docs(website): new translations * New translations logger.md (Vietnamese) docs(website): new translations * New translations logger.md (Hindi) docs(website): new translations * New translations logger.md (Portuguese) docs(website): new translations * New translations logger.md (Russian) docs(website): new translations * New translations logger.md (Spanish) docs(website): new translations * New translations logger.md (Arabic) docs(website): new translations * New translations logger.md (Chinese Simplified) docs(website): new translations * New translations logger.md (Portuguese, Brazilian) docs(website): new translations * New translations logger.md (Japanese) docs(website): new translations * New translations logger.md (French) docs(website): new translations * New translations logger.md (German) docs(website): new translations * New translations kubernetes.md (Russian) docs(website): new translations * New translations kubernetes.md (Russian) docs(website): new translations * New translations kubernetes.md (Russian) docs(website): new translations * New translations en.json (German) docs(website): new translations * New translations en.json (German) docs(website): new translations * New translations windows.md (German) docs(website): new translations * New translations en.json (German) docs(website): new translations * New translations ansible.md (Portuguese, Brazilian) docs(website): new translations * New translations auth.md (Portuguese, Brazilian) docs(website): new translations * New translations en.json (Portuguese, Brazilian) docs(website): new translations * New translations cli.md (Vietnamese) docs(website): new translations * New translations docker.md (Vietnamese) docs(website): new translations * New translations dev-plugins.md (Vietnamese) docs(website): new translations * New translations docker.md (Vietnamese) docs(website): new translations * New translations build.md (Portuguese, Brazilian) docs(website): new translations * New translations ci.md (Portuguese, Brazilian) docs(website): new translations * New translations chef.md (Portuguese, Brazilian) docs(website): new translations * New translations auth.md (Portuguese, Brazilian) docs(website): new translations * New translations config.md (Portuguese, Brazilian) docs(website): new translations * New translations ci.md (Portuguese, Brazilian) docs(website): new translations
7.1 KiB
id | title |
---|---|
dev-plugins | Phát triển các phần mềm bổ trợ |
Có nhiều cách để mở rộng verdaccio
. Các loại phần mềm bổ trợ là:
- Xác minh các phần mềm bổ trợ
- Phần mềm bổ trợ Middleware (kể từ phiên bản
v2.7.0
) - Phần mềm bổ trợ lưu trữ từ phiên bản (
v3.x
)
Chúng tôi khuyên bạn nên phát triển phần mềm bổ trợ bằng cách sử dụng định nghĩa loại luồng của chúng tôi.
Xác minh phần mềm bổ trợ
Cơ bản chúng ta phải trả về một đối tượng với phương thức được gọi là authenticate
, và sẽ nhận lại 3 tham số (user, password, callback
).
API
interface IPluginAuth extends IPlugin {
login_url?: string;
authenticate(user: string, password: string, cb: Callback): void;
adduser(user: string, password: string, cb: Callback): void;
allow_access(user: RemoteUser, pkg: $Subtype<PackageAccess>, cb: Callback): void;
allow_publish(user: RemoteUser, pkg: $Subtype<PackageAccess>, cb: Callback): void;
}
Chỉ có các tùy chọn là
adduser
,allow_access
vàallow_publish
và verdaccio cung cấp chức năng dự phòng trong tất cả các tùy chọn này.
Callback
Khi xác thực được thực hiện, có hai tùy chọn để trả lời verdaccio
.
OnError
Hiện lỗi này nghĩa là hoặc xảy ra lỗi hoặc xác thực không thành công.
callback(null, false)
OnSuccess
Xác thực thành công.
groups
là một tập hợp các chuỗi người dùng.
callback(null, groups);
Ví dụ
function Auth(config, stuff) {
var self = Object.create(Auth.prototype);
self._users = {};
// config for this module
self._config = config;
// verdaccio logger
self._logger = stuff.logger;
// pass verdaccio logger to ldapauth
self._config.client_options.log = stuff.logger;
return self;
}
Auth.prototype.authenticate = function (user, password, callback) {
var LdapClient = new LdapAuth(self._config.client_options);
....
LdapClient.authenticate(user, password, function (err, ldapUser) {
...
var groups;
...
callback(null, groups);
});
};
module.exports = Auth;
Cấu hình sẽ trông như thế này:
auth:
htpasswd:
file: ./htpasswd
Trong đó htpasswd
là tên của một phần mềm bổ trợ, ví dụ: hậu tố của verdaccio-htpasswd
. Các mã còn lại là các tham số của cấu hình phần mềm bổ trợ.
Phần mềm bổ trợ Middleware
Phần mềm bổ trợ Middleware có khả năng sửa đổi giao diện API để thêm các điểm cuối mới hoặc chặn các yêu cầu.
interface verdaccio$IPluginMiddleware extends verdaccio$IPlugin {
register_middlewares(app: any, auth: IBasicAuth, storage: IStorageManager): void;
}
register_middlewares
Phương thức này sẽ cung cấp đầy đủ cách truy cập để xác thực và lưu trữ thông qua auth
và storage
. Nếu bạn muốn thêm điểm cuối mới, hãy dùng ứng dụng app
.
Một ví dụ điển hình về phần mềm bổ trợ Middleware là sinopia-github-oauth và verdaccio-audit .
API
function register_middlewares(expressApp, authInstance, storageInstance) {
/* more stuff */
}
Bằng cách sử dụng một cách thức duy nhất để đăng ký middleware là register_middlewares
, chúng ta cần tìm một đối tượng có thể nhận được 3 tham số (expressApp, auth, storage
) được gọi là. Lớp xác thực Auth và lớp lưu trữ chính storage cho phép bạn truy cập vào tất cả các hoạt động lưu trữ.
Phần mềm bổ trợ lưu trữ
Theo mặc định, Verdaccio sử dụng phần mềm bổ trợ lưu trữ hệ thống tệp local-storage, tuy nhiên, từ phiên bản verdaccio@3.x
bạn có thể chèn lưu trữ tùy chỉnh thay vì hành vi mặc định.
API
Vì API lưu trữ phức tạp hơn nên bạn sẽ cần phải tạo một lớp (bao gồm nhóm các đối tượng mà có các thuộc tính chung) có thể hoàn tác lại việc sử dụng IPluginStorage
. Vui lòng xem chi tiết bên dưới.
class LocalDatabase<IPluginStorage>{
constructor(config: $Subtype<verdaccio$Config>, logger: verdaccio$Logger): ILocalData;
}
interface IPluginStorage {
logger: verdaccio$Logger;
config: $Subtype<verdaccio$Config>;
add(name: string, callback: verdaccio$Callback): void;
remove(name: string, callback: verdaccio$Callback): void;
get(callback: verdaccio$Callback): void;
getSecret(): Promise<string>;
setSecret(secret: string): Promise<any>;
getPackageStorage(packageInfo: string): verdaccio$IPackageStorage;
search(onPackage: verdaccio$Callback, onEnd: verdaccio$Callback, validateName: Function): void;
}
interface IPackageStorageManager {
path: string;
logger: verdaccio$Logger;
writeTarball(name: string): verdaccio$IUploadTarball;
readTarball(name: string): verdaccio$IReadTarball;
readPackage(fileName: string, callback: verdaccio$Callback): void;
createPackage(name: string, value: verdaccio$Package, cb: verdaccio$Callback): void;
deletePackage(fileName: string, callback: verdaccio$Callback): void;
removePackage(callback: verdaccio$Callback): void;
updatePackage(pkgFileName: string,
updateHandler: verdaccio$Callback,
onWrite: verdaccio$Callback,
transformPackage: Function,
onEnd: verdaccio$Callback): void;
savePackage(fileName: string, json: verdaccio$Package, callback: verdaccio$Callback): void;
}
class verdaccio$IUploadTarball extends stream$PassThrough {
abort: Function;
done: Function;
_transform: Function;
abort(): void;
done(): void;
}
class verdaccio$IReadTarball extends stream$PassThrough {
abort: Function;
abort(): void;
}
API lưu trữ vẫn đang trong quá trình chạy thử nghiệm và có thể sẽ được sửa đổi trong phiên bản tiếp theo. Để biết thêm thông tin về API lưu trữ, vui lòng truy cập và nhập định nghĩa trong kho lưu trữ chính thức của chúng tôi .
Những ví dụ về phần mềm bổ trợ bộ nhớ
Dưới đây là danh sách những phần mềm bổ trợ đang sử dụng API lưu trữ và có thể được sử dụng làm ví dụ.
Bạn đã sẵn sàng đóng góp vào phần mềm bổ trợ lưu trữ mới chưa? Nhấp vào đây.