Skip to content

Commit 5a4f4ed

Browse files
authored
Merge pull request #12 from fastruby/feature/readme
Update README.md
2 parents bc91316 + 3bc0b6f commit 5a4f4ed

File tree

4 files changed

+198
-11
lines changed

4 files changed

+198
-11
lines changed

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing to OmbuLabs::Auth
2+
Have a fix for a problem you've been running into or an idea for a new feature you think would be useful? Bug reports and pull requests are welcome on GitHub at [https://github.com/fastruby/ombu_labs-auth](https://github.com/fastruby/ombu_labs-auth).
3+
4+
Here's what you need to do:
5+
6+
- Read and understand the [Code of Conduct](https://github.com/fastruby/ombu_labs-auth/blob/main/CODE_OF_CONDUCT.md).
7+
- Fork this repo and clone your fork to somewhere on your machine.
8+
- [Ensure that you have a working environment](#setting-up-your-environment)
9+
- Cut a new branch and write a failing test for the feature or bug fix you plan on implementing.
10+
- [Update the changelog when applicable](#a-word-on-the-changelog).
11+
- Read the guidelines when [Releasing a new version](#releasing-a-new-version)
12+
- Push to your fork and submit a pull request.
13+
- [Make sure the test suite passes on GitHub Actions and make any necessary changes to your branch to bring it to green.](#continuous-integration).
14+
15+
## Setting up your environment
16+
To install the dependencies, run:
17+
18+
```bash
19+
bin/setup
20+
```
21+
22+
## A word on the changelog
23+
You may also notice that we have a changelog in the form of [CHANGELOG.md](CHANGELOG.md). We use a format based on [Keep A Changelog](https://keepachangelog.com/en/1.0.0/).
24+
25+
The important things to keep in mind are:
26+
27+
- If your PR closes any open GitHub issue, make sure you include `Closes #XXXX` in your comment.
28+
- New additions get added under the main (unreleased) heading;
29+
- Attach a link to the PR with the following format:
30+
31+
* [<FEATURE | BUGFIX >: Description of changes](github.com/link/to/pr).
32+
33+
## Releasing a new version
34+
To release a new version, update the version number in `version.rb`.
35+
36+
To create a git tag for the version, push git commits and tags, and push the `.gem` file to rubygems.org, run:
37+
38+
`bundle exec rake release`
39+
40+
## When Submitting a Pull Request:
41+
* If your PR closes any open GitHub issues, please include `Closes #XXXX` in your comment.
42+
* Please include a summary of the change and which issue is fixed or which feature is introduced.
43+
* If changes to the behavior are made, clearly describe what are the changes and why.
44+
* If changes to the UI are made, please include screenshots of the before and after.
45+
46+
## Continuous integration
47+
After opening your Pull Request, please make sure that all tests pass on the CI, to make sure your changes work in all possible environments. GitHub Actions will kick in after you push up a branch or open a PR.
48+
49+
If the build fails, click on a failed job and scroll through its output to verify what is the problem. Push your changes to your branch until the build is green.

README.md

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,82 @@
11
# OmbuLabs::Auth
2-
Short description and motivation.
32

4-
## Usage
5-
How to use my plugin.
3+
This gem provides an easy way to generate new (Devise) sessions for members of a GitHub organization.
64

7-
## Installation
8-
Add this line to your application's Gemfile:
5+
If a user is signing in with GitHub and they are a (public) member of the configured GitHub organization, they will be allowed in.
6+
7+
## Environment Variables
8+
Make sure you configure your ENV variables to use Github authentication.
9+
10+
```
11+
ENV["GITHUB_APP_ID"]
12+
ENV["GITHUB_APP_SECRET"]
13+
ENV["ORGANIZATION_LOGIN"]
14+
```
15+
16+
`ORGANIZATION_LOGIN`: This is the organization name as it appears in the GitHub URL, for instance `orgname` in https://github.com/orgname. It is needed to check if users are a part of the organization. Ensure that your membership is set to _public_ when you visit https://github.com/orgs/orgname/people.
17+
18+
If you don't belong to any organization, you can set up one here: https://github.com/organizations/plan
19+
20+
Make sure you add your organization to the `.env` file like this:
21+
22+
```
23+
ORGANIZATION_LOGIN=orgname
24+
```
25+
26+
`GITHUB_APP_ID` and `GITHUB_APP_SECRET`: These are the credentials of the OAuth GitHub App that you need to create. Follow the instructions on this link to create one: [Creating an OAuth GitHub App](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)
27+
28+
When creating the OAuth GitHub App, the `Homepage URL` field should be set to http://localhost:3000, and the `Authorization callback URL` should be http://localhost:3000/users/auth/github/callback.
29+
30+
Once you create the app and generate credentials for it, make sure you add them to the `.env` file like this:
31+
32+
```
33+
GITHUB_APP_ID=xxxxxxxxxxxxxxxxxxxx
34+
GITHUB_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
35+
```
36+
## Getting Started
37+
38+
- Add these lines to your application's Gemfile:
939

1040
```ruby
11-
gem "ombu_labs-auth"
41+
gem 'ombu_labs-auth'
42+
gem 'omniauth-github', '~> 2.0.0'
1243
```
1344

14-
And then execute:
45+
- And then execute:
1546
```bash
1647
$ bundle
1748
```
1849

19-
Or install it yourself as:
20-
```bash
21-
$ gem install ombu_labs-auth
50+
- Add the following line to `config/routes.rb`
51+
52+
```ruby
53+
mount OmbuLabs::Auth::Engine, at: '/', as: 'ombu_labs_auth'
2254
```
2355

56+
- Add a Devise signin link in your homepage (notice all URL helpers will be under the engine object `ombu_labs_auth`)
57+
58+
```html
59+
<div>
60+
<h1>Welcome to the App</h1>
61+
<%= link_to "Sign in", ombu_labs_auth.new_user_session_path %>
62+
</div>
63+
```
64+
65+
- Add the Devise authentication helper to your private objects controllers
66+
67+
```
68+
before_action :authenticate_user!
69+
```
70+
71+
## Caveats
72+
73+
Please be aware this gem is a mountable engine which depends on Devise, and it's not possible to mount it multiple times. Refer to their Wiki for more on the issue - https://github.com/heartcombo/devise/wiki/How-To:-Use-devise-inside-a-mountable-engine
74+
2475
## Contributing
25-
Contribution directions go here.
76+
77+
Have a fix for a problem you've been running into or an idea for a new feature you think would be useful?
78+
79+
Take a look at the [Contributing document](https://github.com/fastruby/ombu_labs-auth/blob/main/CONTRIBUTING.md) for instructions to set up the repo on your machine and create a good Pull Request.
2680

2781
## License
2882
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

bin/setup

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
set -vx
5+
6+
bundle install
7+
8+
# Do any other automated setup that you need to do here

0 commit comments

Comments
 (0)