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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9d94cc333de503a6fbdb201f1ed9b31cff858cb5
4
- data.tar.gz: bfcedea76e84e2134f0bdf187bed35f30d8e99b0
2
+ SHA256:
3
+ metadata.gz: 25f71431fe3e6a87766f5fe1d2ed3250991afb1c751025088e6740466466dec8
4
+ data.tar.gz: 3f110e0d1d75eaf3921c7fd10e87c33ee3b2fc6126439a29e570abfb5cb0f89d
5
5
  SHA512:
6
- metadata.gz: ab4b0d18dfd9ee56ab8e3781990ff90decf4bb580e20f67379cf889cb836168e9a86ce1e2f495c0bc77e4417e61d21bdfaa5a95cf4f6152f464f6e43402bc0e3
7
- data.tar.gz: 3d444b873b5918a678d31acbbb18c7944cb825c9f765ad28038ce36d5b0dcc2983dd0f9261c78fba87a67c19f83eb221389ba1445d6c7d6fd1f20731c587b502
6
+ metadata.gz: 7b7876e78ea89e16ac9a7d49127c27d4bcc37e4397c1d14aa16c746144d9ce90cb5756bc894282fffbb383ae70bcfbcb8550755075352b51786d598c0f5cbe12
7
+ data.tar.gz: a57c1176f2c27257905503c278a670a14256963a471f67475dc09fc97f0a4739ded211be927a36a889f9ed4f0d2e288a5088600cfd87e9684ec55d4a1421b4a7
@@ -0,0 +1,3 @@
1
+ # Require @benbalter's :+1: for changes to the .github repo-config files
2
+ # mainly due to https://github.com/probot/settings privilege escalation
3
+ .github/* @benbalter
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+
5
+ ---
6
+
7
+ ### Describe the bug
8
+
9
+ A clear and concise description of what the bug is.
10
+
11
+ ### Steps to reproduce the behavior
12
+
13
+ 1. Go to '...'
14
+ 2. Click on '....'
15
+ 3. Scroll down to '....'
16
+ 4. See error
17
+
18
+ ### Expected behavior
19
+
20
+ A clear and concise description of what you expected to happen.
21
+
22
+ ### Screenshots
23
+
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ ### Additional context
27
+
28
+ Add any other context about the problem here.
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+
5
+ ---
6
+
7
+ ### Is your feature request related to a problem? Please describe the problem you're trying to solve.
8
+
9
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
10
+
11
+ ### Describe the solution you'd like
12
+
13
+ A clear and concise description of what you want to happen.
14
+
15
+ ### Describe alternatives you've considered
16
+
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ ### Additional context
20
+
21
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,23 @@
1
+ # Behaviorbot config. See https://github.com/behaviorbot/ for more information.
2
+ # Note: Please Don't edit this file directly.
3
+ # Edit https://github.com/benbalter/shared-community-files instead.
4
+
5
+ # Configuration for update-docs - https://github.com/behaviorbot/update-docs
6
+ updateDocsComment: "Thanks for the pull request! If you are making any changes to the user-facing functionality, please be sure to update the documentation in the `README` or `docs/` folder alongside your change. :heart:"
7
+
8
+ # Configuration for request-info - https://github.com/behaviorbot/request-info
9
+ requestInfoReplyComment: Thanks for this. Do you mind providing a bit more information about what problem you're trying to solve?
10
+ requestInfoLabelToAdd: more-information-needed
11
+
12
+ # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
13
+ #newIssueWelcomeComment: >
14
+ # Welcome!
15
+
16
+ # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
17
+ newPRWelcomeComment: Welcome! Congrats on your first pull request to Jekyll Auth. If you haven't already, please be sure to check out [the contributing guidelines](https://github.com/benbalter/jekyll-auth/blob/master/docs/CONTRIBUTING.md).
18
+
19
+ # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
20
+ firstPRMergeComment: "Congrats on getting your first pull request to Jekyll Auth merged! Without amazing humans like you submitting pull requests, we couldn’t run this project. You rock! :tada:<br /><br />If you're interested in tackling another bug or feature, take a look at [the open issues](https://github.com/benbalter/jekyll-auth/issues), especially those [labeled `help wanted`](https://github.com/benbalter/jekyll-auth/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)."
21
+
22
+ # Bug workaround
23
+ contact_links: []
@@ -0,0 +1 @@
1
+ patreon: benbalter
@@ -0,0 +1,15 @@
1
+ # Configuration for probot-no-response - https://github.com/probot/no-response
2
+ # Note: Please Don't edit this file directly.
3
+ # Edit https://github.com/benbalter/shared-community-files instead.
4
+
5
+ # Number of days of inactivity before an Issue is closed for lack of response
6
+ daysUntilClose: 14
7
+ # Label requiring a response
8
+ responseRequiredLabel: more-information-needed
9
+ # Comment to post when closing an Issue for lack of response. Set to `false` to disable
10
+ closeComment: >
11
+ This issue has been automatically closed because there has been no response
12
+ to our request for more information from the original author. With only the
13
+ information that is currently in the issue, we don't have enough information
14
+ to take action. Please reach out if you have or find the answers we need so
15
+ that we can investigate further.
@@ -0,0 +1,4 @@
1
+ template: |
2
+ ## What's Changed
3
+
4
+ $CHANGES
@@ -0,0 +1,33 @@
1
+ # Repository settings set via https://github.com/probot/settings
2
+ # Note: Please Don't edit this file directly.
3
+ # Edit https://github.com/benbalter/shared-community-files instead.
4
+
5
+ repository:
6
+ has_issues: true
7
+ has_wiki: false
8
+ has_projects: false
9
+ has_downloads: false
10
+
11
+ labels:
12
+ - name: help wanted
13
+ oldname: help-wanted
14
+ color: 0e8a16
15
+ - name: more-information-needed
16
+ color: d93f0b
17
+ - name: bug
18
+ color: b60205
19
+ - name: feature
20
+ color: 1d76db
21
+ - name: good first issue
22
+ color: "5319e7"
23
+
24
+ # Not currently implemented by probot/settings, but manually implemented in script/deploy
25
+ branch_protection:
26
+ restrictions: null
27
+ enforce_admins: false
28
+ required_status_checks:
29
+ strict: true
30
+ contexts:
31
+ - "continuous-integration/travis-ci"
32
+ required_pull_request_reviews:
33
+ require_code_owner_reviews: true
data/.github/stale.yml ADDED
@@ -0,0 +1,29 @@
1
+ # Configuration for probot-stale - https://github.com/probot/stale
2
+ # Note: Please Don't edit this file directly.
3
+ # Edit https://github.com/benbalter/shared-community-files instead.
4
+
5
+ # Number of days of inactivity before an Issue or Pull Request becomes stale
6
+ daysUntilStale: 60
7
+
8
+ # Number of days of inactivity before a stale Issue or Pull Request is closed
9
+ daysUntilClose: 7
10
+
11
+ # Issues or Pull Requests with these labels will never be considered stale
12
+ exemptLabels:
13
+ - pinned
14
+ - security
15
+
16
+ # Label to use when marking as stale
17
+ staleLabel: wontfix
18
+
19
+ # Comment to post when marking as stale. Set to `false` to disable
20
+ markComment: >
21
+ This issue has been automatically marked as stale because it has not had
22
+ recent activity. It will be closed if no further activity occurs. Thank you
23
+ for your contributions.
24
+
25
+ # Comment to post when closing a stale Issue or Pull Request. Set to `false` to disable
26
+ closeComment: false
27
+
28
+ # Limit to only `issues` or `pulls`
29
+ # only: issues
data/.rubocop.yml ADDED
@@ -0,0 +1,28 @@
1
+ require: rubocop-jekyll
2
+ inherit_gem:
3
+ rubocop-jekyll: .rubocop.yml
4
+
5
+ Style/Documentation:
6
+ Enabled: false
7
+
8
+ Metrics/MethodLength:
9
+ Enabled: false
10
+
11
+ Layout/LineLength:
12
+ Enabled: false
13
+
14
+ Naming/FileName:
15
+ Enabled: false
16
+
17
+ Metrics/BlockLength:
18
+ Enabled: false
19
+
20
+ Style/DoubleNegation:
21
+ Enabled: false
22
+
23
+ AllCops:
24
+ Exclude:
25
+ - vendor/**/*
26
+
27
+ Jekyll/NoPutsAllowed:
28
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,4 +1,8 @@
1
1
  language: ruby
2
+ rvm:
3
+ - 3.0
4
+ - 2.7
5
+ - 2.6
2
6
  script: "./script/cibuild"
3
7
 
4
8
  before_script:
@@ -12,4 +16,4 @@ env:
12
16
  global:
13
17
  - GITHUB_CLIENT_ID=FOO
14
18
  - GITHUB_CLIENT_SECRET=BAR
15
- - GITHUB_ORG_ID="balter-test-org"
19
+ - GITHUB_ORG_NAME="balter-test-org"
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gemspec
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
- require 'rubygems/package_task'
2
- require 'rubygems/specification'
3
- require 'bundler'
4
- require 'fileutils'
5
- require 'dotenv'
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems/package_task"
4
+ require "rubygems/specification"
5
+ require "bundler"
6
+ require "fileutils"
7
+ require "dotenv"
6
8
 
7
9
  task :default => [:spec]
8
10
 
@@ -12,9 +14,9 @@ task :site do
12
14
  `bundle exec jekyll-auth`
13
15
  end
14
16
 
15
- require 'rspec/core/rake_task'
17
+ require "rspec/core/rake_task"
16
18
  desc "Run specs"
17
19
  RSpec::Core::RakeTask.new do |t|
18
- t.pattern = 'spec/**/*_spec.rb'
20
+ t.pattern = "spec/**/*_spec.rb"
19
21
  t.rspec_opts = ["--order", "rand", "--color"]
20
22
  end
data/bin/jekyll-auth CHANGED
@@ -1,26 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # Command-line interface for jekyll-auth
3
5
 
4
- require 'mercenary'
5
- require 'jekyll-auth'
6
- require 'open3'
7
- require 'jekyll-auth'
6
+ require "mercenary"
7
+ require "jekyll-auth"
8
+ require "open3"
8
9
 
9
10
  Mercenary.program("jekyll-auth") do |p|
10
- p.version JekyllAuth::VERSION
11
+ p.version JekyllAuth::VERSION
11
12
  p.description "A simple way to use Github OAuth to serve a protected jekyll site to your GitHub organization"
12
- p.syntax 'jekyll-auth <subcommand> options'
13
+ p.syntax "jekyll-auth <subcommand> options"
13
14
 
14
15
  p.command(:new) do |c|
15
- c.syntax 'new'
16
+ c.syntax "new"
16
17
  c.description "Initialize an existing Jekyll site as a Jekyll Auth site"
17
- c.action do |args, options|
18
-
18
+ c.action do |_args, _options|
19
19
  JekyllAuth::Commands.copy_templates
20
20
 
21
- if JekyllAuth::Commands.changed?
22
- puts "Looks like we've made some changes, you may want to do a git commit and git push sometime soon".yellow
23
- end
21
+ puts "Looks like we've made some changes, you may want to do a git commit and git push sometime soon".yellow if JekyllAuth::Commands.changed?
24
22
 
25
23
  puts "Setup complete. Run `jekyll-auth` to view the authenticated site."
26
24
  end
@@ -30,30 +28,29 @@ Mercenary.program("jekyll-auth") do |p|
30
28
  # Called by Rake task, to allow the gem
31
29
  # to add functionality here in the future
32
30
  p.command(:build) do |c|
33
- c.syntax 'build'
31
+ c.syntax "build"
34
32
  c.description "Build the Jekyll site"
35
- c.action do |args, options|
36
- require 'jekyll'
33
+ c.action do |_args, options|
34
+ require "jekyll"
37
35
  Jekyll::Commands::Build.process(options)
38
36
  end
39
37
  end
40
38
 
41
39
  p.command(:team_id) do |c|
42
- c.syntax 'team_id --org <ORG> --team <TEAM>'
40
+ c.syntax "team_id --org <ORG> --team <TEAM>"
43
41
  c.description "Retrieve a team's ID"
44
- c.option 'org', '--org <ORG>', 'The GitHub Organization, e.g., "jekyll"'
45
- c.option 'team', '--team <TEAM>', 'The team name, e.g., "maintainers"'
46
-
47
- c.action do |args, options|
42
+ c.option "org", "--org <ORG>", 'The GitHub Organization, e.g., "jekyll"'
43
+ c.option "team", "--team <TEAM>", 'The team name, e.g., "maintainers"'
48
44
 
49
- if !JekyllAuth::Commands.env_var_set? "GITHUB_TOKEN"
45
+ c.action do |_args, options|
46
+ unless JekyllAuth::Commands.env_var_set? "GITHUB_TOKEN"
50
47
  puts "You'll need to go to https://github.com/settings/tokens/new and create a personal access token".red
51
48
  puts "Once you've got the token, prefix the jekyll-auth command with GITHUB_TOKEN=[YOUR TOKEN]".red
52
49
  puts "You can also add it to a `.env` file in this directory".red
53
50
  exit 1
54
51
  end
55
52
 
56
- org = options["org"] || ENV["GITHUB_ORG_ID"]
53
+ org = options["org"] || ENV["GITHUB_ORG_NAME"]
57
54
  team = options["team"]
58
55
 
59
56
  if org.nil? || team.nil?
@@ -62,9 +59,9 @@ Mercenary.program("jekyll-auth") do |p|
62
59
  exit 1
63
60
  end
64
61
 
65
- team_id = JekyllAuth::Comands.team_id(org, team)
62
+ team_id = JekyllAuth::Commands.team_id(org, team)
66
63
 
67
- if found
64
+ if team_id
68
65
  puts "The team ID for `@#{org}/#{team}` is `#{team_id}`".green
69
66
  else
70
67
  puts "Couldn't find the `@#{org}/#{team}` team.".red
@@ -75,12 +72,14 @@ Mercenary.program("jekyll-auth") do |p|
75
72
  p.command(:serve) do |c|
76
73
  c.syntax "serve"
77
74
  c.description "Run Jekyll Auth site locally"
78
- c.action do |args, options|
75
+ c.option "host", "--host <HOST>", "Listen at the given hostname, e.g., 127.0.0.1"
76
+ c.option "port", "--port <PORT>", "Listen on the given port, e.g., 4000"
79
77
 
78
+ c.action do |_args, options|
80
79
  # Ensure environmental variables are set
81
- unless ["GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET"].all? { |v| JekyllAuth::Commands.env_var_set?(v) }
80
+ unless %w(GITHUB_CLIENT_ID GITHUB_CLIENT_SECRET).all? { |v| JekyllAuth::Commands.env_var_set?(v) }
82
81
  puts "Whoops. Looks like you forgot to tell Jekyll Auth about your app".red
83
- puts "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)".red
82
+ puts "Be sure to run export GITHUB_CLIENT_ID=[client id], export GITHUB_CLIENT_SECRET=[client secret], and export GITHUB_ORG_NAME=[org name] (or GITHUB_TEAM_ID)".red
84
83
  puts "See the readme for more information on where to find these".red
85
84
  exit 1
86
85
  end
@@ -88,24 +87,25 @@ Mercenary.program("jekyll-auth") do |p|
88
87
  # build site
89
88
  p.go ["build"]
90
89
 
90
+ host = options["host"] || "0.0.0.0"
91
+ port = options["port"] || "4000"
92
+
91
93
  puts "Spinning up the server with authentication. Use CTRL-C to stop."
92
94
  puts "To preview the site without authentication, use the `jekyll serve` command"
93
- JekyllAuth::Commands.execute_command "bundle", "exec", "rackup", "-p", "4000"
94
-
95
+ JekyllAuth::Commands.execute_command "bundle", "exec", "rackup", "-o", host, "-p", port
95
96
  end
96
97
  end
97
98
 
98
99
  p.command(:setup) do |c|
99
100
  c.syntax "setup"
100
101
  c.description "Configure Heroku for use with your Jekyll Auth site"
101
- c.option "client_id", "--client_id", "Your oauth app client id"
102
- c.option "client_secret", "--client_secret", "Your oauth app client secret"
103
- c.option "team_id", "--team_id", "The team to authenticate against"
104
- c.option "org_id", "--org_id", "An organization to authenticate against"
105
- c.action do |args, options|
106
-
102
+ c.option "client_id", "--client_id <ID>", "Your oauth app client id"
103
+ c.option "client_secret", "--client_secret <SECRET>", "Your oauth app client secret"
104
+ c.option "team_id", "--team_id <ID>", "The team to authenticate against"
105
+ c.option "org_name", "--org_name <NAME>", "An organization to authenticate against"
106
+ c.action do |_args, options|
107
107
  if find_executable("heroku").nil?
108
- say "Looks like we're missing the Heroku client. Let's see if we can't install it..."
108
+ puts "Looks like we're missing the Heroku client. Let's see if we can't install it..."
109
109
  JekyllAuth::Commands.execute_command "wget", "-qO-", "https://toolbelt.heroku.com/install.sh", "|", "sh"
110
110
  end
111
111
 
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ben@balter.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/