|
| 1 | +## Project Overview |
| 2 | + |
| 3 | +This project is a Go-based OAuth 2.0 and OpenID Connect (OIDC) server called Shadow SSO (3SO). It provides a complete suite of tools to implement secure authentication and authorization in Go applications. It can be used as a standalone server or as a library. |
| 4 | + |
| 5 | +The project is designed to be modular and flexible, with support for various grant types, token management features, and integration with external identity providers like LDAP/Active Directory. It uses MongoDB for data storage by default but also offers a high-performance Distributed Token Store (DTS) backend using BBoltDB. |
| 6 | + |
| 7 | +The project also includes a command-line interface (CLI) tool called `ssoctl` for managing the SSO system. |
| 8 | + |
| 9 | +## Building and Running |
| 10 | + |
| 11 | +The project uses a `Makefile` for common development tasks. |
| 12 | + |
| 13 | +### Building |
| 14 | + |
| 15 | +To build the `ssso` server and `ssoctl` CLI applications, run: |
| 16 | + |
| 17 | +```bash |
| 18 | +make build |
| 19 | +``` |
| 20 | + |
| 21 | +This will create the `ssso` and `ssoctl` executables in the project's root directory. |
| 22 | + |
| 23 | +### Running |
| 24 | + |
| 25 | +The `ssso` server can be run in several ways: |
| 26 | + |
| 27 | +**1. Standalone:** |
| 28 | + |
| 29 | +After building the application, you can run it directly: |
| 30 | + |
| 31 | +```bash |
| 32 | +./ssso |
| 33 | +``` |
| 34 | + |
| 35 | +The server requires a configuration file (`sso_config.yaml`) or environment variables to be set. Key configuration options include the MongoDB connection string, issuer URL, and token signing key. |
| 36 | + |
| 37 | +**2. Docker:** |
| 38 | + |
| 39 | +A `Dockerfile` is provided to build a Docker image for the `ssso` server: |
| 40 | + |
| 41 | +```bash |
| 42 | +docker build -t pilab/ssso:latest . |
| 43 | +``` |
| 44 | + |
| 45 | +You can then run the container with the required environment variables: |
| 46 | + |
| 47 | +```bash |
| 48 | +docker run -d \ |
| 49 | + -p 8080:8080 \ |
| 50 | + -e SSSO_MONGO_URI="mongodb://your_mongo_host:27017/shadow_sso_db" \ |
| 51 | + -e SSSO_ISSUER_URL="http://localhost:8080" \ |
| 52 | + -e SSSO_SIGNING_KEY_PATH="/path/to/your/signing_key.pem" \ |
| 53 | + --name ssso-server \ |
| 54 | + pilab/ssso:latest |
| 55 | +``` |
| 56 | + |
| 57 | +**3. Docker Compose:** |
| 58 | + |
| 59 | +The project includes a `docker-compose.yml` file to run the `ssso` server with the Distributed Token Store (`ssso-dts`) and a MongoDB instance: |
| 60 | + |
| 61 | +```bash |
| 62 | +docker-compose up --build |
| 63 | +``` |
| 64 | + |
| 65 | +### Testing |
| 66 | + |
| 67 | +To run the unit tests, use the following command: |
| 68 | + |
| 69 | +```bash |
| 70 | +make test |
| 71 | +``` |
| 72 | + |
| 73 | +## Development Conventions |
| 74 | + |
| 75 | +* **Code Generation:** The project uses Protocol Buffers and `buf` to generate Go code for API definitions. The `make proto` command can be used to regenerate the code. |
| 76 | +* **Dependency Management:** Go modules are used for dependency management. The `go.mod` file lists the project's dependencies. |
| 77 | +* **Configuration:** The server and CLI tool are configured using Viper, which allows for configuration via files (e.g., `sso_config.yaml`) or environment variables. |
| 78 | +* **Interfaces:** The project defines several interfaces (`OAuthRepository`, `UserRepository`, `TokenStore`) to allow for custom implementations of storage and caching layers. The default implementation uses MongoDB. |
| 79 | +* **CLI:** The `ssoctl` CLI is built using Cobra, a popular library for creating CLI applications in Go. |
| 80 | + |
| 81 | +## Key Files |
| 82 | + |
| 83 | +* `README.md`: Provides a comprehensive overview of the project, its features, and how to use it. |
| 84 | +* `Makefile`: Contains commands for building, testing, and other development tasks. |
| 85 | +* `go.mod`: Defines the project's Go module and its dependencies. |
| 86 | +* `apps/ssso/ssso.go`: The main entry point for the `ssso` server application. |
| 87 | +* `apps/sssoctl/sssoctl.go`: The main entry point for the `ssoctl` CLI tool. |
| 88 | +* `apps/ssso/config/config.go`: Defines the configuration structure for the `ssso` server. |
| 89 | +* `domain/`: Contains the core domain models and interfaces for the application. |
| 90 | +* `mongodb/`: Contains the MongoDB implementation of the repository interfaces. |
| 91 | +* `services/`: Contains the business logic and services for the application. |
| 92 | +* `api/`: Contains the API handlers for the server. |
| 93 | +* `proto/`: Contains the Protocol Buffer definitions for the API. |
0 commit comments