Skip to content

Commit c0dd0f9

Browse files
NimaBoscarinostevhliuosanseviero
authored
Docs Revamp: Organizations and Security (#150)
Add docs for organizations, security, API Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
1 parent 1e26793 commit c0dd0f9

12 files changed

+325
-1
lines changed
120 KB
Loading

docs/assets/hub/security-soc-1.jpeg

40.4 KB
Loading

docs/hub/_sections.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@
1111
title: Spaces
1212

1313
- local: datasets-main
14-
title: Datasets
14+
title: Datasets
15+
16+
- local: organizations-main
17+
title: Organizations
18+
19+
- local: security-main
20+
title: Security
21+
22+
- local: api-main
23+
title: Hub API Endpoints

docs/hub/api-main.md

+48
Large diffs are not rendered by default.

docs/hub/organizations-cards.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Organization cards
3+
---
4+
5+
<h1>Organization cards</h1>
6+
7+
You can create an organization card to help users learn more about what your organization is working on and how users can use your libraries, models, datasets, and Spaces.
8+
9+
An organization card is displayed on an organization's profile:
10+
11+
![/docs/assets/hub/org-card.png](/docs/assets/hub/org-card.png)
12+
13+
14+
If you're a member of an organization, you'll see a button to create or edit your organization card on the organization's main page. Organization cards are a `README.md` static file inside a Space repo named `README`. The card can be as simple as Markdown text, or you can create a more customized appearance with HTML.
15+
16+
The card for the [Hugging Face Course organization](https://huggingface.co/huggingface-course), shown above, [contains the following HTML](https://huggingface.co/spaces/huggingface-course/README/blob/main/README.md):
17+
18+
```html
19+
<p>
20+
This is the organization grouping all the models and datasets used in the <a href="https://huggingface.co/course/chapter1" class="underline">Hugging Face course</a>.
21+
</p>
22+
```
23+
24+
For more examples, take a look at:
25+
26+
* [Amazon's](https://huggingface.co/spaces/amazon/README/blob/main/README.md) organization card source code
27+
* [spaCy's](https://huggingface.co/spaces/spacy/README/blob/main/README.md) organization card source code.

docs/hub/organizations-main.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Organizations
3+
---
4+
5+
<h1>Organizations</h1>
6+
7+
The Hugging Face Hub offers **Organizations**, which can be used to group accounts and manage datasets, models, and Spaces. The Hub also allows admins to set user roles to [**control access to repositories**](./organizations-security) and manage their organization's [subscription](https://huggingface.co/pricing).
8+
9+
If an organization needs to track user access to a dataset due to licensing or privacy issues, an organization can enable [user access requests](./datasets-gated).
10+
11+
## Contents
12+
13+
- [Managing Organizations](./organizations-managing)
14+
- [Organization Cards](./organizations-cards)
15+
- [Access Control in Organizations](./organizations-security)

docs/hub/organizations-managing.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Managing organizations
3+
---
4+
5+
<h1>Managing organizations</h1>
6+
7+
## Creating an organization
8+
9+
Visit the [New Organization](https://hf.co/organizations/new) form to create an organization.
10+
11+
## Managing members
12+
13+
New members can be added to an organization by visiting the **Organization settings** and clicking on the **Members** tab. There, you'll be able to generate an invite link, add members individually, or send out email invitations in bulk. If the **Allow requests to join from the organization page** setting is enabled, you'll also be able to approve or reject any pending requests on the **Members** page.
14+
15+
![The "Members" panel for an Organization](/docs/assets/hub/organizations-members.png)
16+
17+
You can also revoke a user's membership or change their role on this page.
18+
19+
## Organization domain name
20+
21+
Under the **Account** tab in the Organization settings, you can set an **Organization domain name**. Specifying a domain name will allow any user with a matching email address on the Hugging Face Hub to join your organization.

docs/hub/organizations-security.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Access control in organizations
3+
---
4+
5+
<h1>Access control in organizations</h1>
6+
7+
Members of organizations can have three different roles: `read`, `write` or `admin`:
8+
9+
- `read`: read-only access to the Organization's repos and metadata/settings (eg, the Organization's profile, members list, API token, etc).
10+
11+
- `write`: additional write rights to the Organization's repos. Users can create, delete or rename any repo in the Organization namespace. A user can also edit and delete files from the browser editor and push content with `git`.
12+
13+
- `admin`*: in addition to write rights on repos, admin members can update the Organization's profile, refresh the Organization's API token, and manage Organization members.
14+
15+
As an organization `admin`, go to the **Members** section of the org settings to manage roles for users.
16+
17+
![/docs/assets/hub/org-members-page.png](/docs/assets/hub/org-members-page.png)

docs/hub/security-gpg.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Signing commits with GPG
3+
---
4+
5+
<h1>Signing commits with GPG</h1>
6+
7+
`git` has an authentication layer to control who can push commits to a repo, but it does not authenticate the actual commit authors.
8+
9+
In other words, you can commit changes as `Elon Musk <elon@tesla.com>`, push them to your preferred `git` host (for instance github.com), and your commit will link to Elon's GitHub profile. (Try it! But don't blame us if Elon gets mad at you for impersonating him.)
10+
11+
The reasons we implemented GPG signing were:
12+
- To provide finer-grained security, especially as more and more Enterprise users rely on the Hub.
13+
- To provide ML benchmarks backed by a cryptographically-secure source.
14+
15+
See Ale Segala's [How (and why) to sign `git` commits](https://withblue.ink/2020/05/17/how-and-why-to-sign-git-commits.html) for more context.
16+
17+
You can prove a commit was authored by you with GNU Privacy Guard (GPG) and a key server. GPG is a cryptographic tool used to verify the authenticity of a message's origin. We'll explain how to set this up on Hugging Face below.
18+
19+
The Pro Git book is, as usual, a good resource about commit signing: [Pro Git: Signing your work](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work).
20+
21+
## Setting up signed commits verification
22+
23+
You will need to install [GPG](https://gnupg.org/) on your system in order to execute the following commands.
24+
> It's included by default in most Linux distributions.
25+
> On Windows, it is included in Git Bash (which comes with `git` for Windows).
26+
27+
You can sign your commits locally using [GPG](https://gnupg.org/).
28+
Then configure your profile to mark these commits as **verified** on the Hub,
29+
so other people can be confident that they come from a trusted source.
30+
31+
For a more in-depth explanation of how git and GPG interact, please visit the the [git documentation on the subject](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work)
32+
33+
Commits can have the following signing statuses:
34+
35+
| Status | Explanation |
36+
| ----------------- | ------------------------------------------------------------ |
37+
| Verified | The commit is signed and the signature is verified |
38+
| Unverified | The commit is signed but the signature could not be verified |
39+
| No signing status | The commit is not signed |
40+
41+
For a commit to be marked as **verified**, you need to upload the public key used to sign it on your Hugging Face account.
42+
43+
Use the `gpg --list-secret-keys` command to list the GPG keys for which you have both a public and private key.
44+
A private key is required for signing commits or tags.
45+
46+
If you don't have a GPG key pair or you don't want to use the existing keys to sign your commits, go to **Generating a new GPG key**.
47+
48+
Otherwise, go straight to [Adding a GPG key to your account](#adding-a-gpg-key-to-your-account).
49+
50+
## Generating a new GPG key
51+
52+
To generate a GPG key, run the following:
53+
54+
```bash
55+
gpg --gen-key
56+
```
57+
58+
GPG will then guide you through the process of creating a GPG key pair.
59+
60+
Make sure you specify an email address for this key, and that the email address matches the one you specified in your Hugging Face [account](https://huggingface.co/settings/account).
61+
62+
## Adding a GPG key to your account
63+
64+
1. First, select or generate a GPG key on your computer. Make sure the email address of the key matches the one in your Hugging Face [account](https://huggingface.co/settings/account) and that the email of your account is verified.
65+
66+
2. Export the public part of the selected key:
67+
68+
```bash
69+
gpg --armor --export <YOUR KEY ID>
70+
```
71+
72+
3. Then visit your profile [settings page](https://huggingface.co/settings/keys) and click on **Add GPG Key**.
73+
74+
Copy & paste the output of the `gpg --export` command in the text area and click on **Add Key**.
75+
76+
4. Congratulations! 🎉 You've just added a GPG key to your account!
77+
78+
## Configure git to sign your commits with GPG
79+
80+
The last step is to configure git to sign your commits:
81+
82+
```bash
83+
git config user.signingkey <Your GPG Key ID>
84+
git config user.email <Your email on hf.co>
85+
```
86+
87+
Then add the `-S` flag to your `git commit` commands to sign your commits!
88+
89+
```bash
90+
git commit -S -m "My first signed commit"
91+
```
92+
93+
Once pushed on the Hub, you should see the commit with a "Verified" badge.

docs/hub/security-main.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Security
3+
---
4+
5+
<h1>Security</h1>
6+
7+
The Hugging Face Hub offers several security features to ensure that your code and data are secure. Beyond offering [private repositories](./repositories-best-practices) for models, datasets, and Spaces, the Hub supports access tokens, commit signatures, and malware scanning.
8+
9+
Hugging Face is also [SOC2 Type 1 certified](https://us.aicpa.org/interestareas/frc/assuranceadvisoryservices/aicpasoc1report.html), meaning we provide security certification to our customers and actively monitor and patch any security weaknesses.
10+
11+
![SOC Type 1 Certification logo](/docs/assets/hub/security-soc-1.jpeg)
12+
13+
## Contents
14+
15+
- [User Access Tokens](./security-tokens)
16+
- [Signing commits with GPG](./security-gpg)
17+
- [Malware Scanning](./security-malware)

docs/hub/security-malware.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Malware Scanning
3+
---
4+
5+
<h1>Malware Scanning</h1>
6+
7+
We run every file of your repositories through a [malware scanner](https://www.clamav.net/).
8+
9+
Scanning is triggered at each commit or when you visit a repository page.
10+
11+
Here is an [example view](https://huggingface.co/mcpotato/42-eicar-street/tree/main) of an infected file:
12+
13+
![/docs/assets/hub/eicar-hub-tree-view.png](/docs/assets/hub/eicar-hub-tree-view.png)
14+
15+
![/docs/assets/hub/eicar-hub-file-view.png](/docs/assets/hub/eicar-hub-file-view.png)
16+
17+
_Note_: if your file has neither an ok nor infected badge, it could mean that it is either currently being scanned, waiting to be scanned, or that there was an error during the scan. It can take up to a few minutes to be scanned.

docs/hub/security-tokens.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: User Access Tokens
3+
---
4+
5+
<h1>User access tokens</h1>
6+
7+
8+
## What are User Access Tokens?
9+
10+
User Access Tokens are the preferred way to authenticate an application or notebook to Hugging Face services. You can manage your access tokens in your [settings](https://huggingface.co/settings/tokens).
11+
12+
![/docs/assets/hub/access-tokens.png](/docs/assets/hub/access-tokens.png)
13+
14+
Access tokens allow applications and notebooks to perform specific actions specified by the scope of the roles shown in the following:
15+
16+
- `read`: tokens with this role can only be used to provide read access to repositories you could read. That includes public and private repositories that you, or an organization you're a member of, own. Use this role if you only need to read content from the Hugging Face Hub (e.g. when downloading private models or doing inference).
17+
18+
- `write`: tokens with this role additionally grant write access to the repositories you have write access to. Use this token if you need to create or push content to a repository (e.g., when training a model or modifying a model card).
19+
20+
## How to manage User Access Tokens?
21+
22+
To create an access token, go to your settings, then click on the [Access Tokens tab](https://huggingface.co/settings/tokens). Click on the **New token** button to create a new User Access Token.
23+
24+
![/docs/assets/hub/new-token.png](/docs/assets/hub/new-token.png)
25+
26+
Select a role and a name for your token and voilà - you're ready to go!
27+
28+
You can delete and refresh User Access Tokens by clicking on the **Manage** button.
29+
30+
![/docs/assets/hub/delete-token.png](/docs/assets/hub/delete-token.png)
31+
32+
## How to use User Access Tokens?
33+
34+
There are plenty of ways to use a User Access Token to access the Hugging Face Hub, granting you the flexibility you need to build awesome apps on top of it.
35+
36+
User Access Tokens can be:
37+
- used **in place of a password** to access the Hugging Face Hub with git or with basic authentication.
38+
- passed as a **bearer token** when calling the [Inference API](https://huggingface.co/inference-api).
39+
- used in the Hugging Face Python libraries, such as `transformers` or `datasets`:
40+
41+
```python
42+
from transformers import AutoModel
43+
44+
access_token = "hf_..."
45+
46+
model = AutoModel.from_pretrained("private/model", use_auth_token=access_token)
47+
```
48+
49+
⚠️ Try not to leak your token! Though you can always rotate it, anyone will be able to read or write your private repos in the meantime which is 💩
50+
51+
### Best practices
52+
53+
We recommend you create one access token per app or usage. For instance, you could have a separate token for:
54+
* A local machine.
55+
* A Colab notebook.
56+
* An awesome custom inference server.
57+
58+
This way, you can invalidate one token without impacting your other usages.
59+
60+
We also recommend only giving the appropriate role to each token you create. If you only need read access (i.e., loading a dataset with the `datasets` library or retrieving the weights of a model), only give your access token the `read` role.

0 commit comments

Comments
 (0)