Skip to content
This repository
Browse code

added http basic authentication options

  • Loading branch information...
commit f55b6a9ea814b7f1532bbd2a5b4893d239bbaf4f 1 parent d38328d
Robert Clark lojack authored

Showing 3 changed files with 33 additions and 1 deletion. Show diff stats Hide diff stats

  1. +4 0 README.md
  2. +20 0 src/git.coffee
  3. +9 1 src/server.coffee
4 README.md
Source Rendered
@@ -26,6 +26,10 @@ Concrete is a minimalistic Continuous Integration server.
26 26 ## Setting the branch
27 27 git config --add concrete.branch deploy
28 28
  29 +## Adding HTTP Basic authentication
  30 + git config --add concrete.user username
  31 + git config --add concrete.pass password
  32 +
29 33 ## Post build
30 34 After building Concrete will run `.git/hooks/build-failed` or `.git/hooks/build-worked` depending on test outcome. Like all git hooks, they're just shell scripts so put whatever you want in there.
31 35
20 src/git.coffee
@@ -10,9 +10,13 @@ readyCallback = null
10 10 git = module.exports =
11 11 runner: ''
12 12 branch: ''
  13 + user: ''
  14 + pass: ''
13 15 config:
14 16 runner: 'concrete.runner'
15 17 branch: 'concrete.branch'
  18 + user: 'concrete.user'
  19 + pass: 'concrete.pass'
16 20
17 21 # init at target directory
18 22 init: (target, callback) ->
@@ -37,6 +41,8 @@ git = module.exports =
37 41 if exists is no
38 42 console.log "'#{target}' is not a valid Git repo".red
39 43 process.exit 1
  44 + getUser()
  45 + getPass()
40 46 getBranch()
41 47 getRunner()
42 48
@@ -58,6 +64,20 @@ git = module.exports =
58 64 console.log out.grey
59 65 next()
60 66
  67 +getUser = ->
  68 + exec 'git config --get ' + git.config.user, (error, stdout, stderr)=>
  69 + if error?
  70 + git.user = ''
  71 + else
  72 + git.user = stdout.toString().replace /[\s\r\n]+$/, ''
  73 +
  74 +getPass = ->
  75 + exec 'git config --get ' + git.config.pass, (error, stdout, stderr)=>
  76 + if error?
  77 + git.pass = ''
  78 + else
  79 + git.pass = stdout.toString().replace /[\s\r\n]+$/, ''
  80 +
61 81 # get the current working branch
62 82 # fallback to master if git.config.branch isn't set
63 83 getBranch = ->
10 src/server.coffee
@@ -4,7 +4,15 @@ fs = require 'fs'
4 4 path = require 'path'
5 5 runner = require './runner'
6 6 jobs = require './jobs'
7   -app = module.exports = express.createServer()
  7 +git = require './git'
  8 +
  9 +authorize = (user, pass) ->
  10 + user == git.user and pass == git.pass
  11 +
  12 +if git.user and git.pass
  13 + app = module.exports = express.createServer(express.basicAuth(authorize))
  14 +else
  15 + app = module.exports = express.createServer()
8 16
9 17 app.configure ->
10 18 app.set 'views', __dirname + '/views'

0 comments on commit f55b6a9

Please sign in to comment.
Something went wrong with that request. Please try again.