# #3 Switching Authentication Method in BookStack

If you choose to use Google authentication, you need to manually switch the authentication method to standard to log in as a local admin and enable user registration. Then turn in back to OIDC. 

# 📌 One-Time Setup for Google Authentication

### Follow these steps:

##### **Step 1: Connect to Your EC2 Instance**

1\. Go to the <span class="s1">**AWS Console**</span> → <span class="s1">**EC2**</span>.

2\. Locate your <span class="s1">**BookStack instance**</span> (named something like `<span class="s2">bookstack-dev-asg-instance</span>`).

3\. Use <span class="s1">**Systems Manager**</span> to connect to the instance. In new window appear, enter in prompt: `sudo su - ec2-user` and hit enter

```bash
sh-5.2$ sudo su - ec2-user

Last login: Wed Feb 26 07:36:32 UTC 2025 on pts/1

Welcome to your EC2 instance!

-----------------------------

Operating System: GNU/Linux

Hostname: ip-172-31-42-121.ec2.internal

Current Date and Time: Wed Feb 26 08:33:35 UTC 2025
```

##### **Step 2: Modify the Authentication Method**

In the **<span class="s1">.env</span>** file, change the authentication method from <span class="s2">**OIDC**</span> to <span class="s2">**Standard**</span> by modifying or adding the following lines:

```yaml
nano bookstack/.env
#AUTH_METHOD="oidc" # comment in or edit exist line
AUTH_METHOD="standard" # or add the new one with value =standard 
```

Save and exit the file.

##### **Step 3: Restart BookStack**

Run the following command to restart the BookStack service:

```bash
docker-compose --env-file bookstack/.env -f bookstack/docker-compose.yml up -d

# After a few seconds, you should see:
[+] Running 1/1
✔ Container bookstack  Started   
```

##### **Step 4: Log in as Admin**

Now, access BookStack through your <span class="s1">**AppURL**</span> and log in using the default credentials:

<span class="s2"> • </span><span class="s1">**Email:**</span> `admin@admin.com`

<span class="s2"> • </span>**Password:** `<span class="s3">password</span>`

##### **Step 5: Enable User Registration**

1\. Click on <span class="s1">**Settings**</span> in the top navigation bar.

[![bookstack settings.png](https://wiki.devsecopsinc.io/uploads/images/gallery/2025-03/scaled-1680-/bookstack-settings.png)](https://wiki.devsecopsinc.io/uploads/images/gallery/2025-03/bookstack-settings.png "bookstack-settings.png")

<span class="s2"> 2. Under </span>**Categories**<span class="s2">, select </span>**Registration**<span class="s2">.</span>

<span class="s2"> 3. Check </span>**Enable Registration**<span class="s2">.</span>

4\. In <span class="s1">**Default user role after registration**</span>, select <span class="s1">**Viewer**</span>.

[![bookstack registration.jpeg](https://wiki.devsecopsinc.io/uploads/images/gallery/2025-03/scaled-1680-/bookstack-registration.jpeg)](https://wiki.devsecopsinc.io/uploads/images/gallery/2025-03/bookstack-registration.jpeg "bookstack-registration.jpeg")

<span class="s2"> 5. Click </span>**Save Settings**<span class="s2">.</span>

6\. Click on **Users** tab. Choose user which you want to make an admin role.

[![Bookstack users.png](https://wiki.devsecopsinc.io/uploads/images/gallery/2025-03/scaled-1680-/bookstack-users.png)](https://wiki.devsecopsinc.io/uploads/images/gallery/2025-03/bookstack-users.png "bookstack-users.png")

7\. Select Admin role and click <span style="background-color: rgb(35, 111, 161); color: rgb(0, 0, 0);">**Save**</span>.

[![Bookstack edit profile.png](https://wiki.devsecopsinc.io/uploads/images/gallery/2025-03/scaled-1680-/bookstack-edit-profile.png)](https://wiki.devsecopsinc.io/uploads/images/gallery/2025-03/bookstack-edit-profile.png "bookstack-edit-profile.png")

<span class="s2">  
</span>

##### **Step 6: Switch Back to OIDC Authentication**

Now that user registration is enabled, repeat <span class="s1">**Step 2**</span>, but this time set the authentication method back to **OIDC**:

```bash
nano bookstack/.env
AUTH_METHOD="oidc" # uncomment or edit exist line
```

Save the file and restart BookStack again:

```bash
docker-compose --env-file bookstack/.env -f bookstack/docker-compose.yml up -d

[+] Running 1/1

✔ Container bookstack  Started
```

<span style="color: rgb(224, 62, 45);">**⚠ Important Notice!** </span>Don’t worry! If something goes wrong, the <span class="s1">**Auto Scaling Group**</span> will detect the issue and recreate the instance with default settings.