{"id":15538421,"url":"https://github.com/benbalter/add-to-org","last_synced_at":"2025-09-04T07:06:15.155Z","repository":{"id":17097583,"uuid":"19862950","full_name":"benbalter/add-to-org","owner":"benbalter","description":"A simple Oauth App to automatically add users to an organization","archived":false,"fork":false,"pushed_at":"2021-10-07T20:51:01.000Z","size":334,"stargazers_count":29,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-06T14:55:05.433Z","etag":null,"topics":["github","oauth","oauth-application","organization","private-repository","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benbalter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-16T16:19:19.000Z","updated_at":"2025-08-06T11:38:53.000Z","dependencies_parsed_at":"2022-08-26T04:20:55.088Z","dependency_job_id":null,"html_url":"https://github.com/benbalter/add-to-org","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/benbalter/add-to-org","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fadd-to-org","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fadd-to-org/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fadd-to-org/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fadd-to-org/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benbalter","download_url":"https://codeload.github.com/benbalter/add-to-org/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fadd-to-org/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273568312,"owners_count":25128761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","oauth","oauth-application","organization","private-repository","ruby"],"created_at":"2024-10-02T12:03:51.311Z","updated_at":"2025-09-04T07:06:15.132Z","avatar_url":"https://github.com/benbalter.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Add to Org\n\n*A simple Oauth App to automatically add users to an organization*\n\n[![Gem Version](https://badge.fury.io/rb/add-to-org.svg)](http://badge.fury.io/rb/add-to-org) [![Build Status](https://travis-ci.org/benbalter/add-to-org.svg)](https://travis-ci.org/benbalter/add-to-org)\n\n## Usage\n\nOnce set up, simply swap out your app's domain for any GitHub URL. E.g., `github.com/government/best-practices/issues/1` becomes `government-community.githubapp.com/government/best-practices/1`. The user will be authenticated, added to the organization, and redirected to the requested GitHub URL.\n\n## Setup\n\n*Pro-tip: for a quickstart on how to set up the app, see the [add-to-org demo app](https://github.com/benbalter/add-to-org-demo).*\n\n### Credentials\n\nYou'll need a few different credentials for things to work:\n\n#### A bot account\n\nYou'll need a dedicated \"bot\" account to add users to the organization:\n\n1. [Create a bot account](https://github.com/signup) (a standard GitHub account not used by a human) that has *admin* rights to your organization.\n2. [Create a personal access token](https://github.com/settings/tokens/new) for that user, with `admin:org` scope.\n\n#### An OAuth application\n\nYou'll also need to create an OAUth application to validate users:\n\n1. Create an OAauth application *within your organization* via `https://github.com/organizations/[YOUR-ORGANIZATION-NAME]/settings/applications/new`\n2. The homepage URL should be the URL to your production instance.\n3. You can leave the callback URL blank. The default is fine.\n\n## Developing locally and deploying\n\n*Pro-tip: for a quickstart on how to set up the app, see the [add-to-org demo app](https://github.com/benbalter/add-to-org-demo)*\n\n1. Create [an oauth app](github.com/settings/applications/new) (see above)\n2. Create a personal access token for a user with admin rights to the organization (see above)\n3. Add `gem 'add-to-org' to your project's Gemfile\n4. Add the following to your project's `config.ru` file:\n\n```ruby\nrequire 'add-to-org'\nrun AddToOrg::App\n```\n\n## Configuration\n\nThe following environmental values should be set:\n\n* `GITHUB_ORG_ID` - The name of the org to add users to\n* `GITHUB_TEAM_ID` - The ID of the team to add users to. Get this from the team page's URL\n* `GITHUB_CLIENT_ID` - Your OAuth app's client ID\n* `GITHUB_CLIENT_SECRET` - Your Oauth app's client secret\n* `GITHUB_TOKEN` - A personal access token for a user with admin rights to the organization\n* `CONTACT_EMAIL` - Point of contact to point users to if something goes wrong\n\n### Customizing the validator\n\nFor Add to Org to work, you'll also need to define a custom validator. You can do this in your `configu.ru`, or in a separate file included into `config.ru`. Here's an example of a validator that confirms the user has a verified `@github.com` email address:\n\n```ruby\nrequire 'add-to-org'\n\nAddToOrg.set_validator do |github_user, verified_emails, client|\n  verified_emails.any? { |email| email[:email] =~ /@github\\.com\\z/ }\nend\n\nrun AddToOrg::App\n```\n\nIf you prefer, you can also pass the validator as a proc (or lambda):\n\n```ruby\nAddToOrg.validator = proc { |github_user, verified_emails, client|\n  verified_emails.any? { |email| email[:email] =~ /@github\\.com\\z/ }\n}\n```\n\nThe validator will receive three  arguments to help you validate the user meets your criteria:\n\n* `github_user` - the Warden user, which will contain information like username, company, and human-readable name\n* `verified_emails` - an array of the user's verified emails\n* `client` - An [Octokit.rb](https://github.com/octokit/octokit.rb) client, preset with the user's OAuth token.\n\nThe validator should return `true` if you'd like the current user added to the organization, or `false` if you'd like the user's request to be denied.\n\n### Customizing Views\n\nThere are three views, `success`, `forbidden`, and `error`. They're pretty boring by default, so you may want to swap them out for something a bit my snazzy. If you had a views directory along side your `config.ru`, you can do so like this in your `config.ru` file:\n\n```ruby\nrequire 'add-to-org'\n\nAddToOrgs.views_dir = File.expand_path(\"./views\", File.dirname(__FILE__))\n\nrun AddToOrg::App\n```\n\nThese are just sinatra `.erb` views. Take a look at [the default views](https://github.com/benbalter/add-to-org/tree/master/lib/add-to-org/views) for an example.\n\n### Customizing static assets\n\nYou can also do the same with `AddToOrg.public_dir` for serving static assets (AddToOrg comes bundled with Bootstrap by default).\n\n```ruby\nrequire 'add-to-org'\n\nAddToOrgs.public_dir = File.expand_path(\"./public\", File.dirname(__FILE__))\n\nrun AddToOrg::App\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenbalter%2Fadd-to-org","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenbalter%2Fadd-to-org","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenbalter%2Fadd-to-org/lists"}