Skip to content

Instantly share code, notes, and snippets.

@xring
Created May 30, 2019 03:05
Show Gist options
  • Save xring/867d0b7e56815fc38f812aefd88b72de to your computer and use it in GitHub Desktop.
Save xring/867d0b7e56815fc38f812aefd88b72de to your computer and use it in GitHub Desktop.
@RestController
@Slf4j
public class AuthController {
@GetMapping("/")
public void auth(HttpServletRequest request, HttpServletResponse response) {
Map<String, String> headers = new HashMap<>();
Enumeration headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String key = (String) headerNames.nextElement();
String value = request.getHeader(key);
headers.put(key, value);
}
String authT = headers.get("authorization");
if (StringUtils.isEmpty(authT)) {
response.setStatus(HttpStatus.UNAUTHORIZED.value());
return;
}
response.setStatus(HttpStatus.OK.value());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment