{"id":22354282,"url":"https://github.com/jonmagic/omniauth-github-team-member","last_synced_at":"2025-07-30T09:31:04.969Z","repository":{"id":6868555,"uuid":"8117542","full_name":"jonmagic/omniauth-github-team-member","owner":"jonmagic","description":"OmniAuth Strategy for GitHub Teams","archived":false,"fork":false,"pushed_at":"2021-02-18T23:19:03.000Z","size":19,"stargazers_count":10,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-15T06:07:45.778Z","etag":null,"topics":[],"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/jonmagic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-10T01:09:08.000Z","updated_at":"2023-10-30T12:21:36.000Z","dependencies_parsed_at":"2022-08-20T14:31:19.873Z","dependency_job_id":null,"html_url":"https://github.com/jonmagic/omniauth-github-team-member","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jonmagic/omniauth-github-team-member","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmagic%2Fomniauth-github-team-member","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmagic%2Fomniauth-github-team-member/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmagic%2Fomniauth-github-team-member/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmagic%2Fomniauth-github-team-member/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonmagic","download_url":"https://codeload.github.com/jonmagic/omniauth-github-team-member/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonmagic%2Fomniauth-github-team-member/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267472633,"owners_count":24092943,"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-07-28T02:00:09.689Z","response_time":68,"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":[],"created_at":"2024-12-04T13:12:12.191Z","updated_at":"2025-07-30T09:31:04.685Z","avatar_url":"https://github.com/jonmagic.png","language":"Ruby","readme":"# OmniAuth GitHub Team Auth\n\nThis is an OmniAuth strategy for authenticating to GitHub and ensuring the user belongs to a specific team. This strategy is useful for building web apps that should only be administered by specific teams. I adapted this from an internal gem at GitHub.\n\nTo use it, you'll need to sign up for an OAuth2 Application ID and Secret on the [GitHub Applications Page](https://github.com/settings/applications).\n\n## Installing\n\nAdd the gem to your Gemfile and bundle.\n\n```\ngem \"omniauth-github-team-member\"\n```\n\nI like to store the GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET in my environment, but you don't have to if you have a preferred place to put keys and secrets. For local development I recommend the [dotenv](https://github.com/bkeepers/dotenv) gem for setting environment variables.\n\n## Basic Usage\n\nIn the examples below, `42634` is the id of the team we are checking against. You can find the id of a team via the GitHub API, either by [listing all teams for the parent org](https://developer.github.com/v3/orgs/teams/#list-teams) or [finding all of the team memberships for a user who is on the team you are looking for](https://developer.github.com/v3/orgs/teams/#get-team-membership).\n\nUsage in Rails:\n\n```ruby\n# config/initializers/github_omniauth.rb\n\nRails.application.config.middleware.use OmniAuth::Builder do\n  provider :githubteammember,\n    ENV['GITHUB_CLIENT_ID'],\n    ENV['GITHUB_CLIENT_SECRET'],\n    scope: 'read:org',\n    teams: {\n      \"mentors_team_member?\" =\u003e 426344\n    }\nend\n```\n\nDuring the callback phase, you can check to see if the authed user is on the mentors team or not by checking the returned credentials object `request.env['omniauth.auth'].credentials.mentors_team_member?`.\n\nAn example of how to integrate this strategy with OmniAuth is below. Do note that these examples are just guidelines, you will most likely need to change each example to match your application's needs.\n\n```ruby\nclass SessionsController\n  def create\n    @user = User.find_for_github_team_oauth(request.env['omniauth.auth'])\n\n    if @user \u0026\u0026 @user.persisted?\n      redirect_to root_path\n    else\n      redirect_to no_access_path\n    end\n  end\nend\n```\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  def self.find_for_github_team_oauth(access_token, signed_in_resource=nil)\n    # Prevents past team members from logging into existing accounts they\n    # created when they were previously a team member. Also ensures\n    # new accounts can't be created unless they are a team member.\n    return false unless access_token.credentials.mentors_team_member?\n\n    info = access_token.info\n    github_id = access_token.uid\n    user = find_or_initialize_by_github_id(github_id)\n\n    if user.new_record?\n      user.name = info.name\n      user.email = info.email\n      user.github_identifier = info.nickname\n      user.save\n    end\n\n    user\n  end\nend\n```\n\nUsage in Sinatra:\n\n```ruby\nuse OmniAuth::Builder do\n  provider :githubteammember,\n    ENV['GITHUB_CLIENT_ID'],\n    ENV['GITHUB_CLIENT_SECRET'],\n    scope: 'read:org',\n    teams: {\n      \"mentors_team_member?\" =\u003e 426344\n    }\nend\n```\n\n### Scopes\n\nYou must require the `read:org` scope to be able to access the team data associated with the authenticated user.\n\nMore info on [Scopes](http://developer.github.com/v3/oauth/#scopes).\n\n## Contributing\n\n1. [Fork it](https://help.github.com/articles/fork-a-repo)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new [Pull Request](https://help.github.com/articles/using-pull-requests)\n\n## Contributors\n\n* [Garrett Bjerkhoel](https://github.com/dewski)\n* [Jonathan Hoyt](https://github.com/jonmagic)\n* [Arthur Chiu](https://github.com/achiu)\n* [Tim Clem](https://github.com/tclem)\n* [Jessie Young](https://github.com/jessieay)\n* [Paul Schreiber](https://github.com/paulschreiber)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonmagic%2Fomniauth-github-team-member","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonmagic%2Fomniauth-github-team-member","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonmagic%2Fomniauth-github-team-member/lists"}