Last active
April 4, 2018 17:59
-
-
Save stewartadam/4fba14b7c00141d699a848676917a937 to your computer and use it in GitHub Desktop.
Spring Redirect to Azure AD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
class StubController { | |
@RequestMapping("/resource/{id}") | |
ModelAndView resource(ModelMap model, HttpServletRequest request, @PathVariable String id) { | |
model.addAttribute("attribute", "forwardWithForwardPrefix"); | |
String client_id = ""; | |
int state = (int )(Math.random() * 1000000 + 1); | |
String resource = "client_id_guid_of_fhir"; | |
String base_uri = request.getRequestURL().toString(); | |
base_uri = base_uri.substring(0, base_uri.length() - request.getServletPath().length()); | |
String redirect_uri = base_uri + "/context/authorized"; | |
String redirect = String.format("https://login.microsoftonline.com/common/oauth2/authorize?client_id=%s&state=%s&resource=%s&redirect_uri=%s&response_type=code&response_mode=post", client_id, state, resource, redirect_uri); | |
return new ModelAndView("redirect:" + redirect, model); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment