├── .dockerignore ├── .bowerrc ├── .yo-rc.json ├── .editorconfig ├── routes ├── index.js └── gitlab.js ├── Dockerfile ├── bin └── www ├── config.sample.json ├── README.md ├── gulpfile.js ├── package.json ├── config.schema.json ├── app.js ├── gitlabLdapGroupSync.js └── LICENSE /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | *.md 3 | node_modules 4 | config.json 5 | -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "public/components", 3 | "json": "bower.json" 4 | } 5 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-express": { 3 | "promptValues": { 4 | "type": "Basic", 5 | "viewEngine": "Jade", 6 | "cssPreprocessor": "None", 7 | "buildTool": "Gulp" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /routes/index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET home page. */ 5 | 6 | router.get('/', function (req, res) { 7 | res.send('Gitlab LDAP User Sync'); 8 | }); 9 | 10 | module.exports = router; 11 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:7.8.0 2 | 3 | MAINTAINER Stefan Jauker 4 | 5 | ENV NODE_ENV production 6 | 7 | WORKDIR /opt/gitlab_ldap_group_sync 8 | COPY . /opt/gitlab_ldap_group_sync 9 | 10 | RUN npm prune && npm install 11 | 12 | CMD ["node", "./bin/www"] 13 | 14 | EXPOSE 8080 15 | -------------------------------------------------------------------------------- /bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var app = require('../app'); 3 | 4 | exitOnSignal('SIGINT'); 5 | exitOnSignal('SIGTERM'); 6 | process.stdin.resume(); 7 | 8 | function exitOnSignal(signal) { 9 | process.on(signal, function() { 10 | console.log('\ncaught ' + signal + ', exiting'); 11 | process.exit(1); 12 | }); 13 | } 14 | 15 | var server = app.listen(app.get('port'), function () { 16 | console.log('Express server listening on port ' + server.address().port); 17 | }); 18 | -------------------------------------------------------------------------------- /config.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": 8080, 3 | "syncInterval": "10m", 4 | "gitlab": { 5 | "api": "https://repo.mwaysolutions.com/api/v4", 6 | "privateToken": "My_S3Cr3T_T0k3n" 7 | }, 8 | "ldap": { 9 | "url": "ldaps://ldap.example.com", 10 | "baseDN": "OU=AADDC Users,DC=example,DC=com", 11 | "username": "ldap@example.com", 12 | "password": "mY_S3Cr3T_P455W0Rd" 13 | }, 14 | "groupPrefix": "gitlab-", 15 | "ownersGroups": "admins", 16 | "ownerAccessLevel": 50, 17 | "defaultAccessLevel": 30 18 | 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gitlab-ldap-group-sync 2 | 3 | It provides a way to sync ldap group members with gitlab groups 4 | 5 | ## Prerequisites 6 | 7 | Node JS 8 | 9 | ## Installation 10 | 11 | Clone the repository and create a `config.json` file. 12 | 13 | ```bash 14 | git clone https://github.com/gitlab-tools/gitlab-ldap-group-sync.git 15 | cd gitlab-ldap-group-sync 16 | cp config.sample.json config.json 17 | npm install 18 | ``` 19 | 20 | ## Configuration 21 | 22 | See: [config.sample.json ](config.sample.json ) 23 | 24 | ## Usage 25 | 26 | Just start the node application. 27 | 28 | ```bash 29 | npm start 30 | ``` 31 | -------------------------------------------------------------------------------- /routes/gitlab.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | /* GET users listing. */ 5 | router.post('/webhook', function (req, res) { 6 | console.log(req.body); 7 | if (req.body.event_name === 'user_create') { 8 | gitlabLdapGroupSync.sync(); 9 | res.status(200).send('OK'); 10 | } else if(req.body.event_name) { 11 | res.status(200).send('OK'); 12 | } else { 13 | res.status(422).send('This is not a valid gitlab system hook'); 14 | } 15 | }); 16 | 17 | module.exports = router; 18 | 19 | var gitlabLdapGroupSync = undefined; 20 | module.exports.init = function (glgs) { 21 | gitlabLdapGroupSync = glgs; 22 | } 23 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | nodemon = require('gulp-nodemon'), 3 | plumber = require('gulp-plumber'), 4 | livereload = require('gulp-livereload'); 5 | 6 | 7 | gulp.task('develop', function () { 8 | livereload.listen(); 9 | nodemon({ 10 | script: 'bin/www', 11 | ext: 'js jade coffee', 12 | stdout: false 13 | }).on('readable', function () { 14 | this.stdout.on('data', function (chunk) { 15 | if (/^Express server listening on port/.test(chunk)) { 16 | livereload.changed(__dirname); 17 | } 18 | }); 19 | this.stdout.pipe(process.stdout); 20 | this.stderr.pipe(process.stderr); 21 | }); 22 | }); 23 | 24 | gulp.task('default', [ 25 | 'develop' 26 | ]); 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gitlab-ldap-group-sync", 3 | "version": "0.0.1", 4 | "private": true, 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "node ./bin/www", 8 | "test": "mocha --recursive test", 9 | "test:coverage": "nyc npm test", 10 | "test:unit": "mocha --recursive test/middleware test/models test/routes", 11 | "test:integration": "mocha --recursive test/integration", 12 | "docker": "docker build -t gitlab-tools/gitlab-ldap-group-sync ." 13 | }, 14 | "dependencies": { 15 | "activedirectory": "^0.7.2", 16 | "body-parser": "^1.17.1", 17 | "co": "^4.6.0", 18 | "express": "^4.13.3", 19 | "getenv": "^0.7.0", 20 | "jsonschema": "^1.1.1", 21 | "morgan": "^1.6.1", 22 | "node-gitlab": "^1.6.0", 23 | "schedule": "^0.1.0" 24 | }, 25 | "devDependencies": { 26 | "chai": "^3.5.0", 27 | "debug": "^2.2.0", 28 | "gulp": "^3.9.0", 29 | "gulp-nodemon": "^2.0.2", 30 | "gulp-livereload": "^3.8.0", 31 | "gulp-plumber": "^1.0.0", 32 | "mocha": "^3.0.2", 33 | "nyc": "^10.0.0", 34 | "supertest": "^2.0.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /config.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "port": { 5 | "type": "integer", 6 | "minimum": 1, 7 | "maximum": 65535, 8 | "default": 8080 9 | }, 10 | "syncInterval": { 11 | "type": "string", 12 | "default": "10m" 13 | }, 14 | "gitlab": { 15 | "id": "/gitlab", 16 | "type": "object", 17 | "properties": { 18 | "api": { 19 | "type": "string" 20 | }, 21 | "privateToken": { 22 | "type": "string" 23 | }, 24 | "requestTimeout": { 25 | "type": "integer", 26 | "default": 5000 27 | } 28 | }, 29 | "required": [ 30 | "api", 31 | "privateToken" 32 | ] 33 | }, 34 | "ldap": { 35 | "type": "object", 36 | "properties": { 37 | "url": { 38 | "type": "string" 39 | }, 40 | "baseDN": { 41 | "type": "string" 42 | }, 43 | "username": { 44 | "type": "string" 45 | }, 46 | "password": { 47 | "type": "string" 48 | }, 49 | "groupPrefix": { 50 | "type": "string", 51 | "default": "gitlab-" 52 | } 53 | }, 54 | "required": [ 55 | "url", 56 | "baseDN", 57 | "username", 58 | "password" 59 | ] 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | // Read config 2 | var configSchema = require('./config.schema'); 3 | var getenv = require('getenv'); 4 | 5 | var config = {}; 6 | try { 7 | config = require('./config'); 8 | } catch (err) { 9 | console.log('no config file found'); 10 | } 11 | 12 | readEnvironmentVariables(configSchema, config); 13 | 14 | var validate = require('jsonschema').validate; 15 | var result = validate(config, configSchema); 16 | 17 | if (result.errors.length > 0) { 18 | console.log('Config file invalid', result); 19 | process.exit(1); 20 | } 21 | 22 | var gitlabLdapGroupSync = new require('./gitlabLdapGroupSync')(config); 23 | gitlabLdapGroupSync.startScheduler(config.syncInterval || '1h'); 24 | gitlabLdapGroupSync.sync(); 25 | 26 | /// EXPRESS 27 | var express = require('express'); 28 | var bodyParser = require('body-parser') 29 | var path = require('path'); 30 | var logger = require('morgan'); 31 | 32 | var routes = require('./routes/index'); 33 | var gitlabRoute = require('./routes/gitlab'); 34 | gitlabRoute.init(gitlabLdapGroupSync); 35 | 36 | var app = express(); 37 | app.set('port', config.port || process.env.PORT || 8080); 38 | 39 | app.use(logger('dev')); 40 | 41 | app.use(bodyParser.json()); 42 | 43 | app.use('/', routes); 44 | app.use('/api/gitlab', gitlabRoute); 45 | 46 | /// catch 404 and forward to error handler 47 | app.use(function (req, res, next) { 48 | var err = new Error('Not Found'); 49 | err.status = 404; 50 | next(err); 51 | }); 52 | 53 | 54 | module.exports = app; 55 | 56 | 57 | // Helper functions 58 | function readEnvironmentVariables(schema, conf, prefix = '') { 59 | getenv.enableErrors(); 60 | for (property in schema.properties) { 61 | var envKey = (prefix + property).toUpperCase().replace('.', '_'); 62 | try { 63 | if (schema.properties[property].type === 'object') { 64 | var subConf = conf[property] || {}; 65 | conf[property] = subConf; 66 | readEnvironmentVariables(schema.properties[property], subConf, prefix + property + '.'); 67 | } else if (schema.properties[property].type === 'string') { 68 | conf[property] = getenv(envKey); 69 | } else if (schema.properties[property].type === 'integer') { 70 | conf[property] = getenv.int(envKey); 71 | } else { 72 | console.log('unsupported type', schema.properties[property].type); 73 | } 74 | } catch (e) { } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /gitlabLdapGroupSync.js: -------------------------------------------------------------------------------- 1 | var co = require('co'); 2 | var every = require('schedule').every; 3 | var ActiveDirectory = require('activedirectory'); 4 | var NodeGitlab = require('node-gitlab'); 5 | 6 | var ACCESS_LEVEL_OWNER = 50; 7 | var ACCESS_LEVEL_NORMAL = 30; 8 | 9 | module.exports = GitlabLdapGroupSync; 10 | 11 | var isRunning = false; 12 | var gitlab = undefined; 13 | var ldap = undefined; 14 | 15 | function GitlabLdapGroupSync(config) { 16 | if (!(this instanceof GitlabLdapGroupSync)) 17 | return new GitlabLdapGroupSync(config) 18 | 19 | gitlab = NodeGitlab.createThunk(config.gitlab); 20 | ldap = new ActiveDirectory(config.ldap); 21 | this.config = config 22 | } 23 | 24 | 25 | GitlabLdapGroupSync.prototype.sync = function () { 26 | 27 | if (isRunning) { 28 | console.log('ignore trigger, a sync is already running'); 29 | return; 30 | } 31 | isRunning = true; 32 | 33 | co(function* () { 34 | // find all users with a ldap identiy 35 | var gitlabUsers = []; 36 | var pagedUsers = []; 37 | var i=0; 38 | do { 39 | i++; 40 | pagedUsers = yield gitlab.users.list({ per_page: 100, page: i }); 41 | gitlabUsers.push.apply(gitlabUsers, pagedUsers); 42 | 43 | } 44 | while(pagedUsers.length == 100); 45 | 46 | var gitlabUserMap = {}; 47 | var gitlabLocalUserIds = []; 48 | for (var user of gitlabUsers) { 49 | if (user.identities.length > 0) { 50 | gitlabUserMap[user.username.toLowerCase()] = user.id; 51 | } else { 52 | gitlabLocalUserIds.push(user.id); 53 | } 54 | } 55 | console.log(gitlabUserMap); 56 | 57 | //set the gitlab group members based on ldap group 58 | var gitlabGroups = []; 59 | var pagedGroups = []; 60 | var i=0; 61 | do { 62 | i++; 63 | pagedGroups = yield gitlab.groups.list({ per_page: 100, page: i }); 64 | gitlabGroups.push.apply(gitlabGroups, pagedGroups); 65 | 66 | } 67 | while(pagedGroups.length == 100); 68 | 69 | var membersOwner = yield this.resolveLdapGroupMembers(ldap, this.config['ownersGroup'] || 'admins', gitlabUserMap); 70 | var membersDefault = yield this.resolveLdapGroupMembers(ldap, 'default', gitlabUserMap); 71 | 72 | for (var gitlabGroup of gitlabGroups) { 73 | console.log('-------------------------'); 74 | console.log('group:', gitlabGroup.name); 75 | var gitlabGroupMembers = []; 76 | var pagedGroupMembers = []; 77 | var i=0; 78 | do { 79 | i++; 80 | pagedGroupMembers = yield gitlab.groupMembers.list({ id: gitlabGroup.id, per_page: 100, page: i }); 81 | gitlabGroupMembers.push.apply(gitlabGroupMembers, pagedGroupMembers); 82 | } 83 | while(pagedGroupMembers.length == 100); 84 | 85 | var currentMemberIds = []; 86 | for (var member of gitlabGroupMembers) { 87 | if (gitlabLocalUserIds.indexOf(member.id) > -1) { 88 | continue; //ignore local users 89 | } 90 | 91 | var access_level = this.accessLevel(member.id, membersOwner); 92 | if (member.access_level !== access_level) { 93 | console.log('update group member permission', { id: gitlabGroup.id, user_id: member.id, access_level: access_level }); 94 | gitlab.groupMembers.update({ id: gitlabGroup.id, user_id: member.id, access_level: access_level }); 95 | } 96 | 97 | currentMemberIds.push(member.id); 98 | } 99 | 100 | var members = yield this.resolveLdapGroupMembers(ldap, gitlabGroup.name, gitlabUserMap); 101 | members = (members && members.length) ? members : membersDefault; 102 | 103 | //remove unlisted users 104 | var toDeleteIds = currentMemberIds.filter(x => members.indexOf(x) == -1); 105 | for (var id of toDeleteIds) { 106 | console.log('delete group member', { id: gitlabGroup.id, user_id: id }); 107 | gitlab.groupMembers.remove({ id: gitlabGroup.id, user_id: id }); 108 | } 109 | 110 | //add new users 111 | var toAddIds = members.filter(x => currentMemberIds.indexOf(x) == -1); 112 | for (var id of toAddIds) { 113 | var access_level = this.accessLevel(id, membersOwner); 114 | console.log('add group member', { id: gitlabGroup.id, user_id: id, access_level: access_level }); 115 | gitlab.groupMembers.create({ id: gitlabGroup.id, user_id: id, access_level: access_level }); 116 | } 117 | } 118 | 119 | }.bind(this)).then(function (value) { 120 | console.log('sync done'); 121 | isRunning = false; 122 | }, function (err) { 123 | console.error(err.stack); 124 | isRunning = false; 125 | }); 126 | } 127 | 128 | var ins = undefined; 129 | 130 | GitlabLdapGroupSync.prototype.accessLevel = function (id, membersOwner) { 131 | var owner = membersOwner.indexOf(id) > -1 132 | 133 | if(owner) { 134 | return this.config['ownerAccessLevel'] || ACCESS_LEVEL_OWNER; 135 | } 136 | return this.config['defaultAccessLevel'] || ACCESS_LEVEL_NORMAL; 137 | } 138 | 139 | GitlabLdapGroupSync.prototype.startScheduler = function (interval) { 140 | this.stopScheduler(); 141 | ins = every(interval).do(this.sync.bind(this)); 142 | } 143 | 144 | GitlabLdapGroupSync.prototype.stopScheduler = function () { 145 | if (ins) { 146 | ins.stop(); 147 | } 148 | ins = undefined; 149 | } 150 | 151 | GitlabLdapGroupSync.prototype.resolveLdapGroupMembers = function(ldap, group, gitlabUserMap) { 152 | var groupName = (this.config.groupPrefix || 'gitlab-') + group 153 | console.log('Loading users for group: ' + groupName) 154 | return new Promise(function (resolve, reject) { 155 | var ldapGroups = {}; 156 | ldap.getUsersForGroup(groupName, function (err, users) { 157 | if (err) { 158 | reject(err); 159 | return; 160 | } 161 | 162 | groupMembers = []; 163 | if(users) { 164 | for (var user of users) { 165 | if (gitlabUserMap[user.sAMAccountName.toLowerCase()]) { 166 | groupMembers.push(gitlabUserMap[user.sAMAccountName.toLowerCase()]); 167 | } 168 | } 169 | } 170 | console.log('Members=' + groupMembers); 171 | resolve(groupMembers); 172 | }); 173 | }); 174 | } 175 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------