jekyll-auth 1.0.2 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/.github/CODEOWNERS +3 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
  5. data/.github/config.yml +23 -0
  6. data/.github/funding.yml +1 -0
  7. data/.github/no-response.yml +15 -0
  8. data/.github/release-drafter.yml +4 -0
  9. data/.github/settings.yml +33 -0
  10. data/.github/stale.yml +29 -0
  11. data/.rubocop.yml +28 -0
  12. data/.travis.yml +5 -1
  13. data/Gemfile +2 -0
  14. data/Rakefile +9 -7
  15. data/bin/jekyll-auth +36 -36
  16. data/docs/CODE_OF_CONDUCT.md +46 -0
  17. data/docs/CONTRIBUTING.md +88 -0
  18. data/docs/README.md +33 -0
  19. data/docs/SECURITY.md +3 -0
  20. data/docs/_config.yml +2 -0
  21. data/docs/configuring.md +36 -0
  22. data/docs/getting-started.md +63 -0
  23. data/docs/running-locally.md +24 -0
  24. data/docs/troubleshooting.md +31 -0
  25. data/jekyll-auth.gemspec +22 -15
  26. data/lib/jekyll-auth.rb +16 -13
  27. data/lib/jekyll_auth/auth_site.rb +12 -15
  28. data/lib/jekyll_auth/commands.rb +12 -9
  29. data/lib/jekyll_auth/config.rb +15 -8
  30. data/lib/jekyll_auth/config_error.rb +3 -2
  31. data/lib/jekyll_auth/helpers.rb +6 -3
  32. data/lib/jekyll_auth/jekyll_site.rb +6 -5
  33. data/lib/jekyll_auth/sinatra/auth/github.rb +8 -4
  34. data/lib/jekyll_auth/version.rb +3 -1
  35. data/script/cibuild +5 -0
  36. data/spec/jekyll_auth_auth_site_spec.rb +17 -17
  37. data/spec/jekyll_auth_bin_spec.rb +12 -11
  38. data/spec/jekyll_auth_commands_spec.rb +6 -5
  39. data/spec/jekyll_auth_helpers_spec.rb +5 -4
  40. data/spec/jekyll_auth_jekyll_site_spec.rb +2 -1
  41. data/spec/jekyll_auth_spec.rb +5 -4
  42. data/spec/spec_helper.rb +14 -9
  43. data/templates/.gitignore +0 -1
  44. data/templates/Rakefile +2 -0
  45. data/templates/config.ru +2 -0
  46. metadata +150 -45
  47. data/README.md +0 -149
@@ -0,0 +1,88 @@
1
+ # Contributing to Jekyll Auth
2
+
3
+ Hi there! We're thrilled that you'd like to contribute to Jekyll Auth. Your help is essential for keeping it great.
4
+
5
+ Jekyll Auth is an open source project supported by the efforts of an entire community and built one contribution at a time by users like you. We'd love for you to get involved. Whatever your level of skill or however much time you can give, your contribution is greatly appreciated. There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, helping other users by commenting on issues, or writing code which can be incorporated into Jekyll Auth itself.
6
+
7
+ Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests.
8
+
9
+ ## Troubleshooting
10
+
11
+ Having trouble with Jekyll Auth? Check out [the troubleshooting guidelines](troubleshooting.md) for solutions to common problems.
12
+
13
+
14
+ ## How to report a bug
15
+
16
+ Think you found a bug? Please check [the list of open issues](https://github.com/benbalter/jekyll-auth/issues) to see if your bug has already been reported. If it hasn't please [submit a new issue](https://github.com/benbalter/jekyll-auth/issues/new).
17
+
18
+ Here are a few tips for writing *great* bug reports:
19
+
20
+ * Describe the specific problem (e.g., "widget doesn't turn clockwise" versus "getting an error")
21
+ * Include the steps to reproduce the bug, what you expected to happen, and what happened instead
22
+ * Check that you are using the latest version of the project and its dependencies
23
+ * Include what version of the project your using, as well as any relevant dependencies
24
+ * Only include one bug per issue. If you have discovered two bugs, please file two issues
25
+ * Include screenshots or screencasts whenever possible
26
+ * Even if you don't know how to fix the bug, including a failing test may help others track it down
27
+
28
+ **If you find a security vulnerability, do not open an issue. Please email ben@balter.com instead.**
29
+
30
+ ## How to suggest a feature or enhancement
31
+
32
+ If you find yourself wishing for a feature that doesn't exist in Jekyll Auth, you are probably not alone. There are bound to be others out there with similar needs. Many of the features that Jekyll Auth has today have been added because our users saw the need.
33
+
34
+ Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and goals of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible, including describing the problem you're trying to solve.
35
+
36
+ [Open an issue](https://github.com/benbalter/jekyll-auth/issues/new) which describes the feature you would like to see, why you want it, how it should work, etc.
37
+
38
+
39
+
40
+ ## Your first contribution
41
+
42
+ We'd love for you to contribute to the project. Unsure where to begin contributing to Jekyll Auth? You can start by looking through these "good first issue" and "help wanted" issues:
43
+
44
+ * [Good first issues](https://github.com/benbalter/jekyll-auth/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) - issues which should only require a few lines of code and a test or two
45
+ * [Help wanted issues](https://github.com/benbalter/jekyll-auth/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) - issues which may be a bit more involved, but are specifically seeking community contributions
46
+
47
+ *p.s. Feel free to ask for help; everyone is a beginner at first* :smiley_cat:
48
+
49
+ ## How to propose changes
50
+
51
+ Here's a few general guidelines for proposing changes:
52
+
53
+ * If you are changing any user-facing functionality, please be sure to update the documentation
54
+ * If you are adding a new behavior or changing an existing behavior, please be sure to update the corresponding test(s)
55
+ * Each pull request should implement **one** feature or bug fix. If you want to add or fix more than one thing, submit more than one pull request
56
+ * Do not commit changes to files that are irrelevant to your feature or bug fix
57
+ * Don't bump the version number in your pull request (it will be bumped prior to release)
58
+ * Write [a good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
59
+
60
+ At a high level, [the process for proposing changes](https://guides.github.com/introduction/flow/) is:
61
+
62
+ 1. [Fork](https://github.com/benbalter/jekyll-auth/fork) and clone the project
63
+ 2. Configure and install the dependencies: `script/bootstrap`
64
+ 3. Make sure the tests pass on your machine: `script/cibuild`
65
+ 4. Create a descriptively named branch: `git checkout -b my-branch-name`
66
+ 5. Make your change, add tests and documentation, and make sure the tests still pass
67
+ 6. Push to your fork and [submit a pull request](https://github.com/benbalter/jekyll-auth/compare) describing your change
68
+ 7. Pat your self on the back and wait for your pull request to be reviewed and merged
69
+
70
+ **Interesting in submitting your first Pull Request?** It's easy! You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
71
+
72
+ ## Bootstrapping your local development environment
73
+
74
+ `script/bootstrap`
75
+
76
+ ## Running tests
77
+
78
+ `script/cibuild`
79
+
80
+ ## Code of conduct
81
+
82
+ This project is governed by [the Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
83
+
84
+ ## Additional Resources
85
+
86
+ * [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/)
87
+ * [Using Pull Requests](https://help.github.com/articles/using-pull-requests/)
88
+ * [GitHub Help](https://help.github.com)
data/docs/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Jekyll Auth
2
+
3
+ *A simple way to use GitHub OAuth to serve a protected Jekyll site to your GitHub organization*
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/jekyll-auth.png)](http://badge.fury.io/rb/jekyll-auth) [![Build Status](https://travis-ci.org/benbalter/jekyll-auth.png?branch=master)](https://travis-ci.org/benbalter/jekyll-auth) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
+
7
+ ## The problem
8
+
9
+ [Jekyll](http://github.com/mojombo/jekyll) and [GitHub Pages](http://pages.github.com) are awesome, right? Static site, lightning fast, everything versioned in Git. What else could you ask for?
10
+
11
+ But what if you only want to share that site with a select number of people? Before, you were SOL. Now, simply host the site on a free, [Heroku](http://heroku.com) Dyno, and whenever someone tries to access it, it will Oauth them against GitHub, and make sure they're a member of your Organization. Pretty cool, huh?
12
+
13
+ ## Requirements
14
+
15
+ 1. A GitHub account (one per user)
16
+ 2. A GitHub Organization (of which members will have access to the Jekyll site)
17
+ 3. A GitHub Application (you can [register one](https://github.com/settings/applications/new) for free)
18
+ 4. A Heroku account (you can technically use this elsewhere, but the instructions are for Heroku)
19
+
20
+ ## Under the hood
21
+
22
+ Every time you push to Heroku, we take advantage of the fact that Heroku automatically runs the `rake assets:precompile` command (normally used for Rails sites) to build our Jekyll site and store it statically, just like GitHub pages would.
23
+
24
+ Anytime a request comes in for a page, we run it through [Sinatra](http://www.sinatrarb.com/) (using the `_site` folder as the static file folder, just as `public` would be normally), and authenticate it using [sinatra\_auth\_github](https://github.com/atmos/sinatra_auth_github).
25
+
26
+ If they're in the org, they get the page. Otherwise, all they ever get is [the bouncer](http://octodex.github.com/bouncer/).
27
+
28
+ ## Further reading
29
+
30
+ * [Configuring](configuring.md)
31
+ * [Getting started](getting-started.md)
32
+ * [Running locally](running-locally.md)
33
+ * [Troubleshooting](troubleshooting.md)
data/docs/SECURITY.md ADDED
@@ -0,0 +1,3 @@
1
+ # Security Policy
2
+
3
+ To report a security vulnerability, please email [ben@balter.com](mailto:ben@balter.com).
data/docs/_config.yml ADDED
@@ -0,0 +1,2 @@
1
+ title: Jekyll Auth
2
+ permalink: pretty
@@ -0,0 +1,36 @@
1
+ ## Configuration
2
+
3
+ ### Whitelisting
4
+
5
+ Don't want to require authentication for every part of your site? Fine! Add a whitelist to your Jekyll's **config.yml** file:
6
+
7
+ ```yaml
8
+ jekyll_auth:
9
+ whitelist:
10
+ - drafts?
11
+ ```
12
+
13
+ `jekyll_auth.whitelist` takes an array of regular expressions as strings. The default auth behavior checks (and blocks) against root (`/`). Any path defined in the whitelist won't require authentication on your site.
14
+
15
+ What if you want to go the other way, and unauthenticate the entire site *except* for certain portions? You can define some regex magic for that:
16
+
17
+ ```yaml
18
+ jekyll_auth:
19
+ whitelist:
20
+ - "^((?!draft).)*$"
21
+ ```
22
+
23
+ There is also a more [extensive article containing installation instructions for Jekyll-Auth](http://fabian-kostadinov.github.io/2014/11/13/installation-of-jekyll-auth/) and a second one on [how to find your GitHub team ID](http://fabian-kostadinov.github.io/2015/01/16/how-to-find-a-github-team-id/).
24
+
25
+ ### Requiring SSL
26
+
27
+ If [you've got SSL set up](https://devcenter.heroku.com/articles/ssl-endpoint), simply add the following your your `_config.yml` file to ensure SSL is enforced.
28
+
29
+ ```yaml
30
+ jekyll_auth:
31
+ ssl: true
32
+ ```
33
+
34
+ ### Using a custom 404
35
+
36
+ Just like GitHub Pages, Jekyll Auth will honor a custom 404 page, if it's generated as `/404.html` in the built site.
@@ -0,0 +1,63 @@
1
+ ## Getting Started
2
+
3
+ ### Create a GitHub Application
4
+
5
+ 1. Navigate to [the GitHub app registration page](https://github.com/settings/applications/new)
6
+ 2. Give your app a name
7
+ 3. Tell GitHub the URL you want the app to eventually live at. If using a free Heroku account, this will be something like <http://my-site.herokuapp.com>
8
+ 4. Specify the callback URL; should be like this: <https://my-site.herokuapp.com/auth/github/callback>; note that this is **https**, not http.
9
+ 5. Hit Save, but leave the page open, you'll need some of the information in a moment
10
+
11
+ Remember the 'my-site' part for later on when using `heroku create`. Also, my-site is often called 'app-name' in Heroku documentation.
12
+
13
+ ### Add Jekyll Auth to your site
14
+
15
+ 1. Within your new site repository or orphaned github [branch](https://help.github.com/articles/creating-project-pages-manually/) (the branch could be named anything except 'gh-pages' since this would then be public on GitHub!), add `gem 'jekyll-auth'` to your `Gemfile` or if you don't already have a `Gemfile`, create a file called `Gemfile` in the root of your site's repository with the following content:
16
+
17
+ ```ruby
18
+ source "https://rubygems.org"
19
+
20
+ gem 'jekyll-auth'
21
+ ```
22
+
23
+ 2. `cd` into your project's directory and run `bundle install`. If you get an error using `bundle install`, see Troubleshooting below.
24
+
25
+ 3. Run `bundle exec jekyll-auth new` which will copy the necessary files to set up the server
26
+
27
+
28
+ ### Setting up hosting with Heroku
29
+
30
+ #### Automatically
31
+
32
+ Run `bundle exec jekyll-auth setup --client_id XXX --client_secret XXX --org_name XXX`
33
+
34
+ (or `--team_id XXX`)
35
+
36
+ #### Manually
37
+
38
+ 1. You may need to add and commit the files generated by `jekyll-auth new` to Git before continuing
39
+ 2. Make sure you have [the Heroku toolbelt](https://toolbelt.heroku.com/) installed
40
+ 3. Run `heroku create my-site` from your site's directory; make sure my-site matches what you specified in the GitHub application registration above.
41
+ 4. `heroku config:set GITHUB_CLIENT_ID=XXX GITHUB_CLIENT_SECRET=XXX GITHUB_ORG_NAME=XXX` (or `GITHUB_TEAM_ID`)
42
+ 5. `git push heroku`, or if you are maintaining the site in an orphaned branch of your GitHub repo (say 'heroku-pages'), do `git push heroku heroku-pages:master`
43
+ 6. `heroku open` to open the site in your browser
44
+
45
+ #### Find the Organization ID (needed to find Team ID)
46
+
47
+ If you need to find an organization's ID, you can use the following cURL command:
48
+
49
+ ```
50
+ curl https://api.github.com/orgs/{org_name}
51
+ ```
52
+
53
+ #### Finding the Team ID
54
+
55
+ If you need help finding a team's numeric ID, you can use the `jekyll-auth team_id` command.
56
+
57
+ For example, to find the team ID for @jekyll/maintainers you'd run the command:
58
+
59
+ ```
60
+ jekyll-auth team_id --org jekyll --team maintainers
61
+ ```
62
+
63
+ You'll want to add a [personal access token](https://github.com/settings/tokens/new) to your `.env` file so that Jekyll-Auth can make the necessary API request, but the command will run you through the process if you do not provide this.
@@ -0,0 +1,24 @@
1
+ ## Running locally
2
+
3
+ Want to run it locally?
4
+
5
+ ### Without authentication
6
+
7
+ Just run `jekyll serve` as you would normally.
8
+
9
+ ### With authentication
10
+
11
+ 1. `export GITHUB_CLIENT_ID=[your github app client id]`
12
+ 2. `export GITHUB_CLIENT_SECRET=[your github app client secret]`
13
+ 3. `export GITHUB_ORG_NAME=[org name]` or `export GITHUB_TEAM_ID=[team id]` or `export GITHUB_TEAM_IDS=1234,5678`
14
+ 4. `jekyll-auth serve`
15
+
16
+ *Pro-tip #1:* For sanity's sake, and to avoid problems with your callback URL, you may want to have two apps, one with a local Oauth callback, and one for production if you're going to be testing auth locally.
17
+
18
+ *Pro-tip #2*: Jekyll Auth supports [dotenv](https://github.com/bkeepers/dotenv) out of the box. You can create a `.env` file in the root of site and add your configuration variables there. It's ignored by `.gitignore` if you use `jekyll-auth new`, but be sure not to accidentally commit your `.env` file. Here's what your `.env` file might look like:
19
+
20
+ ```
21
+ GITHUB_CLIENT_SECRET=abcdefghijklmnopqrstuvwxyz0123456789
22
+ GITHUB_CLIENT_ID=qwertyuiop0001
23
+ GITHUB_TEAM_ID=12345
24
+ ```
@@ -0,0 +1,31 @@
1
+ ## Troubleshooting
2
+
3
+ ### `ERROR: YOUR SITE COULD NOT BE BUILT` During install, either locally or on Heroku.
4
+
5
+ You likely need to add `exclude: [vendor]` to `_config.yml` in your branch's root directory (create the file if it does not exist already). If you still have problems on the *local* install, you may have better luck using `bundle install --deployment`, but be sure to add the resulting 'vendor' directory to .gitignore. For completeness, the full error may look something like this:
6
+
7
+
8
+ ```
9
+ remote: Configuration file: none
10
+ remote: ERROR: YOUR SITE COULD NOT BE BUILT:
11
+ remote: ------------------------------------
12
+ remote: Invalid date '0000-00-00': Post '/vendor/bundle/ruby/2.0.0/gems/jekyll-2.5.3/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb' does not have a valid date in the filename.
13
+ ```
14
+
15
+ ### Pushing to heroku
16
+
17
+ If you are working from a new GitHub-cloned repo (where you have not run `heroku create`), you may also want to push to Heroku. Instead of adding the remote in the standard way with Git, do this:
18
+
19
+
20
+ ```
21
+ heroku git:remote -a my-site
22
+ ```
23
+
24
+ ### Upgrading from Jekyll Auth &lt; 0.1.0
25
+
26
+ 1. `cd` to your project directory
27
+ 2. `rm config.ru`
28
+ 3. `rm Procfile`
29
+ 4. Remove any Jekyll Auth specific requirements from your `Gemfile`
30
+ 5. Follow [the instructions above](https://github.com/benbalter/jekyll-auth#add-jekyll-auth-to-your-site) to get started
31
+ 6. When prompted, select "n" if Heroku is already set up
data/jekyll-auth.gemspec CHANGED
@@ -1,31 +1,38 @@
1
- require './lib/jekyll_auth/version'
1
+ # frozen_string_literal: true
2
+
3
+ require "./lib/jekyll_auth/version"
2
4
 
3
5
  Gem::Specification.new do |s|
4
6
  s.name = "jekyll-auth"
5
7
  s.version = JekyllAuth::VERSION
6
- s.summary = "A simple way to use Github OAuth to serve a protected jekyll site to your GitHub organization"
7
- s.description = "A simple way to use Github Oauth to serve a protected jekyll site to your GitHub organization."
8
+ s.summary = "A simple way to use GitHub OAuth to serve a protected jekyll site to your GitHub organization"
9
+ s.description = "A simple way to use GitHub OAuth to serve a protected jekyll site to your GitHub organization."
8
10
  s.authors = "Ben Balter"
9
11
  s.email = "ben@balter.com"
10
12
  s.homepage = "https://github.com/benbalter/jekyll-auth"
11
13
  s.license = "MIT"
12
14
  s.files = `git ls-files`.split("\n")
13
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
15
17
  s.require_paths = ["lib"]
16
18
 
17
- s.add_dependency "jekyll", "~> 2.0"
19
+ s.add_dependency "activesupport", ">= 5", "< 7"
20
+ s.add_dependency "colorator", "~> 1.0"
21
+ s.add_dependency "dotenv", "~> 2.0"
22
+ s.add_dependency "jekyll", "~> 4.0"
23
+ s.add_dependency "mercenary", "~> 0.3"
24
+ s.add_dependency "rack", "~> 1.6"
25
+ s.add_dependency "rack-protection", "~> 1.5", ">= 1.5.5"
26
+ s.add_dependency "rack-ssl-enforcer", "~> 0.2"
27
+ s.add_dependency "rake", "~> 13.0"
28
+ s.add_dependency "safe_yaml", "~> 1.0"
18
29
  s.add_dependency "sinatra-index", "~> 0.0"
19
30
  s.add_dependency "sinatra_auth_github", "~> 1.1"
20
- s.add_dependency "rack", "1.5.2"
21
- s.add_dependency "dotenv", "~> 1.0"
22
- s.add_dependency "rake", "~> 10.3"
23
- s.add_dependency "rack-ssl-enforcer", "~> 0.2"
24
- s.add_dependency "mercenary", "~> 0.3"
25
- s.add_dependency 'safe_yaml', "~> 1.0"
26
- s.add_dependency "colorator", "~> 0.1"
27
- s.add_development_dependency "rspec", "~> 3.1"
28
- s.add_development_dependency "rack-test", "~> 0.6"
29
- s.add_development_dependency "webmock", "~> 1.2 "
30
31
  s.add_development_dependency "pry", "~> 0.10"
32
+ s.add_development_dependency "rack-test", "~> 0.6"
33
+ s.add_development_dependency "rspec", "~> 3.1"
34
+ s.add_development_dependency "rubocop", "~> 0.49", ">= 0.49.0"
35
+ s.add_development_dependency "rubocop-jekyll", "~> 0.11.0"
36
+ s.add_development_dependency "rubocop-performance", "~> 1.0"
37
+ s.add_development_dependency "webmock", "~> 2.3 "
31
38
  end
data/lib/jekyll-auth.rb CHANGED
@@ -1,16 +1,19 @@
1
- require 'sinatra-index'
2
- require 'sinatra_auth_github'
3
- require 'dotenv'
4
- require 'safe_yaml'
5
- require 'colorator'
6
- require 'mkmf'
7
- require_relative 'jekyll_auth/version'
8
- require_relative 'jekyll_auth/helpers'
9
- require_relative 'jekyll_auth/config'
10
- require_relative 'jekyll_auth/auth_site'
11
- require_relative 'jekyll_auth/jekyll_site'
12
- require_relative 'jekyll_auth/config_error'
13
- require_relative 'jekyll_auth/commands'
1
+ # frozen_string_literal: true
2
+
3
+ require "sinatra-index"
4
+ require "sinatra_auth_github"
5
+ require "dotenv"
6
+ require "safe_yaml"
7
+ require "colorator"
8
+ require "mkmf"
9
+ require_relative "jekyll_auth/version"
10
+ require_relative "jekyll_auth/helpers"
11
+ require_relative "jekyll_auth/config"
12
+ require_relative "jekyll_auth/auth_site"
13
+ require_relative "jekyll_auth/jekyll_site"
14
+ require_relative "jekyll_auth/config_error"
15
+ require_relative "jekyll_auth/commands"
16
+ require_relative "jekyll_auth/sinatra/auth/github"
14
17
 
15
18
  Dotenv.load
16
19
 
@@ -1,21 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class JekyllAuth
2
4
  class AuthSite < Sinatra::Base
3
-
4
5
  configure :production do
5
- require 'rack-ssl-enforcer'
6
+ require "rack-ssl-enforcer"
6
7
  use Rack::SslEnforcer if JekyllAuth.ssl?
7
8
  end
8
9
 
9
- use Rack::Session::Cookie, {
10
- :http_only => true,
11
- :secret => ENV['SESSION_SECRET'] || SecureRandom.hex
12
- }
10
+ use Rack::Session::Cookie, :http_only => true,
11
+ :secret => ENV["SESSION_SECRET"] || SecureRandom.hex
13
12
 
14
- set :github_options, {
15
- :scopes => 'read:org'
16
- }
13
+ set :github_options, :scopes => "read:org"
17
14
 
18
- ENV['WARDEN_GITHUB_VERIFIER_SECRET'] ||= SecureRandom.hex
15
+ ENV["WARDEN_GITHUB_VERIFIER_SECRET"] ||= SecureRandom.hex
19
16
  register Sinatra::Auth::Github
20
17
 
21
18
  use Rack::Logger
@@ -29,19 +26,19 @@ class JekyllAuth
29
26
 
30
27
  case authentication_strategy
31
28
  when :team
32
- github_team_authenticate! ENV['GITHUB_TEAM_ID']
29
+ github_team_authenticate! ENV["GITHUB_TEAM_ID"]
33
30
  when :teams
34
- github_teams_authenticate! ENV['GITHUB_TEAM_IDS'].split(",")
31
+ github_teams_authenticate! ENV["GITHUB_TEAM_IDS"].split(",")
35
32
  when :org
36
- github_organization_authenticate! ENV['GITHUB_ORG_ID']
33
+ github_organization_authenticate! ENV["GITHUB_ORG_NAME"]
37
34
  else
38
35
  raise JekyllAuth::ConfigError
39
36
  end
40
37
  end
41
38
 
42
- get '/logout' do
39
+ get "/logout" do
43
40
  logout!
44
- redirect '/'
41
+ redirect "/"
45
42
  end
46
43
  end
47
44
  end
@@ -1,11 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class JekyllAuth
2
4
  class Commands
3
-
4
- FILES = %w{Rakefile config.ru .gitignore .env}
5
- VARS = %w{client_id client_secret team_id org_id}
5
+ FILES = %w(Rakefile config.ru .gitignore .env).freeze
6
+ VARS = %w(client_id client_secret team_id org_name).freeze
6
7
 
7
8
  def self.source
8
- @source ||= File.expand_path( "../../templates", File.dirname(__FILE__) )
9
+ @source ||= File.expand_path("../../templates", File.dirname(__FILE__))
9
10
  end
10
11
 
11
12
  def self.destination
@@ -13,14 +14,15 @@ class JekyllAuth
13
14
  end
14
15
 
15
16
  def self.changed?
16
- execute_command("git", "status", destination, "--porcelain").length != 0
17
- rescue
17
+ !execute_command("git", "status", destination, "--porcelain").empty?
18
+ rescue StandardError
18
19
  false
19
20
  end
20
21
 
21
22
  def self.execute_command(*args)
22
23
  output, status = Open3.capture2e(*args)
23
- raise "Command `#{args.join(" ")}` failed: #{output}" if status != 0
24
+ raise "Command `#{args.join(" ")}` failed: #{output}" unless status.exitstatus.zero?
25
+
24
26
  output
25
27
  end
26
28
 
@@ -44,13 +46,14 @@ class JekyllAuth
44
46
  end
45
47
 
46
48
  def self.env_var_set?(var)
47
- !(ENV[var].to_s.blank?)
49
+ !ENV[var].to_s.blank?
48
50
  end
49
51
 
50
52
  def self.init_repo
51
53
  execute_command "git", "init", destination
52
54
  FILES.each do |file|
53
55
  next if file == ".env"
56
+
54
57
  execute_command("git", "add", "--", "#{destination}/#{file}")
55
58
  end
56
59
  end
@@ -61,7 +64,7 @@ class JekyllAuth
61
64
 
62
65
  def self.heroku_remote_set?
63
66
  remotes = execute_command "git", "remote", "-v"
64
- !!(remotes =~ /^heroku\s/)
67
+ !!(remotes =~ %r!^heroku\s!)
65
68
  end
66
69
 
67
70
  def self.configure_heroku(options)