Skip to content

Commit 10319ea

Browse files
authored
docs(github): refactor getting started and auth (#8767)
1 parent 53bb5af commit 10319ea

File tree

8 files changed

+236
-246
lines changed

8 files changed

+236
-246
lines changed

docs/tutorials/github/authentication.md

Lines changed: 192 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,211 @@
1-
# Github Authentication in Prowler
1+
# GitHub Authentication in Prowler
22

33
Prowler supports multiple methods to [authenticate with GitHub](https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api). These include:
44

5-
- **Personal Access Token (PAT)**
6-
- **OAuth App Token**
7-
- **GitHub App Credentials**
5+
- [Personal Access Token (PAT)](./authentication.md#personal-access-token-pat)
6+
- [OAuth App Token](./authentication.md#oauth-app-token)
7+
- [GitHub App Credentials](./authentication.md#github-app-credentials)
88

99
This flexibility enables scanning and analysis of GitHub accounts, including repositories, organizations, and applications, using the method that best suits the use case.
1010

11-
## Supported Login Methods
11+
## Personal Access Token (PAT)
1212

13-
Here are the available login methods and their respective flags:
13+
Personal Access Tokens provide the simplest GitHub authentication method, but it can only access resources owned by a single user or organization.
1414

15-
### Personal Access Token (PAT)
15+
???+ warning "Classic Tokens Deprecated"
16+
GitHub has deprecated Personal Access Tokens (classic) in favor of fine-grained Personal Access Tokens. We recommend using fine-grained tokens as they provide better security through more granular permissions and resource-specific access control.
1617

17-
Use this method by providing your personal access token directly.
18+
#### **Option 1: Create a Fine-Grained Personal Access Token (Recommended)**
1819

19-
```console
20-
prowler github --personal-access-token pat
21-
```
20+
1. **Navigate to GitHub Settings**
21+
- Open [GitHub](https://github.com) and sign in
22+
- Click the profile picture in the top right corner
23+
- Select "Settings" from the dropdown menu
2224

23-
### OAuth App Token
25+
2. **Access Developer Settings**
26+
- Scroll down the left sidebar
27+
- Click "Developer settings"
2428

25-
Authenticate using an OAuth app token.
29+
3. **Generate Fine-Grained Token**
30+
- Click "Personal access tokens"
31+
- Select "Fine-grained tokens"
32+
- Click "Generate new token"
2633

27-
```console
28-
prowler github --oauth-app-token oauth_token
29-
```
34+
4. **Configure Token Settings**
35+
- **Token name**: Give your token a descriptive name (e.g., "Prowler Security Scanner")
36+
- **Expiration**: Set an appropriate expiration date (recommended: 90 days or less)
37+
- **Repository access**: Choose "All repositories" or "Only select repositories" based on your needs
3038

31-
### GitHub App Credentials
32-
Use GitHub App credentials by specifying the App ID and the private key path.
39+
???+ note "Public repositories"
40+
Even if you select 'Only select repositories', the token will have access to the public repositories that you own or are a member of.
3341

34-
```console
35-
prowler github --github-app-id app_id --github-app-key-path app_key_path
36-
```
42+
5. **Configure Token Permissions**
43+
To enable Prowler functionality, configure the following permissions:
3744

38-
### Automatic Login Method Detection
45+
- **Repository permissions:**
46+
- **Administration**: Read-only access
47+
- **Contents**: Read-only access
48+
- **Metadata**: Read-only access
49+
- **Pull requests**: Read-only access
50+
51+
- **Organization permissions:**
52+
- **Administration**: Read-only access
53+
- **Members**: Read-only access
54+
55+
- **Account permissions:**
56+
- **Email addresses**: Read-only access
57+
58+
6. **Copy and Store the Token**
59+
- Copy the generated token immediately (GitHub displays tokens only once)
60+
- Store tokens securely using environment variables
61+
62+
![GitHub Personal Access Token Permissions](./img/github-pat-permissions.png)
3963

40-
If no login method is explicitly provided, Prowler will automatically attempt to authenticate using environment variables in the following order of precedence:
64+
#### **Option 2: Create a Classic Personal Access Token (Not Recommended)**
4165

42-
1. `GITHUB_PERSONAL_ACCESS_TOKEN`
43-
2. `GITHUB_OAUTH_APP_TOKEN`
44-
3. `GITHUB_APP_ID` and `GITHUB_APP_KEY` (where the key is the content of the private key file)
66+
???+ warning "Security Risk"
67+
Classic tokens provide broad permissions that may exceed what Prowler actually needs. Use fine-grained tokens instead for better security.
68+
69+
1. **Navigate to GitHub Settings**
70+
- Open [GitHub](https://github.com) and sign in
71+
- Click the profile picture in the top right corner
72+
- Select "Settings" from the dropdown menu
73+
74+
2. **Access Developer Settings**
75+
- Scroll down the left sidebar
76+
- Click "Developer settings"
77+
78+
3. **Generate Classic Token**
79+
- Click "Personal access tokens"
80+
- Select "Tokens (classic)"
81+
- Click "Generate new token"
82+
83+
4. **Configure Token Permissions**
84+
To enable Prowler functionality, configure the following scopes:
85+
- `repo`: Full control of private repositories (includes `repo:status` and `repo:contents`)
86+
- `read:org`: Read organization and team membership
87+
- `read:user`: Read user profile data
88+
- `security_events`: Access security events (secret scanning and Dependabot alerts)
89+
- `read:enterprise`: Read enterprise data (if using GitHub Enterprise)
90+
91+
5. **Copy and Store the Token**
92+
- Copy the generated token immediately (GitHub displays tokens only once)
93+
- Store tokens securely using environment variables
94+
95+
## OAuth App Token
96+
97+
OAuth Apps enable applications to act on behalf of users with explicit consent.
98+
99+
### Create an OAuth App Token
100+
101+
1. **Navigate to Developer Settings**
102+
- Open GitHub Settings → Developer settings
103+
- Click "OAuth Apps"
104+
105+
2. **Register New Application**
106+
- Click "New OAuth App"
107+
- Complete the required fields:
108+
- **Application name**: Descriptive application name
109+
- **Homepage URL**: Application homepage
110+
- **Authorization callback URL**: User redirection URL after authorization
111+
112+
3. **Obtain Authorization Code**
113+
- Request authorization code (replace `{app_id}` with the application ID):
114+
```
115+
https://github.com/login/oauth/authorize?client_id={app_id}
116+
```
117+
118+
4. **Exchange Code for Token**
119+
- Exchange authorization code for access token (replace `{app_id}`, `{secret}`, and `{code}`):
120+
```
121+
https://github.com/login/oauth/access_token?code={code}&client_id={app_id}&client_secret={secret}
122+
```
123+
124+
## GitHub App Credentials
125+
GitHub Apps provide the recommended integration method for accessing multiple repositories or organizations.
126+
127+
### Create a GitHub App
128+
129+
1. **Navigate to Developer Settings**
130+
- Open GitHub Settings → Developer settings
131+
- Click "GitHub Apps"
132+
133+
2. **Create New GitHub App**
134+
- Click "New GitHub App"
135+
- Complete the required fields:
136+
- **GitHub App name**: Unique application name
137+
- **Homepage URL**: Application homepage
138+
- **Webhook URL**: Webhook payload URL (optional)
139+
- **Permissions**: Application permission requirements
140+
141+
3. **Configure Permissions**
142+
To enable Prowler functionality, configure these permissions:
143+
- **Repository permissions**:
144+
- Contents (Read)
145+
- Metadata (Read)
146+
- Pull requests (Read)
147+
- **Organization permissions**:
148+
- Members (Read)
149+
- Administration (Read)
150+
- **Account permissions**:
151+
- Email addresses (Read)
152+
153+
4. **Where can this GitHub App be installed?**
154+
- Select "Any account" to be able to install the GitHub App in any organization.
155+
156+
5. **Generate Private Key**
157+
- Scroll to the "Private keys" section after app creation
158+
- Click "Generate a private key"
159+
- Download the `.pem` file and store securely
160+
161+
5. **Record App ID**
162+
- Locate the App ID at the top of the GitHub App settings page
163+
164+
### Install the GitHub App
165+
166+
1. **Install Application**
167+
- Navigate to GitHub App settings
168+
- Click "Install App" in the left sidebar
169+
- Select the target account/organization
170+
- Choose specific repositories or select "All repositories"
171+
172+
## Best Practices
173+
174+
### Security Considerations
175+
176+
Implement the following security measures:
177+
178+
- **Secure Credential Storage**: Store credentials using environment variables instead of hardcoding tokens
179+
- **Secrets Management**: Use dedicated secrets management systems in production environments
180+
- **Regular Token Rotation**: Rotate tokens and keys regularly
181+
- **Least Privilege Principle**: Grant only minimum required permissions
182+
- **Permission Auditing**: Review and audit permissions regularly
183+
- **Token Expiration**: Set appropriate expiration times for tokens
184+
- **Usage Monitoring**: Monitor token usage and revoke unused tokens
185+
186+
### Authentication Method Selection
187+
188+
Choose the appropriate method based on use case:
189+
190+
- **Personal Access Token**: Individual use, testing, or simple automation
191+
- **OAuth App Token**: Applications requiring user consent and delegation
192+
- **GitHub App**: Production integrations, especially for organizations
193+
194+
## Troubleshooting Common Issues
195+
196+
### Insufficient Permissions
197+
- Verify token/app has necessary scopes/permissions
198+
- Check organization restrictions on third-party applications
199+
200+
### Token Expiration
201+
- Confirm token has not expired
202+
- Verify fine-grained tokens have correct resource access
203+
204+
### Rate Limiting
205+
- GitHub implements API call rate limits
206+
- Consider GitHub Apps for higher rate limits
207+
208+
### Organization Settings
209+
- Some organizations restrict third-party applications
210+
- Contact organization administrator if access is denied
45211

46-
???+ note
47-
Ensure the corresponding environment variables are set up before running Prowler for automatic detection when not specifying the login method.

0 commit comments

Comments
 (0)