https://github.com/thekid/cas
CAS Server in PHP
https://github.com/thekid/cas
authentication cas cas-server mfa php7 php8 totp xp-framework
Last synced: about 1 year ago
JSON representation
CAS Server in PHP
- Host: GitHub
- URL: https://github.com/thekid/cas
- Owner: thekid
- Created: 2019-08-19T22:10:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-02-16T10:51:09.000Z (over 1 year ago)
- Last Synced: 2025-02-16T11:26:09.730Z (over 1 year ago)
- Topics: authentication, cas, cas-server, mfa, php7, php8, totp, xp-framework
- Language: PHP
- Homepage:
- Size: 536 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
CAS Server
==========
[](https://github.com/thekid/cas/actions)
[](https://github.com/xp-framework/core)
[](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[](http://php.net/)
[](http://php.net/)

Minimalistic [CAS](https://apereo.github.io/cas/) Server in PHP supporting MySQL / MariaDB or MongoDB persistence.

Setup
-----
For use with MySQL / MariaDB, create a database with the following tables (*the following uses MySQL syntax, adopt if necessary!*):
```bash
# Create database and tables
$ cat src/main/sql/mysql-schema.ddl | mysql -u root
# Create user
$ mysql -u root -e "grant all on IDENTITIES.* to 'cas'@'%' identified by '...'"
```
MongoDB collections are created automatically when the first document is inserted - so the only thing necessary is to create the user for the respective database, as shown in the following Mongo CLI commands:
```javascript
mongo> use admin;
mongo> db.createUser({
user: "cas",
pwd: "...",
roles: [ { role: "readWrite", db: "cas" } ]
})
```
Run composer:
```sh
$ composer install
# ...
```
Export environment:
```sh
$ export CAS_DB_PASS=... # The one you used when creating the database user above
$ export REDIS_PASS=... # Sessions use filesystem during development, redis only in prod
$ export CRYPTO_KEY=... # Must have 32 characters, generate with `openssl rand -base64 24`
```
You can also put these variables into a file named **credentials**, if you wish:
```sh
$ cat > credentials
CAS_DB_PASS=...
CRYPTO_KEY=...
REDIS_PASS=...
```
Running
-------
Start the server:
```sh
# For MySQL / MariaDB
$ xp serve -p dev -c src/main/etc/sql
# For MongoDB
$ xp serve -p dev -c src/main/etc/mongo
```
*Now open http://localhost:8080/login in your browser.*
To change the address and port the server runs on, add `-a 0.0.0.0:8443` to the above command line.
User management
---------------
All of the following use the *sql* configuration. For use with MongoDB, use `src/main/etc/mongo` instead!
```sh
# Create a new user; generating a random password if necessary
$ xp cmd -c src/main/etc/sql NewUser [--password=]
# Change a user's password
$ xp cmd -c src/main/etc/sql ChangePassword [--password=]
# Remove an existing user
$ xp cmd -c src/main/etc/sql RemoveUser
# List all users
$ xp cmd -c src/main/etc/sql ListUsers
# Filter users on their username. Use * to match any character
$ xp cmd -c src/main/etc/sql ListUsers 't*'
```
Setting up MFA
--------------
```sh
# Create a new token
$ xp cmd -c src/main/etc/sql NewToken [--name=]
# List existing tokens
$ xp cmd -c src/main/etc/sql ListTokens
# Remove an existing token
$ xp cmd -c src/main/etc/sql RemoveToken
```