Package edu.ucsb.cs.scaffold.controller
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThrown 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.postGithubPatCredential(String token, LocalDate expiresAt) postPlPatCredential(String token, LocalDate expiresAt) Methods inherited from class edu.ucsb.cs.scaffold.controller.ApiController
genericMessage, getCurrentUser, handleEntityNotFoundException, handleForbiddenException, handleIllegalArgument, handleUnsupportedOperation
-
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.
-