jekyll-auth 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c299567fea0a69142dfdfe7bd5965efaf64a078
4
+ data.tar.gz: b0b41a85e08eaa51fda54a304806e0f844a1b6d8
5
+ SHA512:
6
+ metadata.gz: d884e76b631a3accbe9598cf0fc9e64e718c2b3f78fdfbfb8d835072eef123f2da9418339ea850043896e21a8d222c5f248d81ad5af91bcf223ebdad2205c264
7
+ data.tar.gz: 32524e318098c5401b3ab0af370adc5628c703205f63389491a2cfe01ad6f1444bfac0f128f7bd438275b1dbecc18cde8b745250ac36d5233c885d6e709c5c9b
@@ -0,0 +1,9 @@
1
+ # This file is auto-generated by Jekyll Auth
2
+ # Feel free to add additional Rake tasks so long as
3
+ # `rake assets:precompile` continues to generate the jekyll site
4
+
5
+ namespace :assets do
6
+ task :precompile do
7
+ sh "bundle exec jekyll build"
8
+ end
9
+ end
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env ruby
2
+ # Command-line interface for jekyll-auth
3
+
4
+ require 'rubygems'
5
+ require 'commander/import'
6
+ require 'rake'
7
+ require 'jekyll-auth'
8
+ require 'git'
9
+
10
+ def changed?
11
+ git = Git.init
12
+ git.diff('HEAD', 'config.ru').entries.length != 0 || git.diff('HEAD', 'Rakefile').entries.length != 0
13
+ end
14
+
15
+ program :version, JekyllAuth::VERSION
16
+ program :description, 'A simple way to use Github Oauth to serve a protected jekyll site to your GitHub organization'
17
+
18
+ command :new do |c|
19
+ c.syntax = 'jekyll-auth new'
20
+ c.description = "Initialize an existing Jekyll site as a Jekyll Auth site"
21
+ c.action do |args, options|
22
+ source = File.expand_path( "../", File.dirname(__FILE__) )
23
+ destination = Dir.pwd
24
+ say "Initaiting new Jekyll Auth site in #{destination}"
25
+
26
+ ["Rakefile", "config.ru"].each do |file|
27
+ if File.exist? "#{destination}/#{file}"
28
+ say "* #{destination}/#{file} already exists... skipping."
29
+ else
30
+ say "* creating #{destination}/#{file}"
31
+ FileUtils.cp "#{source}/#{file}", "#{destination}/#{file}"
32
+ end
33
+ end
34
+
35
+ command(:setup).run if agree "Would you like to set up Heroku now? (Y/n)"
36
+
37
+ if changed?
38
+ system "git status"
39
+ say "Looks like we've made some changes, you may want to do a git commit and git push sometime soon"
40
+ end
41
+
42
+ say "Setup complete. Run jekyll-auth to view the authenticated site."
43
+ end
44
+ end
45
+
46
+ command :setup do |c|
47
+ c.syntax = "jekyll-auth setup"
48
+ c.description = "Configure Heroku for use with your Jekyll Auth site"
49
+ c.action do |args, options|
50
+ git = Git.init
51
+ git.add "config.ru"
52
+ git.add "Rakefile"
53
+
54
+ if changed?
55
+ git.commit "[Jekyll Auth] Initial setup"
56
+ end
57
+
58
+ if git.remotes.any? { |remote| remote.name == "heroku" }
59
+ say "Looks like you've already got heroku set up... skipping."
60
+ else
61
+
62
+ say "If you already created an app, enter it's name"
63
+ say "otherwise, hit enter, and we'll get you set up with one."
64
+ app = ask "Heroku App name?"
65
+
66
+ if app == ""
67
+ say "Not a problem, let's create that heroku app for you."
68
+ sh "heroku create"
69
+ else
70
+ say "Great. Let's tell Heroku to use our existing app."
71
+ sh "heroku git:remote -a #{app}"
72
+ end
73
+ end
74
+
75
+ say "Awesome. Let's teach Heroku about our GitHub app."
76
+
77
+ client_id = ask "What's your GitHub Client ID? "
78
+ sh "heroku config:set GITHUB_CLIENT_ID=#{client_id}"
79
+
80
+ client_secret = ask "What's your GitHub Client Secret? "
81
+ sh "heroku config:set GITHUB_CLIENT_SECRET=#{client_secret}"
82
+
83
+ team_id = ask "What's your GitHub Team ID? (you can skip this in favor of an org if you prefer) "
84
+ if team_id
85
+ sh "heroku config:set GITHUB_TEAM_ID=#{team_id}"
86
+ else
87
+ org_id = ask "What's your GitHub Org ID? "
88
+ sh "heroku config:set GITHUB_ORG_ID=#{org_id}"
89
+ end
90
+
91
+ say "We're all set. Time to deploy our code to Heroku"
92
+ system "git push heroku master --force"
93
+
94
+ say "Let's check if it worked..."
95
+ sh "heroku open"
96
+
97
+ say "fin."
98
+ end
99
+ end
100
+
101
+ command :serve do |c|
102
+ c.syntax = "jekyll-auth serve"
103
+ c.description = "Run Jekyll Auth site locally"
104
+ c.action do |args, options|
105
+
106
+ # Ensure environmental variables are set
107
+ ["GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET"].each do |var|
108
+ next unless ENV[var].nil?
109
+ say "Whoops. Looks like you forgot to tell Jekyll Auth about your app"
110
+ say "Be sure to run export GITHUB_CLIENT_ID=[client id], export GITHUB_CLIENT_SECRET=[client secret], and export GITHUB_ORG_ID=[org id] (or GITHUB_TEAM_ID)"
111
+ say "See the readme for more information on where to find these"
112
+ exit(1)
113
+ end
114
+
115
+ # build site
116
+ command(:build).run
117
+
118
+ say "Spinning up the server with authentication. Use CTRL-C to stop."
119
+ say "To preview the site without authentication, use the `jekyll serve` command"
120
+ sh "bundle exec rackup -p 4000"
121
+
122
+ end
123
+ end
124
+
125
+ command :build do |c|
126
+ c.syntax = 'jekyll-auth build'
127
+ c.description = "Build Jekyll site"
128
+ c.action do |args, options|
129
+ say "building the site..."
130
+ sh "bundle exec rake assets:precompile"
131
+ say "site built."
132
+ end
133
+ end
134
+
135
+ default_command :serve
@@ -0,0 +1,5 @@
1
+ # This file is auto-generated by Jekyll Auth
2
+ # It tells Heroku how to launch our site
3
+
4
+ require "jekyll-auth"
5
+ run JekyllAuth.site
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'sinatra-index'
3
+ require 'sinatra_auth_github'
4
+ require 'rack'
5
+ require File.dirname(__FILE__) + '/jekyll-auth/version'
6
+ require File.dirname(__FILE__) + '/jekyll-auth/auth-site'
7
+ require File.dirname(__FILE__) + '/jekyll-auth/jekyll-site'
8
+
9
+ class JekyllAuth
10
+ def self.site
11
+ Rack::Builder.new do
12
+ use JekyllAuth::AuthSite
13
+ run JekyllAuth::JekyllSite
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ class JekyllAuth
2
+ class AuthSite < Sinatra::Base
3
+
4
+ use Rack::Session::Cookie, :secret => ENV['SESSION_SECRET'] || SecureRandom.hex
5
+
6
+ set :github_options, {
7
+ :client_id => ENV['GITHUB_CLIENT_ID'],
8
+ :client_secret => ENV['GITHUB_CLIENT_SECRET'],
9
+ :scopes => 'user'
10
+ }
11
+
12
+ register Sinatra::Auth::Github
13
+
14
+ before do
15
+ if ENV['GITHUB_TEAM_ID']
16
+ github_team_authenticate!(ENV['GITHUB_TEAM_ID'])
17
+ elsif ENV['GITHUB_ORG_ID']
18
+ github_organization_authenticate!(ENV['GITHUB_ORG_ID'])
19
+ else
20
+ puts "ERROR: Jekyll Auth is refusing to serve your site."
21
+ puts "Looks like your oauth credentials are not properly configured. RTFM."
22
+ halt 401
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ class JekyllAuth
2
+ class JekyllSite < Sinatra::Base
3
+ register Sinatra::Index
4
+ set :public_folder, '_site'
5
+ use_static_index 'index.html'
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ class JekyllAuth
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-auth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Balter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: github-pages
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra-index
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra_auth_github
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: commander
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: heroku
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: git
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: A simple way to use Github Oauth to serve a protected jekyll site to
112
+ your GitHub organization.
113
+ email: ben@balter.com
114
+ executables:
115
+ - jekyll-auth
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - lib/jekyll-auth.rb
120
+ - bin/jekyll-auth
121
+ - config.ru
122
+ - Rakefile
123
+ - lib/jekyll-auth/auth-site.rb
124
+ - lib/jekyll-auth/jekyll-site.rb
125
+ - lib/jekyll-auth/version.rb
126
+ homepage: https://github.com/benbalter/jekyll-auth
127
+ licenses:
128
+ - MIT
129
+ metadata: {}
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.0.3
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: A simple way to use Github OAuth to serve a protected jekyll site to your
150
+ GitHub organization
151
+ test_files: []