Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions for Keycloak #341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions manual/deploy/oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,47 @@ OAUTH_ATTRIBUTE_MAP = {
```

Please see [this tutorial](https://forum.seafile.com/t/oauth-authentification-against-microsoft-office365-azure-cloud/7999) for the complete deployment process of OAuth against Azure Cloud.

#### Sample settings for Keycloak

In order to set up Keycloak for use with Seafile, we'll need to create a client for it in a realm. To do that, create a client with the following settings:

- Client type: OpenID Connect

- Client ID: Anything you like, as long as it's unique within the realm

- Client authentication: On

- Authentication flow: Standard flow

- Root URL: https://your-seafile

- Home URL: /accounts/login

- Valid redirect URLs: /oauth/callback/

- Web origins: https://your-seafile

After creating the client, we'll need to copy the Client Secret from the Credentials tab on the client and save it somewhere. After we have this information, we can add the following to `seahub_settings.py`:

```python
ENABLE_OAUTH = True
OAUTH_CREATE_UNKNOWN_USER = True
OAUTH_ACTIVATE_USER_AFTER_CREATION = True
OAUTH_CLIENT_ID = "your-client-id"
OAUTH_CLIENT_SECRET = "your-client-secret"
OAUTH_REDIRECT_URL = "https://your-seafile/oauth/callback/"

OAUTH_PROVIDER_DOMAIN = 'your-seafile'
OAUTH_AUTHORIZATION_URL = 'https://your-keycloak/realms/YOUR-KEYCLOAK-REALM/protocol/openid-connect/auth'
OAUTH_TOKEN_URL = 'https://your-keycloak/realms/YOUR-KEYCLOAK-REALM/protocol/openid-connect/token'
OAUTH_USER_INFO_URL = 'https://your-keycloak/realms/YOUR-KEYCLOAK-REALM/protocol/openid-connect/userinfo'
OAUTH_SCOPE = ["openid", "profile", "email"]
OAUTH_ATTRIBUTE_MAP = {
"sub": (True, "uid"),
"email": (False, "contact_email"),
"name": (False, "name")
}
```

See [this forum post](https://forum.seafile.com/t/setting-up-keycloak-for-sso/22520) for additional information including screenshots.