How frankhassanabad/oauth2orizerecipes works
Main Components
• Authorization Server: This is the core component responsible for authenticating clients and users, issuing tokens, and enforcing OAuth2 rules. Its code is primarily in the “authorization-server” directory. Note its use of Express (via app.js), token management (token.js, oauth2.js), various OAuth2 flows, client credential management (db/clients.js), and extensive testing.
• Resource Server: Housed in the “resource-server” folder, this component protects resources and makes sure only validated tokens give access. It is similar in structure to the authorization server (with its own app.js, auth.js, and supporting resources like SSO management) but specialized for serving requests and handling resource access.
• Web Client: Found in “web-client,” it is the frontend part (likely serving as a demonstration client) that interacts with the authorization server. It handles presentation (views, HTML pages) and includes client certificates for secure operations.
• Databases: Both the authorization-server and resource-server include a “db” directory for data handling (storing access tokens, refresh tokens, authorization codes, clients, and users). Even though full tokens aren’t stored (only token IDs) due to JWT implementation, this is still an important component.
• Testing and curl Scripts: Although they are not part of the runtime system architecture, noting the separation of unit and integration tests (in “test” directories) and the headless testing via the curl folder can be helpful for completeness in your overall design documentation.
Relationships and Data Flows
• How the Web Client communicates with the Authorization Server to initiate authentication, obtain tokens, and perform SSO.
• Communication between the Resource Server and the Authorization Server—for token validation (e.g., the REST tokeninfo endpoint) and token revocation.
• How each server uses secure communication (SSL/TLS) by pointing to the certificates folder present in each.
Architectural Patterns and Design Principles
• A separation of concerns is evident: each component is isolated by its purpose (authorization, resource protection, client-facing UI).
• The pattern of using JWT for stateless token management is a key design decision. Show that token verification happens without heavy DB reliance beyond token metadata.
• The project leverages middleware-like structures (e.g., Express.js app.js) to manage incoming requests, authentication, and routing.