-
Notifications
You must be signed in to change notification settings - Fork 1
Authentication
Currently ap-npm has a simple implementation of a local auth-method. This was implemented just for testing purposes and although it works, it is not considered very safe and we recommend implementing your own. Using, for example, an API to verify users.
Takes in username, password and email and verifies user. Returns true or false to route.
Takes in username, password and email and tries to create the user. Returns true or false to route.
Note: npm login
is an alias for npm adduser
. When implementing your own auth-methods, just let userAdd return false if you manage your users elsewhere.
Takes in username and password and tries to remove the user. This has not been implemented yet in ap-npm. The function should work with the local auth-methods, but npm does not have a command to remove users from a registry. We might implement a route to allow this feature to be used outside of npm in the future, but for now it is not used yet.
- Create a new file with a class which implements the above mentioned methods.
- In the config file point auth.adapter to your created auth class file.
- Once you are done run
npm install -g babel-cli babel-preset-es2015 babel-preset-stage-2
as we need to convert the auth file to pre-ES6. - Run
babel- --presets es2015,stage-2 'your-auth-file.js' -d 'output-folder'
, this file will be usable by ap-npm.
If everything was implemented correctly your version of ap-npm should now use your own auth-methods.
export default class {
constructor(config) {
this.settings = config.auth;
}
userLogin(username, password, email) {
}
userAdd(username, password, email) {
}
userRemove(username, password) {
}