How nithe14/pam_oauth2_device works
This repository is a PAM authentication module using OAuth 2.0 Device Authorization Grant. Its main workflow loads configuration and logging options, obtains a device code, prompts the user to authorize, polls for an access token, introspects it, and validates the returned identity, scopes, and expiry before reporting a PAM result. The graph includes configuration, prompt rendering, OAuth operations, validation, and logging; external PAM and authorization-server interactions are shown where documented or evidenced by the excerpts.
Main entry points: lib.rs Authentication Handler · oauth_device.rs Device Authorization · prompt.rs User Prompt · config.rs Config Loader
Components 14
PAM Authentication
- Authentication Handler
src/lib.rs - PAM Conversation
- User Prompt
src/prompt.rs - QR Rendering
src/prompt.rs
OAuth Device Flow
- OAuth Client
src/oauth_device.rs - Device Authorization
src/oauth_device.rs - Token Polling
src/oauth_device.rs - Token Introspection
src/oauth_device.rs - Token Validation
src/oauth_device.rs
Configuration and Support
- Config Loader
src/config.rs - File Logger
src/logger.rs
Other components
- Login User
- PAM Framework
- Authorization Server
Connections 18
- Login User → PAM Framework: requests login
README.md - PAM Framework → Authentication Handler: dispatches auth
src/lib.rs - Authentication Handler → Config Loader: loads config
src/lib.rs - Authentication Handler → File Logger: initializes logging
src/lib.rs - Authentication Handler → OAuth Client: builds client
src/lib.rs - Authentication Handler → Device Authorization: requests device code
src/lib.rs - OAuth Client → Device Authorization: configures flow
src/oauth_device.rs - Device Authorization → Authorization Server: requests device code
README.md - Authentication Handler → User Prompt: builds prompt
src/lib.rs - User Prompt → QR Rendering: generates QR
src/prompt.rs - Authentication Handler → PAM Conversation: sends prompt
src/lib.rs - PAM Conversation → Login User: displays instructions
README.md - Authentication Handler → Token Polling: polls token
src/lib.rs - Token Polling → Authorization Server: requests access token
README.md - Authentication Handler → Token Introspection: introspects token
src/lib.rs - Token Introspection → Authorization Server: sends introspection request
README.md - Authentication Handler → Token Validation: validates response
src/lib.rs - Authentication Handler → PAM Framework: returns PAM result
src/lib.rs