Class PatCredentialController

java.lang.Object
edu.ucsb.cs.scaffold.controller.ApiController
edu.ucsb.cs.scaffold.controller.PatCredentialController

@RequestMapping("/api/pat") @RestController public class PatCredentialController extends ApiController
Lets each admin or instructor store one personal access token (PAT) per platform: a GitHub PAT at /api/pat/github and a PrairieLearn PAT at /api/pat/pl. Tokens are encrypted before they are saved and are write-only: no endpoint ever returns one, only metadata (last four characters, expiration date). To replace a lost or expired token, the user simply POSTs a new one. See docs/Github_PAT.md and docs/PrairieLearn_PAT.md for how to create suitable tokens.
  • Constructor Details

    • PatCredentialController

      public PatCredentialController()
  • Method Details

    • getGithubPatCredential

      @PreAuthorize("hasRole(\'ROLE_ADMIN\') || hasRole(\'ROLE_INSTRUCTOR\')") @GetMapping("/github") public PatCredential getGithubPatCredential()
    • getPlPatCredential

      @PreAuthorize("hasRole(\'ROLE_ADMIN\') || hasRole(\'ROLE_INSTRUCTOR\')") @GetMapping("/pl") public PatCredential getPlPatCredential()
    • postGithubPatCredential

      @PreAuthorize("hasRole(\'ROLE_ADMIN\') || hasRole(\'ROLE_INSTRUCTOR\')") @PostMapping("/github") public PatCredential postGithubPatCredential(@RequestParam String token, @RequestParam(required=false) @DateTimeFormat(iso=DATE) LocalDate expiresAt)
    • postPlPatCredential

      @PreAuthorize("hasRole(\'ROLE_ADMIN\') || hasRole(\'ROLE_INSTRUCTOR\')") @PostMapping("/pl") public PatCredential postPlPatCredential(@RequestParam String token, @RequestParam(required=false) @DateTimeFormat(iso=DATE) LocalDate expiresAt)
    • handleIllegalStateException

      @ExceptionHandler(java.lang.IllegalStateException.class) @ResponseStatus(SERVICE_UNAVAILABLE) public Object handleIllegalStateException(Throwable e)
      Thrown by PatEncryptionService when no PAT_ENCRYPTION_KEY is configured — a server-side deployment problem, not a client error, so it maps to 503 rather than 400.