Git Product home page Git Product logo

access-groups's Introduction

access-groups

Test CodeQL XO Code Style Stargazers All Contributors

An action to help determine what groups a user belongs to.

This action does not create any GitHub entities or modify repositories.

Future releases may include a fail-if clause, which would act as a fast fail for that step or job.

Usage

- id: access
  uses: sudojunior/access-groups@main # or specific tag
  
- if: ${{ include(steps.access.outputs.groups, "repo collaborator") }}
  # only run if the user is a repo collaborator
  uses: actions/[email protected]
  with:
    script: |
      await github.issues.createComment({
        issue_number: context.issue.number,
        body: "You're a collaborator on this repository!",
        owner: context.repo.owner,
        repo: context.repo.repo
      })

Arguments

GitHub Token {Future}

Will allow for scope use of context info like organization and sponsors (maybe...).

- id: groups
  uses: sudojunior/access-groups@main
  with:
    github-token: ${{ github.token }} # as default

Output

  • groups is an array of access groups, as explained below.
  • highest-group is the first element from groups.

Explaination of groups

GitHub has a set of adaptive groups that exist under the hood to control permissions per repository and organization.

It is worth noting that the data for the query to determine other groups is there, but may not implemented yet.

Access groups

  • site admin = Covers both public deployment for GitHub Staff and Enterprise Deployment
  • repo owner -> site admin = (If under user scope) is current actor the owner of this repository?
  • repo admin -> site admin = is current actor an admin of this repository?
  • repo maintainer -> repo admin = is current actor a maintainer of this repository?
  • repo triage -> repo maintainer = is current actor a member of the triage team in this repository?
  • repo observer -> repo triage = is current actor an observer to this repository?
  • bounty-hunter = is current actor a bounty hunter?
  • campus-expert = is current actor a campus expert? (may include alumni)
  • developer-program-member = is current actor a developer program member?

Future

Distant Future

Using GraphQL notation, instead of group identifiers.

  • isEmployee = Checks if the actor is a GitHub Employee
  • isHireable = Checks if the actor is Hireable
  • isGitHubStar = Checks if the actor is part of the GitHub Star program
  • repositoriesContributedTo = Checks if the actor has contributed to any repositories *other than their own, unless specified. (quantity required - first or last)

  • Organization Team Member (wildcard)
    Contains child teams, and team roles (MAINTAINER, MEMBER)
    (Dangerous recursion with child teams)

Contributors


Dependabot

๐Ÿšง ๐Ÿ›ก๏ธ

Packages

Known Issues

  • Any file matching to ./tests/**/*.ts has a warning exactly like the one below, it is unknown as to why this is happening - but it does not affect the build process.

    Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
    The file does not match your project config: tests\main.test.ts.
    The file must be included in at least one of the projects provided.

Future consideration

User / Repo context override (via argument)

Currenly open in #22

- uses: sudojunior/access-groups@main
  with:
    user: ${{ github.actor }} # as default
    repo: ${{ github.repository }} # as default

access-groups's People

Contributors

dependabot[bot] avatar mergify[bot] avatar renovate-bot avatar sudojunior avatar

Watchers

 avatar

access-groups's Issues

Access: Triage

Unknown query, check graphql schema / rest response structure.

May require #10 to query this access check.

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Rate Limited

These updates are currently rate limited. Click on a checkbox below to force their creation now.

  • Update dependency prettier to v2.4.1
  • Update dependency @actions/core to v1.6.0
  • Update EndBug/add-and-commit action to v7

  • Check this box to trigger a request for Renovate to run again on this repository

Access: Organization Member

  • Request Endpoint (with authenticated token): either
    • GET /orgs/{org}/members
    • GET /orgs/{org}/members/{username}
  • Request Endpoint (without authenticated token): either
    • GET /orgs/{org}/public_members
    • GET /orgs/{org}/public_members/{username}
  • Path on payload (on list endpoints): ~.*.login
  • Determine if member on check endpoints (~/**/{username}):
    204 if they are, 404 if they aren't.

Referring to a user's membership within an organization.

Argument: endpoint

Future

Links back to #6 with enterprise site admin.

# predefined jobs / steps
- uses: sudojunior/access-check@main
  with:
    endpoint: https://git.example.com/api # defaulting to https://api.github.com

Argument: user

Carefully consider access scope, some modifiers may not work correctly if a user override is provided (i.e. issues, PRs).

Access: Repo Collaborator

May require authenticated token.

  • Request Endpoint: either
    • GET /repos/{owner}/{repo}/collaborators - List (find by ~.*.login)
    • GET /repos/{owner}/{repo}/collaborators/{user}
      204 if they are, 404 if they aren't.

Access: Observer

Specifically for private repositories?

  • Return key: reader / observer / ??

Intention to use GraphQL?

While the rest endpoints are far easier to handle, graphql is far more precise and proves it's worth by showing the schema of the data before you handle the raw data (except for lists / arrays, but they are simple enough to work around).

Example query for the viewer's login, figuring out if nat is a Site Admin #6 and collaborator permissions for TinkerStorm/channel-backup; if they are a Site Admin (again) and if they are a Sponsor.

{
  viewer {
    login
  }
  user(login: "nat") {
    login
    isSiteAdmin
  }
  repository(owner: "TinkerStorm", name: "channel-backup") {
    owner {
      login
    }
    collaborators {
      edges {
        permission
        node {
          viewerIsSponsoring
          login
          isSiteAdmin
        }
      }
    }
  }
}

Access: Repository Owner

  • Path on action: ${{ github.repository_owner }}

Referring to user scope only (possibility to determine if in user or org scope?).

Access: Contributor

Use insight data from ~/:owner/:repo/contributors?
Only first 500 are known.

feat: Query organization teams as wildcards

Unknown at present, query is possible - but not sure if it can be done with the current structure (i.e. it can know if someone is part of a team, but it won't indicate which team(s) they are part of).

Access oriented tests

  • Enterprise Endpoint?
  • Role Accessors
    • site-admin
    • owner (repo)
    • member (org)
    • collaborator (member / org)
    • contributor
    • author (issue / pr)
    • none of the above
    • invalid user
    • campus-expert
    • sponsor (future)

Access: Follower

Can be found on the viewer's side when checking any of the following:

{
  viewer {
    following {
      login
    }
  user(login: $owner) { # repository owner implied
    followers {
      login
    }
  }
}

Access: Author

Unknown query, check graphql schema / rest response structure.

If event is an issue, check github.event.issue.user?

If event is a pull_request, check github.event.pull_request.user?

Access: Collaborator

Unknown query, check graphql schema / rest response structure.

Consider that only the first 500 will be known.

feat: allow a condition to inherit from another?

This idea comes from how the permission structure is handled in organizations in decending order:

  • ADMIN
  • MAINTAIN
  • WRITE
  • TRIAGE
  • READ

Furthermore if the context is in an organization scope, Organization Member may in theory inherit from READ - but there are underlying settings that would cause a problem with this.

Access: Sponsor

Requires #10

  • Return key: sponsor
{
  viewer / user(login: $user) {
    isSponsoredBy(accountLogin: $sponsor) # $sponsor -> $user
    isSponsoringViewer # $user -> (viewer)
    viewerIsSponsoring # (viewer) -> $user
  }
}

Access: Bounty Hunter

Requires #10, implies viewer is current target for query.

  • Return key: bounty-hunter
{
  viewer {
    isBountyHunter
  }
}

Access: Campus Expert

Requires #10, implies viewer is the current target for query.

  • Return key: campus-expert
{
  viewer {
    isCampusExpert
  }
}

Refers to the Campus Experts of GitHub's education program.

PS: Would this also include Campus Advisor

Access: Site admin

  • Request Endpoint: GET /users/${{ github.actor }}
  • Path on payload: ~.site_admin

Site Administrator

Referring to both GitHub Staff and Enterprise Instance Administrators)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.