2021-02-18 18:35:05 +00:00
|
|
|
const NoTokenRequiredAuth = require("./NoTokenRequiredAuth");
|
|
|
|
const TokenIpAuth = require("./TokenIpAuth");
|
|
|
|
const SimpleTokenAuth = require("./SimpleTokenAuth");
|
2018-06-25 15:40:57 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2021-02-18 18:35:05 +00:00
|
|
|
fromConfig: function (config) {
|
|
|
|
if (config.token && config.authorizedIps && config.authorizedIps.length) {
|
|
|
|
return new TokenIpAuth(config.token, config.authorizedIps);
|
|
|
|
} else if (config.token) {
|
2018-06-25 15:40:57 +00:00
|
|
|
return new SimpleTokenAuth(config.token);
|
2021-02-18 18:35:05 +00:00
|
|
|
} else {
|
2018-06-25 15:40:57 +00:00
|
|
|
return new NoTokenRequiredAuth();
|
|
|
|
}
|
2021-02-18 18:35:05 +00:00
|
|
|
},
|
|
|
|
};
|