From 02e99277146d8bd912f2f19af1d3e94a6181d90d Mon Sep 17 00:00:00 2001 From: alecdwm Date: Tue, 13 Dec 2016 22:31:35 +0100 Subject: Initial support for LDAP server authentication Limitations as of this commit: - tlsOptions can only be specified in config.json, not as env vars - authentication failures are not yet gracefully handled by the UI - instead the error message is shown on a blank page (/auth/ldap) - no email address is associated with the LDAP user's account - no picture/profile URL is associated with the LDAP user's account - we might have to generate our own access + refresh tokens, because we aren't using oauth. The currently generated tokens are just a placeholder. - 'LDAP Sign in' needs to be translated to each locale --- README.md | 9 ++++++++- app.js | 6 ++++++ config.json.example | 12 ++++++++++++ lib/auth.js | 33 ++++++++++++++++++++++++++++++++- lib/config.js | 26 ++++++++++++++++++++++++++ lib/response.js | 2 ++ locales/en.json | 3 ++- package.json | 1 + public/views/index.ejs | 5 +++-- public/views/signin-ldap-modal.ejs | 35 +++++++++++++++++++++++++++++++++++ public/views/signin-modal.ejs | 10 ++++++++-- 11 files changed, 135 insertions(+), 7 deletions(-) create mode 100644 public/views/signin-ldap-modal.ejs diff --git a/README.md b/README.md index bdf97ee2..442cbd5c 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,13 @@ Environment variables (will overwrite other server configs) | HMD_DROPBOX_CLIENTSECRET | no example | Dropbox API client secret | | HMD_GOOGLE_CLIENTID | no example | Google API client id | | HMD_GOOGLE_CLIENTSECRET | no example | Google API client secret | +| HMD_LDAP_URL | ldap://example.com | url of LDAP server | +| HMD_LDAP_BINDDN | no example | bindDn for LDAP access | +| HMD_LDAP_BINDCREDENTIALS | no example | bindCredentials for LDAP access | +| HMD_LDAP_TOKENSECRET | supersecretkey | secret used for generating access/refresh tokens | +| HMD_LDAP_SEARCHBASE | o=users,dc=example,dc=com | LDAP directory to begin search from | +| HMD_LDAP_SEARCHFILTER | (uid={{username}}) | LDAP filter to search with | +| HMD_LDAP_SEARCHATTRIBUTES | no example | LDAP attributes to search with | | HMD_IMGUR_CLIENTID | no example | Imgur API client id | | HMD_EMAIL | `true` or `false` | set to allow email register and signin | | HMD_IMAGE_UPLOAD_TYPE | `imgur`, `s3` or `filesystem` | Where to upload image. For S3, see our [S3 Image Upload Guide](docs/guides/s3-image-upload.md) | @@ -182,7 +189,7 @@ Third-party integration api key settings | service | settings location | description | | ------- | --------- | ----------- | -| facebook, twitter, github, gitlab, dropbox, google | environment variables or `config.json` | for signin | +| facebook, twitter, github, gitlab, dropbox, google, ldap | environment variables or `config.json` | for signin | | imgur | environment variables or `config.json` | for image upload | | google drive, dropbox | `public/js/config.js` | for export and import | diff --git a/app.js b/app.js index 0d78a153..44054961 100644 --- a/app.js +++ b/app.js @@ -380,6 +380,12 @@ if (config.google) { failureRedirect: config.serverurl + '/' })); } +// ldap auth +if (config.ldap) { + app.post('/auth/ldap', urlencodedParser, + passport.authenticate('ldapauth', { successRedirect: '/' }) + ); +} // email auth if (config.email) { app.post('/register', urlencodedParser, function (req, res, next) { diff --git a/config.json.example b/config.json.example index 22fd5c92..642df4f6 100644 --- a/config.json.example +++ b/config.json.example @@ -45,6 +45,18 @@ "clientID": "change this", "clientSecret": "change this" }, + "ldap": { + "url": "ldap://change_this", + "bindDn": null, + "bindCredentials": null, + "tokenSecret": "change this", + "searchBase": "change this", + "searchFilter": "change this", + "searchAttributes": "change this", + "tlsOptions": { + "changeme": "See https://nodejs.org/api/tls.html#tls_tls_connect_options_callback" + } + }, "imgur": { "clientID": "change this" } diff --git a/lib/auth.js b/lib/auth.js index f167cede..1e21eb9f 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -7,6 +7,7 @@ var GithubStrategy = require('passport-github').Strategy; var GitlabStrategy = require('passport-gitlab2').Strategy; var DropboxStrategy = require('passport-dropbox-oauth2').Strategy; var GoogleStrategy = require('passport-google-oauth20').Strategy; +var LdapStrategy = require('passport-ldapauth'); var LocalStrategy = require('passport-local').Strategy; var validator = require('validator'); @@ -110,6 +111,36 @@ if (config.google) { callbackURL: config.serverurl + '/auth/google/callback' }, callback)); } +// ldap +if (config.ldap) { + passport.use(new LdapStrategy({ + server: { + url: config.ldap.url || null, + bindDn: config.ldap.bindDn || null, + bindCredentials: config.ldap.bindCredentials || null, + searchBase: config.ldap.searchBase || null, + searchFilter: config.ldap.searchFilter || null, + searchAttributes: config.ldap.searchAttributes || null, + tlsOptions: config.ldap.tlsOptions || null + }, + }, + function(user, done) { + var profile = { + id: 'LDAP-' + user.uidNumber, + username: user.uid, + displayName: user.displayName, + emails: [], + avatarUrl: null, + profileUrl: null, + provider: 'ldap', + } + var stringifiedProfile = JSON.stringify(profile); + // TODO: Generate secure tokens for LDAP users + var accessToken = 'debug-access-token|LDAP-' + user.uidNumber + '|' + config.ldap.tokenSecret + '|' + new Date().getTime(); + var refreshToken = 'debug-refresh-token|LDAP-' + user.uidNumber + '|' + config.ldap.tokenSecret + '|' + new Date().getTime(); + callback(accessToken, refreshToken, profile, done); + })); +} // email if (config.email) { passport.use(new LocalStrategy({ @@ -130,4 +161,4 @@ if (config.email) { return done(err); }); })); -} \ No newline at end of file +} diff --git a/lib/config.js b/lib/config.js index 669fcaa8..a44c279b 100644 --- a/lib/config.js +++ b/lib/config.js @@ -93,6 +93,31 @@ var google = (process.env.HMD_GOOGLE_CLIENTID && process.env.HMD_GOOGLE_CLIENTSE clientID: process.env.HMD_GOOGLE_CLIENTID, clientSecret: process.env.HMD_GOOGLE_CLIENTSECRET } : config.google || false; +var ldap = config.ldap || ( + process.env.HMD_LDAP_URL || + process.env.HMD_LDAP_BINDDN || + process.env.HMD_LDAP_BINDCREDENTIALS || + process.env.HMD_LDAP_TOKENSECRET || + process.env.HMD_LDAP_SEARCHBASE || + process.env.HMD_LDAP_SEARCHFILTER || + process.env.HMD_LDAP_SEARCHATTRIBUTES +) || false; +if (ldap == true) + ldap = {}; +if (process.env.HMD_LDAP_URL) + ldap.url = process.env.HMD_LDAP_URL; +if (process.env.HMD_LDAP_BINDDN) + ldap.bindDn = process.env.HMD_LDAP_BINDDN; +if (process.env.HMD_LDAP_BINDCREDENTIALS) + ldap.bindCredentials = process.env.HMD_LDAP_BINDCREDENTIALS; +if (process.env.HMD_LDAP_TOKENSECRET) + ldap.tokenSecret = process.env.HMD_LDAP_TOKENSECRET; +if (process.env.HMD_LDAP_SEARCHBASE) + ldap.searchBase = process.env.HMD_LDAP_SEARCHBASE; +if (process.env.HMD_LDAP_SEARCHFILTER) + ldap.searchFilter = process.env.HMD_LDAP_SEARCHFILTER; +if (process.env.HMD_LDAP_SEARCHATTRIBUTES) + ldap.searchAttributes = process.env.HMD_LDAP_SEARCHATTRIBUTES; var imgur = process.env.HMD_IMGUR_CLIENTID || config.imgur || false; var email = process.env.HMD_EMAIL || config.email || false; @@ -151,6 +176,7 @@ module.exports = { gitlab: gitlab, dropbox: dropbox, google: google, + ldap: ldap, imgur: imgur, email: email, imageUploadType: imageUploadType, diff --git a/lib/response.js b/lib/response.js index aae39851..f0f49181 100755 --- a/lib/response.js +++ b/lib/response.js @@ -66,6 +66,7 @@ function showIndex(req, res, next) { gitlab: config.gitlab, dropbox: config.dropbox, google: config.google, + ldap: config.ldap, email: config.email, signin: req.isAuthenticated(), infoMessage: req.flash('info'), @@ -98,6 +99,7 @@ function responseHackMD(res, note) { gitlab: config.gitlab, dropbox: config.dropbox, google: config.google, + ldap: config.ldap, email: config.email }); } diff --git a/locales/en.json b/locales/en.json index f1f0d140..dda317f1 100644 --- a/locales/en.json +++ b/locales/en.json @@ -100,5 +100,6 @@ "Select From Available Snippets": "Select From Available Snippets", "OR": "OR", "Export to Snippet": "Export to Snippet", - "Select Visibility Level": "Select Visibility Level" + "Select Visibility Level": "Select Visibility Level", + "LDAP Sign in": "LDAP Sign in" } \ No newline at end of file diff --git a/package.json b/package.json index 5203e54b..4ef10312 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "passport-github": "^1.1.0", "passport-gitlab2": "^2.2.0", "passport-google-oauth20": "^1.0.0", + "passport-ldapauth": "^0.6.0", "passport-local": "^1.0.0", "passport-twitter": "^1.0.4", "passport.socketio": "^3.6.2", diff --git a/public/views/index.ejs b/public/views/index.ejs index 2bec7de0..baca1417 100644 --- a/public/views/index.ejs +++ b/public/views/index.ejs @@ -57,7 +57,7 @@ <% if (errorMessage && errorMessage.length > 0) { %>
<%= errorMessage %>
<% } %> - <% if(facebook || twitter || github || gitlab || dropbox || google || email) { %> + <% if(facebook || twitter || github || gitlab || dropbox || google || ldap || email) { %>
<%= __('Sign In') %> @@ -93,7 +93,7 @@
style="display:none;"<% } %>> - <% if(facebook || twitter || github || gitlab || dropbox || google || email) { %> + <% if(facebook || twitter || github || gitlab || dropbox || google || ldap || email) { %> @@ -192,6 +192,7 @@
<%- include signin-modal %> + <%- include signin-ldap-modal %> <% if(useCDN) { %> diff --git a/public/views/signin-ldap-modal.ejs b/public/views/signin-ldap-modal.ejs new file mode 100644 index 00000000..6a665f17 --- /dev/null +++ b/public/views/signin-ldap-modal.ejs @@ -0,0 +1,35 @@ + + diff --git a/public/views/signin-modal.ejs b/public/views/signin-modal.ejs index acbad256..ba6c57ff 100644 --- a/public/views/signin-modal.ejs +++ b/public/views/signin-modal.ejs @@ -38,7 +38,13 @@ <%= __('Sign in via %s', 'Google') %> <% } %> - <% if((facebook || twitter || github || gitlab || dropbox || google) && email) { %> + <% if(ldap) { %> + + <%= __('Sign in via %s', 'LDAP') %> + + <% } %> + + <% if((facebook || twitter || github || gitlab || dropbox || google || ldap) && email) { %>
<% }%> <% if(email) { %> @@ -67,4 +73,4 @@ - \ No newline at end of file + -- cgit v1.2.3 From 6ba9a2f039fe9c4d7495d30ae4f255b96d7f7530 Mon Sep 17 00:00:00 2001 From: alecdwm Date: Wed, 14 Dec 2016 11:49:33 +0100 Subject: Added HMD_LDAP_TLS_CA env variable --- README.md | 1 + lib/config.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 442cbd5c..30313fe3 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ Environment variables (will overwrite other server configs) | HMD_LDAP_SEARCHBASE | o=users,dc=example,dc=com | LDAP directory to begin search from | | HMD_LDAP_SEARCHFILTER | (uid={{username}}) | LDAP filter to search with | | HMD_LDAP_SEARCHATTRIBUTES | no example | LDAP attributes to search with | +| HMD_LDAP_TLS_CA | no example | Root CA for LDAP TLS in PEM format | | HMD_IMGUR_CLIENTID | no example | Imgur API client id | | HMD_EMAIL | `true` or `false` | set to allow email register and signin | | HMD_IMAGE_UPLOAD_TYPE | `imgur`, `s3` or `filesystem` | Where to upload image. For S3, see our [S3 Image Upload Guide](docs/guides/s3-image-upload.md) | diff --git a/lib/config.js b/lib/config.js index a44c279b..053d083b 100644 --- a/lib/config.js +++ b/lib/config.js @@ -118,6 +118,12 @@ if (process.env.HMD_LDAP_SEARCHFILTER) ldap.searchFilter = process.env.HMD_LDAP_SEARCHFILTER; if (process.env.HMD_LDAP_SEARCHATTRIBUTES) ldap.searchAttributes = process.env.HMD_LDAP_SEARCHATTRIBUTES; +if (process.env.HMD_LDAP_TLS_CA) { + var ca = { + ca: process.env.HMD_LDAP_TLS_CA + } + ldap.tlsOptions = ldap.tlsOptions ? Object.assign(ldap.tlsOptions, ca) : ca +} var imgur = process.env.HMD_IMGUR_CLIENTID || config.imgur || false; var email = process.env.HMD_EMAIL || config.email || false; -- cgit v1.2.3 From 30071637998097b25a36b69af3a1affe3c18bf23 Mon Sep 17 00:00:00 2001 From: alecdwm Date: Wed, 14 Dec 2016 11:50:10 +0100 Subject: Tokens not required for ldap auth --- lib/auth.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/lib/auth.js b/lib/auth.js index 1e21eb9f..b2c787b9 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -135,10 +135,36 @@ if (config.ldap) { provider: 'ldap', } var stringifiedProfile = JSON.stringify(profile); - // TODO: Generate secure tokens for LDAP users - var accessToken = 'debug-access-token|LDAP-' + user.uidNumber + '|' + config.ldap.tokenSecret + '|' + new Date().getTime(); - var refreshToken = 'debug-refresh-token|LDAP-' + user.uidNumber + '|' + config.ldap.tokenSecret + '|' + new Date().getTime(); - callback(accessToken, refreshToken, profile, done); + models.User.findOrCreate({ + where: { + profileid: profile.id.toString() + }, + defaults: { + profile: stringifiedProfile, + } + }).spread(function (user, created) { + if (user) { + var needSave = false; + if (user.profile != stringifiedProfile) { + user.profile = stringifiedProfile; + needSave = true; + } + if (needSave) { + user.save().then(function () { + if (config.debug) + logger.info('user login: ' + user.id); + return done(null, user); + }); + } else { + if (config.debug) + logger.info('user login: ' + user.id); + return done(null, user); + } + } + }).catch(function (err) { + logger.error('ldap auth failed: ' + err); + return done(err, null); + }); })); } // email -- cgit v1.2.3 From fc8d709afb8a0ff78f649c9ec3b405a68b56a3c0 Mon Sep 17 00:00:00 2001 From: alecdwm Date: Wed, 14 Dec 2016 12:40:54 +0100 Subject: LDAP login improvements - return bad request if no username or password given - return to referer url on auth success - flash error message on auth failure --- app.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 44054961..e3ce93de 100644 --- a/app.js +++ b/app.js @@ -382,9 +382,15 @@ if (config.google) { } // ldap auth if (config.ldap) { - app.post('/auth/ldap', urlencodedParser, - passport.authenticate('ldapauth', { successRedirect: '/' }) - ); + app.post('/auth/ldap', urlencodedParser, function (req, res, next) { + if (!req.body.username || !req.body.password) return response.errorBadRequest(res); + setReturnToFromReferer(req); + passport.authenticate('ldapauth', { + successReturnToOrRedirect: config.serverurl + '/', + failureRedirect: config.serverurl + '/', + failureFlash: true + })(req, res, next); + }); } // email auth if (config.email) { -- cgit v1.2.3 From 72a0e90f7d09d8a4e06a2629dcb9404eb37c64a0 Mon Sep 17 00:00:00 2001 From: alecdwm Date: Wed, 14 Dec 2016 12:42:42 +0100 Subject: LDAP signin form moved to main signin-modal - previously was a separate modal - now is located on main modal, like email auth --- locales/en.json | 3 +-- public/views/index.ejs | 1 - public/views/signin-ldap-modal.ejs | 35 ----------------------------------- public/views/signin-modal.ejs | 27 +++++++++++++++++++++++---- 4 files changed, 24 insertions(+), 42 deletions(-) delete mode 100644 public/views/signin-ldap-modal.ejs diff --git a/locales/en.json b/locales/en.json index dda317f1..f1f0d140 100644 --- a/locales/en.json +++ b/locales/en.json @@ -100,6 +100,5 @@ "Select From Available Snippets": "Select From Available Snippets", "OR": "OR", "Export to Snippet": "Export to Snippet", - "Select Visibility Level": "Select Visibility Level", - "LDAP Sign in": "LDAP Sign in" + "Select Visibility Level": "Select Visibility Level" } \ No newline at end of file diff --git a/public/views/index.ejs b/public/views/index.ejs index baca1417..39674b02 100644 --- a/public/views/index.ejs +++ b/public/views/index.ejs @@ -192,7 +192,6 @@ <%- include signin-modal %> - <%- include signin-ldap-modal %> <% if(useCDN) { %> diff --git a/public/views/signin-ldap-modal.ejs b/public/views/signin-ldap-modal.ejs deleted file mode 100644 index 6a665f17..00000000 --- a/public/views/signin-ldap-modal.ejs +++ /dev/null @@ -1,35 +0,0 @@ - - diff --git a/public/views/signin-modal.ejs b/public/views/signin-modal.ejs index ba6c57ff..e71b09c6 100644 --- a/public/views/signin-modal.ejs +++ b/public/views/signin-modal.ejs @@ -38,12 +38,31 @@ <%= __('Sign in via %s', 'Google') %> <% } %> + <% if((facebook || twitter || github || gitlab || dropbox || google) && ldap) { %> +
+ <% }%> <% if(ldap) { %> - - <%= __('Sign in via %s', 'LDAP') %> - +

Via LDAP

+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
<% } %> - <% if((facebook || twitter || github || gitlab || dropbox || google || ldap) && email) { %>
<% }%> -- cgit v1.2.3 From 3491f97f7e18a811e516431fa55429f015cef8c4 Mon Sep 17 00:00:00 2001 From: alecdwm Date: Wed, 14 Dec 2016 13:24:25 +0100 Subject: LDAP auth use email if provided --- lib/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/auth.js b/lib/auth.js index b2c787b9..4b14e42c 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -129,7 +129,7 @@ if (config.ldap) { id: 'LDAP-' + user.uidNumber, username: user.uid, displayName: user.displayName, - emails: [], + emails: user.mail ? [user.mail] : [], avatarUrl: null, profileUrl: null, provider: 'ldap', -- cgit v1.2.3 From 01361afa7a739f05493ca4a718d6ce5ffe728bc4 Mon Sep 17 00:00:00 2001 From: alecdwm Date: Fri, 6 Jan 2017 05:37:40 +0100 Subject: Profile pictures for LDAP users --- lib/letter-avatars.js | 23 +++++++++++++++++++++++ lib/models/user.js | 11 +++++++++++ package.json | 1 + 3 files changed, 35 insertions(+) create mode 100644 lib/letter-avatars.js diff --git a/lib/letter-avatars.js b/lib/letter-avatars.js new file mode 100644 index 00000000..e4d4f840 --- /dev/null +++ b/lib/letter-avatars.js @@ -0,0 +1,23 @@ +"use strict"; + +// external modules +var seedrandom = require('seedrandom'); + +// core +module.exports = function(name) { + var colors = ["#5A8770", "#B2B7BB", "#6FA9AB", "#F5AF29", "#0088B9", "#F18636", "#D93A37", "#A6B12E", "#5C9BBC", "#F5888D", "#9A89B5", "#407887", "#9A89B5", "#5A8770", "#D33F33", "#A2B01F", "#F0B126", "#0087BF", "#F18636", "#0087BF", "#B2B7BB", "#72ACAE", "#9C8AB4", "#5A8770", "#EEB424", "#407887"]; + var color = colors[Math.floor(seedrandom(name)() * colors.length)]; + var letter = name.substring(0, 1).toUpperCase(); + + var svg = ''; + svg += ''; + svg += ''; + svg += ''; + svg += ''; + svg += '' + letter + ''; + svg += ''; + svg += ''; + svg += ''; + + return 'data:image/svg+xml;base64,' + new Buffer(svg).toString('base64'); +}; diff --git a/lib/models/user.js b/lib/models/user.js index aaf344de..7d27242c 100644 --- a/lib/models/user.js +++ b/lib/models/user.js @@ -7,6 +7,7 @@ var scrypt = require('scrypt'); // core var logger = require("../logger.js"); +var letterAvatars = require('../letter-avatars.js'); module.exports = function (sequelize, DataTypes) { var User = sequelize.define("User", { @@ -105,6 +106,16 @@ module.exports = function (sequelize, DataTypes) { case "google": photo = profile.photos[0].value.replace(/(\?sz=)\d*$/i, '$196'); break; + case "ldap": + //no image api provided, + //use gravatar if email exists, + //otherwise generate a letter avatar + if (profile.emails[0]) { + photo = 'https://www.gravatar.com/avatar/' + md5(profile.emails[0]) + '?s=96'; + } else { + photo = letterAvatars(profile.username); + } + break; } return photo; }, diff --git a/package.json b/package.json index 4ef10312..e75f901e 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,7 @@ "reveal.js": "^3.3.0", "sequelize": "^3.24.3", "scrypt": "^6.0.3", + "seedrandom": "^2.4.2", "select2": "^3.5.2-browserify", "sequelize-cli": "^2.4.0", "shortid": "2.2.6", -- cgit v1.2.3 From b044c2ae19e1cacf81524dad15739ea61f4479cb Mon Sep 17 00:00:00 2001 From: alecdwm Date: Fri, 6 Jan 2017 07:06:58 +0100 Subject: Use randomcolor not seedrandom for avatar backgrounds --- lib/letter-avatars.js | 5 ++--- package.json | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/letter-avatars.js b/lib/letter-avatars.js index e4d4f840..437e3e76 100644 --- a/lib/letter-avatars.js +++ b/lib/letter-avatars.js @@ -1,12 +1,11 @@ "use strict"; // external modules -var seedrandom = require('seedrandom'); +var randomcolor = require('randomcolor'); // core module.exports = function(name) { - var colors = ["#5A8770", "#B2B7BB", "#6FA9AB", "#F5AF29", "#0088B9", "#F18636", "#D93A37", "#A6B12E", "#5C9BBC", "#F5888D", "#9A89B5", "#407887", "#9A89B5", "#5A8770", "#D33F33", "#A2B01F", "#F0B126", "#0087BF", "#F18636", "#0087BF", "#B2B7BB", "#72ACAE", "#9C8AB4", "#5A8770", "#EEB424", "#407887"]; - var color = colors[Math.floor(seedrandom(name)() * colors.length)]; + var color = randomcolor({seed: name}); var letter = name.substring(0, 1).toUpperCase(); var svg = ''; diff --git a/package.json b/package.json index e75f901e..4ef10312 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,6 @@ "reveal.js": "^3.3.0", "sequelize": "^3.24.3", "scrypt": "^6.0.3", - "seedrandom": "^2.4.2", "select2": "^3.5.2-browserify", "sequelize-cli": "^2.4.0", "shortid": "2.2.6", -- cgit v1.2.3 From e4fe93249f2af24b113573825aa66350b25e405e Mon Sep 17 00:00:00 2001 From: alecdwm Date: Fri, 6 Jan 2017 07:18:22 +0100 Subject: dark avatar backgrounds only --- lib/letter-avatars.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/letter-avatars.js b/lib/letter-avatars.js index 437e3e76..767a2efd 100644 --- a/lib/letter-avatars.js +++ b/lib/letter-avatars.js @@ -5,7 +5,10 @@ var randomcolor = require('randomcolor'); // core module.exports = function(name) { - var color = randomcolor({seed: name}); + var color = randomcolor({ + seed: name, + luminosity: 'dark', + }); var letter = name.substring(0, 1).toUpperCase(); var svg = ''; -- cgit v1.2.3 From 94abfaba7c5b7655eda3d6547144adfa26c90a5f Mon Sep 17 00:00:00 2001 From: alecdwm Date: Fri, 6 Jan 2017 07:21:59 +0100 Subject: removed comma --- lib/letter-avatars.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/letter-avatars.js b/lib/letter-avatars.js index 767a2efd..3afa03fe 100644 --- a/lib/letter-avatars.js +++ b/lib/letter-avatars.js @@ -7,7 +7,7 @@ var randomcolor = require('randomcolor'); module.exports = function(name) { var color = randomcolor({ seed: name, - luminosity: 'dark', + luminosity: 'dark' }); var letter = name.substring(0, 1).toUpperCase(); -- cgit v1.2.3