Skip to content

Commit 612d792

Browse files
Identity system setup improvements (#122)
2 parents 44c1aba + 5d797c7 commit 612d792

12 files changed

Lines changed: 335 additions & 537 deletions

.env.example

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
APP_NAME=Laravel
1+
APP_NAME=Identity
22
APP_ENV=local
3-
APP_KEY=
3+
# its better to generate a new key for every dev environment via `php artisan key:generate`, but just for simplicity I provided a default one
4+
APP_KEY=base64:xoIA1IBbUjD3w1PvYYjakHYrkH3lyHPgy4ctYvAiwAw=
45
APP_DEBUG=true
5-
APP_URL=http://localhost
6+
APP_URL=http://identity.eurofurence.localhost/
7+
8+
## secrets for hashids. you should generate your own via `openssl rand -hex 32` (or any other 32 random symbol string) for each of that
9+
HASHIDS_SALT=f9931717d231b7578668faedccce718c9cc9769af5fdf7ae1b8b3800241fc074
10+
HASHIDS_USER_SALT=5588ab6d9b4ffbaf4e21e93faf6feb612814364c093a56ad440e2df5816e3567
11+
HASHIDS_GROUP_SALT=20890ee95f76d3c8cb334359f2f9842d5fa31d4802e1f0e8dd033756017d979c
612

713
LOG_CHANNEL=stack
814
LOG_LEVEL=debug
915

1016
DB_CONNECTION=mysql
11-
DB_HOST=127.0.0.1
17+
DB_HOST=mysql
1218
DB_PORT=3306
1319
DB_DATABASE=laravel
14-
DB_USERNAME=root
15-
DB_PASSWORD=
20+
DB_USERNAME=sail
21+
DB_PASSWORD=password
1622

1723
BROADCAST_DRIVER=log
18-
CACHE_DRIVER=file
24+
CACHE_DRIVER=redis
1925
FILESYSTEM_DRIVER=local
2026
QUEUE_CONNECTION=sync
2127
SESSION_DRIVER=database
2228
SESSION_LIFETIME=120
2329

24-
MEMCACHED_HOST=127.0.0.1
25-
26-
REDIS_HOST=127.0.0.1
30+
REDIS_HOST=redis
2731
REDIS_PASSWORD=null
2832
REDIS_PORT=6379
2933

@@ -36,16 +40,49 @@ MAIL_ENCRYPTION=null
3640
MAIL_FROM_ADDRESS=null
3741
MAIL_FROM_NAME="${APP_NAME}"
3842

39-
AWS_ACCESS_KEY_ID=
40-
AWS_SECRET_ACCESS_KEY=
41-
AWS_DEFAULT_REGION=us-east-1
42-
AWS_BUCKET=
43-
AWS_USE_PATH_STYLE_ENDPOINT=false
43+
## AWS S3. doesnt need in local unlesss you want to test it
44+
#AWS_ACCESS_KEY_ID=
45+
#AWS_SECRET_ACCESS_KEY=
46+
#AWS_DEFAULT_REGION=us-east-1
47+
#AWS_BUCKET=
48+
#AWS_USE_PATH_STYLE_ENDPOINT=false
4449

45-
PUSHER_APP_ID=
46-
PUSHER_APP_KEY=
47-
PUSHER_APP_SECRET=
50+
PUSHER_APP_ID=ef-identity
51+
PUSHER_APP_KEY=ef-identity
52+
PUSHER_APP_SECRET=some-default-secret-key-for-dev-environment
4853
PUSHER_APP_CLUSTER=mt1
4954

55+
## Hydra settings. empty values will be filled on seding phase
56+
IDENTITY_OPENID_CONFIGURATION=http://identity.eurofurence.localhost/.well-known/openid-configuration
57+
HYDRA_ADMIN_URL=http://hydra:4445/
58+
# 64 symbols hex random string. for simplicity I provided a default one. you should generate a new one for every dev environment via `openssl rand -hex 32` and paste it here
59+
HYDRA_SECRET_KEY=2f8a4f1ad33752b26891beb16ea52640aa080142e77cf2fcd26af08fa25201d3
60+
61+
IDENTITY_PORTAL_CALLBACK_URL=http://identity.eurofurence.localhost/auth/portal/callback
62+
IDENTITY_PORTAL_ID=
63+
IDENTITY_PORTAL_SECRET=
64+
65+
IDENTITY_ADMIN_CALLBACK_URL=http://identity.eurofurence.localhost/auth/admin/callback
66+
IDENTITY_ADMIN_ID=
67+
IDENTITY_ADMIN_SECRET=
68+
69+
IDENTITY_STAFF_CALLBACK_URL=http://identity.eurofurence.localhost/auth/staff/callback
70+
IDENTITY_STAFF_ID=
71+
IDENTITY_STAFF_SECRET=
72+
73+
## sail settings (check out ./infra/dev/image/entrypoint.sh)
74+
#WWWUSER=1000
75+
#WWWGROUP=1000
76+
#WWWUSERNAME=sail
77+
## default command to run dev server
78+
#DEV_SERVER_COMMAND="php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80"
79+
## you can noop it with
80+
#DEV_SERVER_COMMAND="fail -F /dev/null"
81+
## if your dev server is handling requests slow, you can run a octane server instead (does not work for now)
82+
#DEV_SERVER_COMMAND="php artisan octane:start --host=0.0.0.0 --port=80 --watch"
83+
## admin password. used once on database seeding phase
84+
ADMIN_PASSWORD=admin
85+
86+
## values that will be forwarded to the frontend
5087
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
5188
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

README.md

Lines changed: 97 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,104 @@
33
This is a Laravel, IntertiaJS with Vue based application that works as an OIDC Provider.
44

55
## Installation
6-
This project uses [laravel sail](https://laravel.com/docs/11.x/sail) for local development.
6+
7+
You need to have at least docker and docker-compose installed.
8+
Podman is also supported, but you need to set up the podman socket and command to be compatible with docker.
79

810
1. Clone the Repo
9-
2. Run `sail up -d` to start the docker containers.
10-
3. Run `sail artisan migrate`.
11-
4. Run `sail artisan db:seed`.
12-
5. Run `sail npm install`.
13-
6. Run `sail npm run dev`.
14-
7. Add `auth.eurofurence.localhost` and `identity.eurofurence.localhost` to your hosts file and forward them to `127.0.0.1`.
15-
8. You can now go to http://identity.eurofurence.localhost.
16-
17-
### Security
11+
2. Copy `.env.example` to `.env` and set up the environment variables if needed.
12+
`cp .env.example .env`
13+
(you should generate new secret keys, but for simplicity some default ones are provided)
14+
3. Run `docker compose up -d` to start the docker containers.
15+
It may take a while to pull and build images for the first time.
16+
4. Wait when php dependencies are installed and the dev server starts.
17+
It may also take a while depending on your internet connection and computer performance.
18+
You can check the logs with `docker compose logs -f laravel.test`
19+
(`Ctrl+C` here will close logs, but will keep the server running).
20+
5. Setup alias for sail:
21+
```bash
22+
alias sail='./vendor/bin/sail'
23+
```
24+
or use docker-compose directly:
25+
```bash
26+
docker compose exec -it -u sail laravel.test <command>
27+
```
28+
(further commands will have a sail and pure docker-compose version)
29+
6. Run `sail artisan migrate` or `docker compose exec -it -u sail laravel.test php artisan migrate`.
30+
7. Run `sail artisan db:seed` or `docker compose exec -it -u sail laravel.test php artisan db:seed`.
31+
8. Run `sail npm install` or `docker compose exec -it -u sail laravel.test npm install`.
32+
9. Run `sail npm run dev` or `docker compose exec -it -u sail laravel.test npm run dev`.
33+
(you can run this command locally. it may speed up HMR and file watching on some systems)
34+
10. Add `identity.eurofurence.localhost` to your hosts file and forward them to `127.0.0.1`.
35+
11. You can now go to http://identity.eurofurence.localhost.
36+
it may take a while to load first time.
37+
Default credentials are: `identity@eurofurence.localhost`, `admin` (unless you changed them in `.env`).
38+
39+
### Entering laravel container
40+
41+
To enter the laravel container, run `sail shell` or `docker compose exec -it -u sail laravel.test bash`.
42+
43+
### Updating dev environment
44+
45+
To keep your dev environment up to date after merging changes from the main branch or creating a new one, run:
46+
47+
* `sail up -d` or `docker compose up -d` to update container image versions.
48+
* `sail npm install` or `docker compose exec -it -u sail laravel.test npm install` to update npm packages.
49+
* `sail composer install` or `docker compose exec -it -u sail laravel.test composer install` to update composer files.
50+
* `sail restart` or `docker compose restart` to restart the containers.
51+
52+
### Stopping dev environment
53+
54+
To stop the dev environment, run `sail stop` or `docker compose stop`.
55+
56+
This action will stop all containers, free up the ports and keep data in containers and volumes.
57+
58+
To start it again, run `sail up -d` or `docker compose up -d`.
59+
60+
### Removing and cleaning up the dev environment
61+
62+
**WARNING: This action will remove all containers and volumes, including the database and all data in it.**
63+
64+
To remove the dev environment, run `sail down -v` or `docker compose down -v`.
65+
66+
Also, you may want to remove `vendor` and `node_modules` if you want to perform
67+
a clean installation later `rm -rf vendor node_modules`.
68+
69+
**WARNING: next step will remove all pulled and built images, build caches, volumes, networks and stopped containers.**
70+
71+
For some rare cases, you may want to remove all pulled images and volumes `docker system prune -af`.
72+
73+
## Exposed Ports
74+
75+
* `:80` - HTTP terafic internal router. It routes http request to laravel container (mostly)
76+
and hydra (`/.well-known`,`/oauth2`,`/health`,`/userinfo`)
77+
* `:8080` - traefic dashboard (for debugging)
78+
* `:3306` - MySQL database (can be changed via `FORWARD_DB_PORT` in `.env`)
79+
* `:4444`, `:4445`, `:5555` - Hydra endpoints (for debugging)
80+
* `:6379` - Redis (can be changed via `FORWARD_REDIS_PORT` in `.env`)
81+
* `:6001`, `:9601` - Soketi (local WS pusher implementation)
82+
(can be changed via `PUSHER_PORT` and `PUSHER_METRICS_PORT` in `.env`)
83+
* `:7700` - MeiliSearch (can be changed via `FORWARD_MEILISEARCH_PORT` in `.env`)
84+
* `:1025`, `:8025` - MailPit local SMTP server
85+
(can be changed via `FORWARD_MAILPIT_PORT`, `FORWARD_MAILPIT_DASHBOARD_PORT` in `.env`)
86+
87+
## Connecting to the MySQL database from the host
88+
89+
After you finish the installation, you can connect to the MySQL database from your host machine.
90+
91+
* Host: `127.0.0.1`
92+
* Port: `3306` (or the port you set in `.env` for `FORWARD_DB_PORT`)
93+
* Username: `sail` (or the user you set in `.env` for `DB_USERNAME`)
94+
* Password: `password` (or the password you set in `.env` for `DB_PASSWORD`)
95+
* Database: `laravel` (or the database you set in `.env` for `DB_DATABASE`)
96+
97+
## Receiving mail
98+
99+
During development, you should use `identity.eurofurence.localhost` hostname
100+
(eg `some-user@identity.eurofurence.localhost`) to receive emails.
101+
102+
Use mailpit to check the emails at [http://localhost:8025](http://localhost:8025).
103+
104+
## Security
18105

19106
If you discover any security related issues, please email me@thiritin.com instead of using the issue tracker.

database/seeders/UserSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function run()
2727
'name' => 'Admin',
2828
'email' => 'identity@eurofurence.localhost',
2929
'email_verified_at' => now(),
30-
'password' => \Hash::make(random_bytes(32)),
30+
'password' => \Hash::make(env('ADMIN_PASSWORD', random_bytes(32))),
3131
]);
3232
// Warning this user will be made admin!
3333
$user->roles()->attach(Role::where('name', 'superadmin')->firstOrFail());

0 commit comments

Comments
 (0)