Documentation/content/security/2fa.md

81 lines
3.8 KiB
Markdown
Raw Normal View History

2020-08-29 11:14:14 +00:00
---
eleventyNavigation:
key: 2FA
title: Setting up Two-factor Authentication
parent: Security
---
## Why Two-factor Authentication?
2020-10-13 14:25:26 +00:00
While it is important to have a strong password, to gain extra security, e.g. in case your password or device ever gets compromised, it is a good idea to configure Two-factor Authentication for your account.
2020-08-29 11:14:14 +00:00
2020-10-13 14:25:26 +00:00
With Two-factor Authentication, you will be asked for an authentication code generated using your phone in addition to your password when logging into Codeberg.
2020-08-29 11:44:30 +00:00
2020-10-13 14:25:26 +00:00
That way, your account cannot be compromised even if your password does get compromised, as long as your phone stays safe.
2020-08-29 11:44:30 +00:00
2020-08-29 11:14:14 +00:00
## How to set up Two-factor Authentication
### Prerequisites
You will need an authenticator app installed on your phone.
2020-10-13 14:25:26 +00:00
If you don't already have an authenticator app and you're not sure which app to use, have a look at Aegis Authenticator
2020-09-21 08:32:44 +00:00
([F-Droid](https://f-droid.org/de/packages/com.beemdevelopment.aegis/) | [Google Play Store](https://play.google.com/store/apps/details?id=com.beemdevelopment.aegis&hl=en_US)) or Authenticator ([App Store](https://itunes.apple.com/app/authenticator/id766157276)).
2020-08-29 11:14:14 +00:00
### Step 1: Navigate to your user settings
<picture>
<source srcset="/assets/images/security/user-settings.webp" type="image/webp">
<img src="/assets/images/security/user-settings.png" alt="User Settings">
</picture>
2020-08-29 11:14:14 +00:00
### Step 2: Navigate to the Security tab and click on the Enroll button
<picture>
<source srcset="/assets/images/security/2fa/security-settings.webp" type="image/webp">
<img src="/assets/images/security/2fa/security-settings.png" alt="Security Settings">
</picture>
2020-08-29 11:14:14 +00:00
### Step 3: Scan the QR code and enter the verification code
<picture>
<source srcset="/assets/images/security/2fa/qr-scan.webp" type="image/webp">
<img src="/assets/images/security/2fa/qr-scan.jpg" alt="Scanning QR Code">
</picture>
2020-08-29 11:14:14 +00:00
2020-10-16 14:43:55 +00:00
After scanning the QR code with your app, enter the six-digit code displayed in your app into the "Passcode" field of the settings form, then click "Verify".
2020-08-29 11:14:14 +00:00
### Step 4: Store your scratch token in a safe place
2020-10-13 14:25:26 +00:00
If your phone ever breaks, get lost or stolen, you can recover your account using the scratch token.
2020-08-29 11:14:14 +00:00
That token is showed to you right after setting up 2FA:
<picture>
<source srcset="/assets/images/security/2fa/scratch-token.webp" type="image/webp">
<img src="/assets/images/security/2fa/scratch-token.png" alt="Scratch token">
</picture>
2020-08-29 11:14:14 +00:00
Please store that token in a safe place.
### Step 5: Done!
That's it - you have now configured 2FA for your account.
2020-10-13 14:25:26 +00:00
From now on, each time you log into Codeberg, you will be asked for an authentication code from your app, adding a layer of security over using only a password.
## Personal access token
2020-10-16 14:43:55 +00:00
If you push via HTTP (see [Clone & Commit via HTTP](/git/clone-commit-via-http)), an extra step will be needed to create a personal access token. This token will replace your normal password (+ authentication code) on Codeberg.
2020-10-13 14:25:26 +00:00
2020-10-16 14:43:55 +00:00
In your profile settings on Codeberg.org, go to the `Applications` tab.
In the section `Manage Access Tokens`, add a `Token Name` and confirm by clicking on the green `Generate Token`.
2020-10-13 14:25:26 +00:00
<picture>
<source srcset="/assets/images/security/2fa/applications.webp" type="image/webp">
<img src="/assets/images/security/2fa/applications.png" alt="applications">
</picture>
2020-10-14 07:41:46 +00:00
Make sure you save the generated token in a safe place, because it will not be shown again.
2020-10-13 14:25:26 +00:00
<picture>
<source srcset="/assets/images/security/2fa/token-created.webp" type="image/webp">
<img src="/assets/images/security/2fa/token-created.png" alt="token-created">
</picture>
When asked for your password, just supply the token.
2020-10-16 14:43:55 +00:00
You can create as many token as you like: one for each computer, one for each Git client, one for each session... you decide! You can also revoke tokens at any time by pressing the red `Delete` next to the token (see previous screenshot).