Skip to content

Commit

Permalink
Adding latest updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tnylea committed Jun 1, 2024
1 parent bf00762 commit c1118ad
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 503 deletions.
Binary file added assets/images/2fa-setup.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/social-providers-screen.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
154 changes: 10 additions & 144 deletions content/docs/config/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,158 +14,24 @@ The DevDojo Auth package includes several configuration files that allow you to

### 1. appearance.php

This file allows you to customize the look and feel of the authentication pages.

#### Example Configuration:

```php
return [
'logo' => '/path/to/logo.png',
'background_color' => '#f8f9fa',
'primary_color' => '#007bff',
'font' => 'Roboto, sans-serif',
];
```

### 2. descriptions.php

This file contains descriptions used in the authentication process, allowing you to modify them as needed.

#### Example Configuration:
This file allows you to customize the look and feel of the authentication pages. You may manually modify this file if you would like to make any updates, but it's easier to make those changes from the Auth Setup page.

```php
return [
'login' => 'Please enter your login credentials',
'register' => 'Create a new account',
];
```
### 2. language.php

### 3. fields.php
This file contains the language copy that will be used throughout your authentication. You can modify the tone of your copy to sound more like you.

Define custom fields for user registration and other forms in this configuration file.
### 3. providers.php

#### Example Configuration:
This is a list of all the available providers you can include in your authentication. When you toggle the network on/off it will change the `active` value to true/false and will show/hide that network in your authentication.

```php
return [
'registration' => [
'username' => [
'type' => 'text',
'label' => 'Username',
'required' => true,
],
'phone' => [
'type' => 'text',
'label' => 'Phone Number',
'required' => false,
],
],
];
```
If you see some additional providers available from the <a href="https://socialiteproviders.com/" target="_blank">Socialite Providers website</a>, but it's not listed in this config. You may manually add it to the array and it will show up in the Auth Setup page allowing you to enable/disable that social network.

### 4. language.php
### 4. settings.php

Configure language settings and translations for your authentication pages.
This file contains settings that will change the way your authenticaiton functions.

#### Example Configuration:
> You'll also notice a descriptions.php file, which is only used internally in the Auth Setup pages, so this file can be ignored on your part.
```php
return [
'default' => 'en',
'available' => ['en', 'es', 'fr'],
];
```

### 5. pages.php

Manage the settings for the various authentication pages.

#### Example Configuration:

```php
return [
'login' => [
'title' => 'Login',
'description' => 'Please login to your account',
],
'register' => [
'title' => 'Register',
'description' => 'Create a new account',
],
];
```

### 6. providers.php

Set up third-party OAuth providers for social authentication.

#### Example Configuration:

```php
return [
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
],
'facebook' => [
'client_id' => env('FACEBOOK_CLIENT_ID'),
'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
],
];
```

### 7. settings.php

General settings for the authentication package, including enabling features like two-factor authentication (2FA).

#### Example Configuration:

```php
return [
'2fa' => [
'enabled' => true,
'secret_key_length' => 16,
],
];
```

## Making Changes via /auth/setup

When you visit the `/auth/setup` page, you can customize the various settings for the DevDojo Auth package. The changes you make on this page will be automatically reflected in the corresponding configuration files within the `config/devdojo/auth` directory.

### Example Workflow:

1. **Visit the `/auth/setup` Page:**
Navigate to the `/auth/setup` page in your browser. Here, you will find options to customize the appearance, fields, language, and other settings for your authentication pages.

2. **Make Changes:**
Adjust the settings according to your preferences. For example, you can change the logo, update the primary color, or enable additional registration fields.

3. **Save Changes:**
Once you save your changes, they will be written to the corresponding configuration files in the `config/devdojo/auth` directory. For instance, if you update the primary color, this change will be reflected in the `appearance.php` file.

## Additional Information

### Environment Variables

For sensitive information such as API keys and client secrets, it is recommended to use environment variables. The DevDojo Auth package uses the `env` function to retrieve these values from your `.env` file.

### Example .env Configuration:

```
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
FACEBOOK_CLIENT_ID=your-facebook-client-id
FACEBOOK_CLIENT_SECRET=your-facebook-client-secret
```

### Customization Flexibility

The DevDojo Auth package provides a high level of customization flexibility through its configuration files. This allows you to tailor the authentication process to fit the specific needs of your application and users.

## Conclusion

By understanding and utilizing the configuration files provided by the DevDojo Auth package, you can easily customize and manage the authentication experience in your application. The `/auth/setup` page provides a user-friendly interface for making these changes, ensuring that your configurations are always up to date and reflecting your preferences.
Remember, you can make modifications to these configs manually or via the Auth Setup, but it's probably best practice to modify it in the setup page to prevent any conflicts from future releases.


167 changes: 11 additions & 156 deletions content/docs/config/github-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,171 +8,26 @@ description: DevDojo Auth ships with a Github action that can help gaurantee tha

## Introduction

The DevDojo Auth package includes a GitHub Action workflow that helps you ensure your application is fully functional. This workflow is designed to automate the testing process, running tests on every push and pull request to your repository. By integrating this workflow, you can guarantee that your application remains reliable and any changes made do not break existing functionality.
This package includes a GitHub Action workflow that helps you ensure your authentication is fully functional. This action will run every time you make a new pull request to be merged into the `main` branch. If all the checks pass in the workflow you know that your authentication is fully operational.

## Workflow Overview
## Publish the CI Workflow File

### Location
In order to get the Github Action published to your project you will need to run the following command:

The workflow file is located in the `.github/workflows/tests.yml` directory of your repository.
<div class="p-5 font-mono whitespace-break-spaces bg-white/[6%] rounded-xl border border-white/[8%]"><span class="text-pink-400">php</span> <span class="text-green-400">artisan</span> <span class="text-yellow-400">vendor:publish</span> <span class="text-[#b4fd4f]">--tag=auth:ci</span></div>

### Purpose
This will place a new file located inside your application at `.github/workflows/auth.yml`

The primary purpose of this workflow is to automate the testing process. It runs tests in a clean environment to verify that your application works as expected. This helps catch issues early in the development process, reducing the chances of bugs making it to production.
## Workflow Errors

## How the Workflow Works
If you receive Authentication errors when pushing new code you may want to run the tests locally so that way you can debug what is going on. Run the following command:

### Trigger Events

The workflow is triggered on the following events:
- `push`: Runs the workflow on every push to the repository.
- `pull_request`: Runs the workflow on every pull request.

### Workflow Steps

The workflow consists of several steps, each performing specific tasks to set up the environment and run the tests.

#### Example Workflow Configuration:

```yaml
name: Run tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Copy .env file
run: cp .env.example .env

- name: Generate application key
run: php artisan key:generate

- name: Run migrations
run: php artisan migrate

- name: Run tests
run: php artisan test
```
### Step-by-Step Breakdown
1. **Checkout Code:**
```yaml
- name: Checkout code
uses: actions/checkout@v2
```
This step checks out your repository code so that the workflow can access it.
2. **Set Up PHP:**
```yaml
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
```
This step sets up the PHP environment, specifying the PHP version to use.
3. **Install Dependencies:**
```yaml
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
```
This step installs the PHP dependencies required for your application.
4. **Copy .env File:**
```yaml
- name: Copy .env file
run: cp .env.example .env
```
This step copies the example environment file to create the `.env` file.

5. **Generate Application Key:**
```yaml
- name: Generate application key
run: php artisan key:generate
```
This step generates the application key required by Laravel.

6. **Run Migrations:**
```yaml
- name: Run migrations
run: php artisan migrate
```
This step runs the database migrations to set up the database schema.

7. **Run Tests:**
```yaml
- name: Run tests
run: php artisan test
```
This step runs the application tests to ensure everything is working correctly.

## Additional Information

### Customizing the Workflow

You can customize the workflow to fit the specific needs of your project. For example, you might want to test against multiple PHP versions or include additional setup steps for services like MySQL or Redis.

### Example: Testing Against Multiple PHP Versions

```yaml
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4', '8.0', '8.1']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: \${{ matrix.php-version }}
# ... remaining steps
```

### Example: Adding MySQL Service

```yaml
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
options: >-
--health-cmd "mysqladmin ping --silent"
--health-interval 10s
--health-timeout 5s
--health-retries 3
ports:
- 3306:3306
steps:
- name: Wait for MySQL
run: dockerize -wait tcp://localhost:3306 -timeout 1m
./vendor/bin/pest ./vendor/devdojo/auth/tests
```

### Conclusion
This will attempt to run your tests locally.

By integrating the GitHub Action workflow provided by the DevDojo Auth package, you can automate your testing process and ensure that your application remains functional with every change. Customizing the workflow allows you to tailor it to the specific needs of your project, providing flexibility and robustness in your CI/CD pipeline.
## Troubleshooting

If you find an error in the CI workflow you may open an Issue on Github; however, if the issue is related directly to your specific setup we may end up closing the issue as it might be out of scope for the support we'll provide.
Loading

0 comments on commit c1118ad

Please sign in to comment.