├── .babelrc ├── server.js ├── .editorconfig ├── .gitignore ├── package.json ├── .eslintrc ├── ldapjs.js ├── ldap.js ├── groups.js ├── locations.js ├── README.md ├── people.js └── LICENSE /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ "es2015"], 3 | "plugins": [ 4 | "transform-object-rest-spread" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2014-2016 Hewlett Packard Enterprise Development Company, L.P. 2 | 3 | require('babel-register'); 4 | require('./ldap'); 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | max_line_length = 80 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | max_line_length = 0 14 | trim_trailing_whitespace = false 15 | 16 | [COMMIT_EDITMSG] 17 | max_line_length = 0 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | 29 | .idea/** 30 | 31 | *tmp* 32 | **sublime-project** 33 | **sublime-workspace** 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grommet-ldap-server", 3 | "description": "A node-only ldap server for Grommet", 4 | "version": "0.1.0", 5 | "authors": [ 6 | "Alan Souza", 7 | "Bryan Jacquot", 8 | "Chris Carlozzi", 9 | "Eric Soderberg" 10 | ], 11 | "homepage": "http://grommet.io", 12 | "bugs": "https://github.com/grommet/grommet-ldap-server/issues", 13 | "license": "Apache-2.0", 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/grommet/grommet-ldap-server.git" 17 | }, 18 | "dependencies": { 19 | "babel-plugin-transform-object-rest-spread": "^6.8.0", 20 | "babel-preset-es2015": "^6.6.0", 21 | "babel-register": "^6.9.0", 22 | "ldapjs": "^1.0.0" 23 | }, 24 | "devDependencies": { 25 | "babel-eslint": "^6.0.4" 26 | }, 27 | "scripts": { 28 | "start": "node server.js" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | --- 2 | parser: babel-eslint 3 | 4 | env: 5 | browser: true 6 | node: true 7 | 8 | globals: 9 | __DEV__: true 10 | __THEME__: true 11 | __DEV_MODE__: true 12 | __SOCKET_HOST__: true 13 | IntlPolyfill: true 14 | Modernizr: true 15 | describe: true 16 | it: true 17 | beforeEach: true 18 | afterEach: true 19 | before: true 20 | after: true 21 | 22 | rules: 23 | # ERRORS 24 | space-before-blocks: 2 25 | indent: [2, 2, { SwitchCase: 1 }] 26 | brace-style: 2 27 | # keyword-spacing: 2 28 | comma-dangle: 2 29 | no-unused-expressions: 2 30 | block-scoped-var: 2 31 | eol-last: 2 32 | dot-notation: 2 33 | consistent-return: 2 34 | no-unused-vars: [2, args: none] 35 | semi: [2, "always"] 36 | 37 | # DISABLED 38 | max-len: 0 39 | #change soon back to max-len: [1, 80] 40 | no-underscore-dangle: 0 41 | new-cap: 0 42 | no-use-before-define: 0 43 | key-spacing: 0 44 | eqeqeq: 0 45 | strict: 0 46 | space-unary-ops: 0 47 | yoda: 0 48 | no-loop-func: 0 49 | no-trailing-spaces: 0 50 | no-multi-spaces: 0 51 | no-shadow: 0 52 | no-alert: 0 53 | no-process-exit: 0 54 | no-extend-native: 0 55 | # block-scoped-var: 0 56 | quotes: 0 57 | -------------------------------------------------------------------------------- /ldapjs.js: -------------------------------------------------------------------------------- 1 | import ldap from 'ldapjs'; 2 | import helpers from 'ldap-filter/lib/helpers'; 3 | 4 | function escapeRegExp(str) { 5 | /* JSSTYLED */ 6 | return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); 7 | } 8 | 9 | ldap.SubstringFilter.prototype.matches = function (target, strictAttrCase) { 10 | var tv = helpers.getAttrValue(target, this.attribute, strictAttrCase); 11 | if (tv !== undefined && tv !== null) { 12 | var re = ''; 13 | 14 | if (this.initial) 15 | re += '^' + escapeRegExp(this.initial) + '.*'; 16 | this.any.forEach(function (s) { 17 | re += escapeRegExp(s) + '.*'; 18 | }); 19 | if (this.final) 20 | re += escapeRegExp(this.final) + '$'; 21 | 22 | var matcher = new RegExp(re, 'i'); 23 | return helpers.testValues(function (v) { 24 | return matcher.test(v); 25 | }, tv); 26 | } 27 | 28 | return false; 29 | }; 30 | 31 | ldap.EqualityFilter.prototype.matches = function (target, strictAttrCase) { 32 | var tv = helpers.getAttrValue(target, this.attribute, strictAttrCase); 33 | var value = this.value.toLowerCase(); 34 | 35 | return helpers.testValues(function (v) { 36 | return value === v.toLowerCase(); 37 | }, tv); 38 | }; 39 | 40 | export default ldap; 41 | -------------------------------------------------------------------------------- /ldap.js: -------------------------------------------------------------------------------- 1 | 2 | import ldap from './ldapjs'; 3 | import people from './people'; 4 | import locations from './locations'; 5 | import groups from './groups'; 6 | 7 | const server = ldap.createServer(); 8 | 9 | const PORT = process.env.PORT || 1389; 10 | 11 | function handleOu (req, res, next, search, id, entities, ouName) { 12 | if (search.indexOf(id) > -1) { 13 | Object.keys(entities).some((entity) => { 14 | if (`${id}=${entities[entity].attributes[id]}, ou=${ouName}, o=grommet.io` === search 15 | && req.filter.matches(entities[entity].attributes)) { 16 | res.send(entities[entity]); 17 | return true; 18 | } 19 | }); 20 | } else { 21 | Object.keys(entities).forEach((entity) => { 22 | if (req.filter.matches(entities[entity].attributes)) { 23 | res.send(entities[entity]); 24 | } 25 | }); 26 | } 27 | 28 | res.end(); 29 | return next(); 30 | } 31 | 32 | server.search('o=grommet.io', (req, res, next) => { 33 | const search = req.dn.toString(); 34 | if (search.indexOf('people') > -1) { 35 | handleOu(req, res, next, search, 'uid', people, 'people'); 36 | } else if (search.indexOf('locations') > -1) { 37 | handleOu(req, res, next, search, 'hprealestateid', locations, 'locations'); 38 | } else if (search.indexOf('groups') > -1) { 39 | handleOu(req, res, next, search, 'cn', groups, 'groups'); 40 | } 41 | }); 42 | 43 | server.listen(PORT, function() { 44 | console.log('Grommet Search LDAP server up at: %s', server.url); 45 | }); 46 | -------------------------------------------------------------------------------- /groups.js: -------------------------------------------------------------------------------- 1 | export default { 2 | "grommet-designers": { 3 | "dn": "cn=grommet-designers, ou=groups, o=grommet.io", 4 | "attributes": { 5 | "objectClass": [ 6 | "groupOfNames" 7 | ], 8 | "owner":[ 9 | "uid=chris.carlozzi@fake.grommet.io, ou=people, o=grommet.io", 10 | "uid=jacquot@fake.grommet.io, ou=people, o=grommet.io" 11 | ], 12 | "cn": "grommet-designers", 13 | "description": "Group for grommet designers", 14 | "member":[ 15 | "uid=tracy.barmore@fake.grommet.io, ou=people, o=grommet.io" 16 | ] 17 | } 18 | }, 19 | "grommet-developers": { 20 | "dn": "cn=grommet-developers, ou=groups, o=grommet.io", 21 | "attributes": { 22 | "objectClass": [ 23 | "groupOfNames" 24 | ], 25 | "owner":[ 26 | "uid=eric.soderberg@fake.grommet.io, ou=people, o=grommet.io", 27 | "uid=jacquot@fake.grommet.io, ou=people, o=grommet.io" 28 | ], 29 | "cn": "grommet-developers", 30 | "description": "Group for grommet developers", 31 | "member": [ 32 | "uid=asouza@fake.grommet.io, ou=people, o=grommet.io" 33 | ] 34 | } 35 | }, 36 | "grommet-yen": { 37 | "dn": "cn=grommet-yen, ou=groups, o=grommet.io", 38 | "attributes": { 39 | "objectClass": [ 40 | "groupOfNames" 41 | ], 42 | "owner": [ 43 | "uid=tracy.barmore@fake.grommet.io, ou=people, o=grommet.io" 44 | ], 45 | "cn": "grommet-yen", 46 | "description": "Group for young grommet members", 47 | "member": [ 48 | "uid=asouza@fake.grommet.io, ou=people, o=grommet.io" 49 | ], 50 | "email": "yen@grommet.io" 51 | } 52 | } 53 | }; 54 | -------------------------------------------------------------------------------- /locations.js: -------------------------------------------------------------------------------- 1 | export default { 2 | "PAL20": { 3 | "dn": "lid=PAL20, ou=locations, o=grommet.io", 4 | attributes: { 5 | "postalAddress": "3000 Hanover St. $ Palo Alto $ California $ United States $ 94304-1112", 6 | "lid": "PAL20", 7 | "objectClass": [ 8 | "locality" 9 | ], 10 | "postalCode": "94304-1112", 11 | "co": "United States", 12 | "street": "3000 Hanover St.", 13 | "st": "California", 14 | "latitude": "+37.3939", 15 | "longitude": "-122.1700", 16 | "l": "Palo Alto", 17 | "c": "US", 18 | "timeZone": "-0700", 19 | "cn": "PAL20", 20 | "telephoneNumber": "+1 (555) 555-5555", 21 | "category": "Headquarters" 22 | } 23 | }, 24 | "FTC06": { 25 | "dn": "lid=FTC06, ou=locations, o=grommet.io", 26 | "attributes": { 27 | "lid": "FTC06", 28 | "objectClass": [ 29 | "locality" 30 | ], 31 | "st": "Colorado", 32 | "co": "United States", 33 | "street": "3404 E Harmony Rd.", 34 | "latitude": "+40.5233", 35 | "longitude": "-105.0370", 36 | "postalCode": "80528-9544", 37 | "postalAddress": "3404 E Harmony Rd. $ Ft. Collins $ Colorado $ United States $ 80528-9544", 38 | "l": "Ft. Collins", 39 | "c": "US", 40 | "timeZone": "-0600", 41 | "cn": "FTC06", 42 | "telephoneNumber": "+1 (555) 555-5555", 43 | "category": "Main Branch" 44 | } 45 | }, 46 | "LUNDE01": { 47 | "dn": "lid=LUNDE01, ou=locations, o=grommet.io", 48 | attributes: { 49 | "postalAddress": "Nöbbelövs torg 2 $ Lund $ Scania $ Sweden $ 226 52", 50 | "lid": "LUNDE01", 51 | "objectClass": [ 52 | "locality" 53 | ], 54 | "postalCode": "226 52", 55 | "co": "Sweden", 56 | "street": "Nöbbelövs torg 2", 57 | "st": "Scania", 58 | "latitude": "+55.728502", 59 | "longitude": "+13.174933", 60 | "l": "Lund", 61 | "c": "SE", 62 | "timeZone": "+0200", 63 | "cn": "LUNDE01", 64 | "telephoneNumber": "+1 (555) 555-5555", 65 | "category": "Sweden Branch" 66 | } 67 | }, 68 | "VOCE01": { 69 | "dn": "lid=VOCE01, ou=locations, o=grommet.io", 70 | attributes: { 71 | "postalAddress": "298 South Sunnyvale Road $ Sunnyvale $ California $ US $ 94086", 72 | "lid": "VOCE01", 73 | "objectClass": [ 74 | "locality" 75 | ], 76 | "postalCode": "94086", 77 | "co": "United States", 78 | street: '298 South Sunnyvale Road.', 79 | "st": "California", 80 | "latitude": "+37.374239", 81 | "longitude": "-122.029505", 82 | "l": "Sunnyvale", 83 | "c": "US", 84 | "timeZone": "-0700", 85 | "cn": "VOCE01", 86 | "telephoneNumber": "+1 (555) 555-5555", 87 | "category": "Marketing Branch" 88 | } 89 | } 90 | }; 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Grommet search ldap server 2 | 3 | A simple ldap server with search capabilities on people, locations, and groups. 4 | 5 | Created to be used in conjunction with [Grommet people finder](https://github.com/grommet/grommet-people-finder). 6 | 7 | This LDAP server provides 3 Organizational Unit (ou): people, locations, and groups. 8 | 9 | This LDAP server runs on top of node and was implemented on top of [ldapjs](). 10 | 11 | # People 12 | 13 | Represents Grommet contributors all over the globe. 14 | 15 | ### Schema 16 | 17 | | **Attribute** | **Description** | 18 | |--------|--------| 19 | |uid | required. person full name | 20 | |givenName| required. person first name | 21 | |sn| required. person last name | 22 | | manager | required. dn of the person's manager (e.g. `uid=jacquot@fake.grommet.io, ou=people, o=grommet.io`) | 23 | | title | optional. work title of the person | 24 | |telephoneNumber| optional. person's phone number | 25 | |objectclass| set to "organizationalPerson" | 26 | |employeeNumber| optional. person's employee identification | 27 | | assistant: assistant | optional. dn of the person's assistant (e.g. `uid=asouza@fake.grommet.io, ou=people, o=grommet.io`) | 28 | |pictureThumbnailURI| optional. person thumbnail image | 29 | |pictureURI| optional. person regular size image (250x250) | 30 | |workName| optional. name of the work location. Defaults to "Grommet HQ" | 31 | |workLocation| optional. dn of the work location. Defaults to `lid=PAL20, ou=locations, o=grommet.io` | 32 | |workCity| optional. work location city. Defaults to "Palo Alto" | 33 | |workStreet| optional. work location street. Defaults to "3000 Hanover St." | 34 | |workPostalCode| optional. work location postal code. Defaults to "94304-1112" | 35 | |workState| optional. work location state. Defaults to "California" | 36 | |workCountry| optional. work location country. Defaults to "United States" | 37 | 38 | ### Example Query 39 | 40 | 1. List all grommet people (returns cn and title only) 41 | 42 | ``` 43 | ldapsearch -x -h ldap.grommet.io -b "ou=people, o=grommet.io" cn title 44 | ``` 45 | 46 | # Locations 47 | 48 | Work locations for offices that have people contributing to Grommet. 49 | 50 | ### Schema 51 | 52 | | **Attribute** | **Description** | 53 | |--------|--------| 54 | |lid | required. unique code for the location (e.g. "PAL20") | 55 | |cn | required. unique code for the location (e.g. "PAL20") | 56 | |postalCode| required. location postal code | 57 | |postalAddress| required. full postal address separated by `$` (e.g. "3000 Hanover St. $ Palo Alto $ California $ United States $ 94304-1112") | 58 | | street | required. location street | 59 | | st | required. location state | 60 | | l | required. location city | 61 | | co | required. location country | 62 | | c | required. location country short (e.g. "US") | 63 | | latitude | required. location latitude | 64 | | longitude | required. location longitude | 65 | | timeZone | required. location timezone difference from UTC (e.g. "+0200") | 66 | | telephoneNumber | optional. telephone number of the location | 67 | | category | optional. category for this location (e.g. "Headquarters") 68 | 69 | ### Example Query 70 | 71 | 1. List all grommet locations (returns lid and cn only) 72 | 73 | ``` 74 | ldapsearch -x -h ldap.grommet.io -b "ou=locations, o=grommet.io" lid cn 75 | ``` 76 | 77 | # Groups 78 | 79 | Groups for the Grommet.io organization (e.g. grommet-developers, grommet-designers, ...) 80 | 81 | ### Schema 82 | 83 | | **Attribute** | **Description** | 84 | |--------|--------| 85 | |cn| required. group name. 86 | |description| required. useful description of the group's purpose. 87 | |owner | required. DN list of the group owners (e.g. ["`uid=tracy.barmore@fake.grommet.io, ou=people, o=grommet.io`"]) | 88 | |owner | required. DN list of the group members (e.g. ["`uid=asouza@fake.grommet.io, ou=people, o=grommet.io`"]) | 89 | 90 | ### Example Query 91 | 92 | 1. List all grommet groups 93 | 94 | ``` 95 | ldapsearch -x -h ldap.grommet.io -b "ou=groups, o=grommet.io" 96 | ``` 97 | -------------------------------------------------------------------------------- /people.js: -------------------------------------------------------------------------------- 1 | function createLdapUser (username, name, avatar, 2 | managerUid, title, location = {}, employeeNumber, assistant) { 3 | const names = name.split(' '); 4 | return { 5 | dn: `uid=${username}, ou=people, o=grommet.io`, 6 | attributes: { 7 | cn: name, 8 | uid: username, 9 | givenName: names[0], 10 | sn: names[names.length - 1], 11 | pictureThumbnailURI: `${avatar}?s=80`, 12 | pictureURI: `${avatar}?s=250`, 13 | workName: location.companyName || 'Grommet HQ', 14 | workLocation: `lid=${location.buildName || "PAL20"}, ou=locations, o=grommet.io`, 15 | workCity: location.city || "Palo Alto", 16 | workStreet: location.street || "3000 Hanover St.", 17 | workPostalCode: location.postalCode || "94304-1112", 18 | workState: location.state || "California", 19 | workCountry: location.country || "United States", 20 | manager: managerUid, 21 | title: title, 22 | telephoneNumber: '+1 (555) 555-5555', 23 | objectclass: 'organizationalPerson', 24 | employeeNumber: employeeNumber, 25 | assistant: assistant 26 | } 27 | }; 28 | } 29 | 30 | export default { 31 | "alansouzati": createLdapUser( 32 | 'asouza@fake.grommet.io', 33 | 'Alan Souza', 34 | 'https://s.gravatar.com/avatar/eea1072044af57fa127c0f34e2410f6b', 35 | 'uid=eric.soderberg@fake.grommet.io, ou=people, o=grommet.io', 36 | 'UI/UX Developer', 37 | undefined, 38 | '276456' 39 | ), 40 | "oscarlinde": createLdapUser( 41 | 'oscar.linde@fake.grommet.io', 42 | 'Oscar Linde', 43 | 'https://s.gravatar.com/avatar/aed13290d9c2da5969da278488b46a47', 44 | 'uid=eric.soderberg@fake.grommet.io, ou=people, o=grommet.io', 45 | 'Software Engineer', 46 | { 47 | companyName: 'Tedsys', 48 | buildName: 'LUNDE01', 49 | city: 'Lund', 50 | state: 'Scania', 51 | street: 'Nöbbelövs torg 2', 52 | postalCode: '226 52', 53 | country: 'Sweden' 54 | }, 55 | '276456' 56 | ), 57 | "tracybarmore": createLdapUser( 58 | 'tracy.barmore@fake.grommet.io', 59 | 'Tracy Barmore', 60 | 'https://s.gravatar.com/avatar/4ec9c3a91da89f278e4482811caad7f3', 61 | 'uid=chris.carlozzi@fake.grommet.io, ou=people, o=grommet.io', 62 | 'Experience Designer', 63 | undefined, 64 | '276444' 65 | ), 66 | "ericsoderberg": createLdapUser( 67 | 'eric.soderberg@fake.grommet.io', 68 | 'Eric Soderberg', 69 | 'https://s.gravatar.com/avatar/99020cae7ff399a4fbea19c0634f77c3', 70 | 'uid=jacquot@fake.grommet.io, ou=people, o=grommet.io', 71 | 'Vice President, Engineering Office', 72 | undefined, 73 | '287364' 74 | ), 75 | "chriscarlozzi": createLdapUser( 76 | 'chris.carlozzi@fake.grommet.io', 77 | 'Chris Carlozzi', 78 | 'https://s.gravatar.com/avatar/e3e87c5215378c50fb7e8a4611c6a94d', 79 | 'uid=jacquot@fake.grommet.io, ou=people, o=grommet.io', 80 | 'Vice President, Design Office', 81 | undefined, 82 | '342322' 83 | ), 84 | "bryanjacquot": createLdapUser( 85 | 'jacquot@fake.grommet.io', 86 | 'Bryan Jacquot', 87 | 'https://s.gravatar.com/avatar/10d15019166606cfed23846a7f902660', 88 | '', 89 | 'CEO', 90 | { 91 | buildName: 'FTC06', 92 | city: 'Fort Collins', 93 | state: 'Colorado', 94 | street: '3404 E Harmony Rd.', 95 | postalCode: '80528-9544' 96 | }, 97 | '124243', 98 | 'uid=asouza@fake.grommet.io, ou=people, o=grommet.io' 99 | ), 100 | "randyksar": createLdapUser( 101 | 'randyksar@fake.grommet.io', 102 | 'Randy Ksar', 103 | 'https://s.gravatar.com/avatar/a2ee7bd9ea83d558f913e9371a1f0395', 104 | 'uid=jacquot@fake.grommet.io, ou=people, o=grommet.io', 105 | 'Vice President, Marketing Office', 106 | { 107 | companyName: 'Voce Communications', 108 | buildName: 'VOCE01', 109 | city: 'Sunnyvale', 110 | state: 'California', 111 | street: '298 South Sunnyvale Road Suite 100.', 112 | postalCode: '94086' 113 | }, 114 | '000002', 115 | 'uid=tracy.barmore@fake.grommet.io, ou=people, o=grommet.io' 116 | ) 117 | }; 118 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------