@@ -6,32 +6,62 @@ sidebar_position: 100
6
6
7
7
# Django Admin
8
8
9
- Since the application is built using Django, it benefits from the django admin pages. Flagsmith is built to utilise the
10
- Django admin site for certain aspects of the platform. If you are self hosting, you may find it useful to access these
11
- pages at certain times.
9
+ The Flagsmith API is a Django application. As such, certain administrative tasks can be performed using
10
+ [ Django's built-in admin interface] ( https://docs.djangoproject.com/en/4.2/ref/contrib/admin/ ) , which we refer to as
11
+ Django Admin.
12
+
13
+ ::: danger
14
+
15
+ Improper use of Django Admin can cause data loss and make your Flagsmith instance unusable. Make sure to control who
16
+ has access, and only perform tasks as directed by Flagsmith staff.
17
+
18
+ :::
19
+
20
+ ## Accessing Django Admin
21
+
22
+ Django Admin can be accessed from the ` /admin/ ` route on the Flagsmith API. Note that the trailing slash is important.
23
+
24
+ Accessing Django Admin requires a user with
25
+ [ ` is_staff ` ] ( https://docs.djangoproject.com/en/4.2/ref/contrib/auth/#django.contrib.auth.models.User.is_staff ) set.
26
+ This does not grant any additional permissions beyond accessing Django Admin itself.
27
+
28
+ A user with
29
+ [ ` is_superuser ` ] ( https://docs.djangoproject.com/en/4.2/ref/contrib/auth/#django.contrib.auth.models.User.is_superuser )
30
+ is granted all permissions. Note that superusers still require ` is_staff ` to access Django Admin.
31
+
32
+ You can obtain a user with these permissions using any of these methods:
33
+
34
+ * Use the [ ` createsuperuser ` management command] ( /deployment/hosting/locally-api#locally ) from a Flagsmith API shell.
35
+ * If no users exist yet,
36
+ [ visit the Initialise Config page] ( /deployment/hosting/locally-api#environments-with-no-direct-console-access-eg-heroku-ecs ) .
37
+ * Manually set the ` is_staff ` and ` is_superuser ` database fields for your user in the ` users_ffadminuser ` table.
12
38
13
39
## Authentication
14
40
15
- The admin pages are only available to uses that are designated as 'super users'. This can only be done when first
16
- setting up the platform or via the database. If you're just starting out, you can follow the instructions
17
- [ here] ( /deployment/hosting/locally-api#initialising ) , otherwise, you need to set the ` is_staff ` and ` is_superuser ` flags
18
- against any of the users in your database.
41
+ You can log in to Django Admin using the same email and password you use to log in to Flagsmith, or using Google login.
42
+
43
+ ### Email and password
44
+
45
+ To log in to Django Admin with a password, make sure the Flagsmith API has the ` ENABLE_ADMIN_ACCESS_USER_PASS `
46
+ environment variable set to ` true ` .
47
+
48
+ If your Flagsmith account does not have a password, you can create one using any of these methods:
19
49
20
- Once you have a user, you can access the django admin pages at ` /admin/ ` . You will be prompted to log in with the
21
- credentials of any of your super users.
50
+ * From the Flagsmith login page, click "Forgot password". Make sure your Flagsmith API is
51
+ [ configured to send emails] ( /deployment/hosting/locally-api#email ) .
52
+ * From a Flagsmith API shell, run
` python manage.py changepassword [email protected] ` and type a password.
22
53
23
- ::: info
54
+ ### Google
24
55
25
- If the login page is only showing the option to 'Log in using SSO' then you may need to set the
26
- ` ENABLE_ADMIN_ACCESS_USER_PASS ` environment variable. See
27
- [ this list] ( /deployment/hosting/locally-api#application-environment-variables ) for more information.
56
+ Google accounts uses OAuth 2.0, which requires TLS.
28
57
29
- :::
58
+ To set up Google authentication for Django Admin, create an OAuth client ID and secret from
59
+ [ Google Developer Console] ( https://console.developers.google.com/project ) . The redirect URI should point to
60
+ ` /admin/admin_sso/assignment/end/ ` on your API domain.
30
61
31
- ## Admin Pages
62
+ Set your Google OAuth client ID and secret in the following Flagsmith API environment variables:
32
63
33
- ### Organisation
64
+ * ` OAUTH_CLIENT_ID `
65
+ * ` OAUTH_CLIENT_SECRET `
34
66
35
- The key pages that one might want to access are the ones that configuration organisations on the platform. From the home
36
- page of the admin, you'll see an link to ` Organisations ` about halfway down the page. From here, you can manage the
37
- organisations on your platform as required. For example, SAML configuration data must be set via these pages.
67
+ To log in with Google, click "Log in using SSO" from the Django Admin login page.
0 commit comments