mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-06 03:26:44 +03:00
2.7 KiB
2.7 KiB
Keycloak SSO Setup for Gitea Mirror
1. Access Keycloak Admin Console
- Open http://localhost:8080
- Login with:
- Username:
admin - Password:
admin
- Username:
2. Create a New Realm (Optional)
- Click on the realm dropdown (top-left, probably says "master")
- Click "Create Realm"
- Name it:
gitea-mirror - Click "Create"
3. Create a Client for Gitea Mirror
- Go to "Clients" in the left menu
- Click "Create client"
- Fill in:
- Client type:
OpenID Connect - Client ID:
gitea-mirror - Name:
Gitea Mirror Application
- Client type:
- Click "Next"
- Enable:
- Client authentication:
ON - Authorization:
OFF - Standard flow:
ON - Direct access grants:
OFF
- Client authentication:
- Click "Next"
- Set the following URLs:
- Root URL:
http://localhost:4321 - Valid redirect URIs:
http://localhost:4321/api/auth/sso/callback/keycloak - Valid post logout redirect URIs:
http://localhost:4321 - Web origins:
http://localhost:4321
- Root URL:
- Click "Save"
4. Get Client Credentials
- Go to the "Credentials" tab of your client
- Copy the "Client secret"
5. Configure Keycloak SSO in Gitea Mirror
- Go to your Gitea Mirror settings: http://localhost:4321/settings
- Navigate to "Authentication" → "SSO Settings"
- Click "Add SSO Provider"
- Fill in:
- Provider ID:
keycloak - Issuer URL:
http://localhost:8080/realms/master(orhttp://localhost:8080/realms/gitea-mirrorif you created a new realm) - Client ID:
gitea-mirror - Client Secret: (paste the secret from step 4)
- Email Domain: Leave empty or set a specific domain to restrict access
- Scopes: Select the scopes you want to test:
openid(required)profileemailoffline_access(Keycloak supports this!)
- Provider ID:
6. Optional: Create Test Users in Keycloak
- Go to "Users" in the left menu
- Click "Add user"
- Fill in:
- Username:
testuser - Email:
testuser@example.com - Email verified:
ON
- Username:
- Click "Create"
- Go to "Credentials" tab
- Click "Set password"
- Set a password and turn off "Temporary"
7. Test SSO Login
- Logout from Gitea Mirror if you're logged in
- Go to the login page: http://localhost:4321/login
- Click "Continue with SSO"
- Enter the email address (e.g.,
testuser@example.com) - You'll be redirected to Keycloak
- Login with your Keycloak user credentials
- You should be redirected back to Gitea Mirror and logged in!
Troubleshooting
- If you get SSL/TLS errors, make sure you're using the correct URLs (http for both Keycloak and Gitea Mirror)
- Check the browser console and network tab for any errors
- Keycloak logs:
docker logs gitea-mirror-keycloak - The
offline_accessscope should work with Keycloak (unlike Google)