API now bound to USER for read, ADMIN for write, addresses #267
parent
1daf5bd357
commit
c9bdba3f3a
|
@ -25,6 +25,7 @@ import com.google.gson.Gson;
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/api/scopes")
|
@RequestMapping("/api/scopes")
|
||||||
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public class ScopeAPI {
|
public class ScopeAPI {
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,6 +93,7 @@ public class ScopeAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@RequestMapping(value = "", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
|
@RequestMapping(value = "", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
|
||||||
public String createScope(@RequestBody String json, ModelMap m) {
|
public String createScope(@RequestBody String json, ModelMap m) {
|
||||||
SystemScope scope = gson.fromJson(json, SystemScope.class);
|
SystemScope scope = gson.fromJson(json, SystemScope.class);
|
||||||
|
@ -111,6 +113,7 @@ public class ScopeAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||||
public String deleteScope(@PathVariable("id") Long id, ModelMap m) {
|
public String deleteScope(@PathVariable("id") Long id, ModelMap m) {
|
||||||
SystemScope existing = scopeService.getById(id);
|
SystemScope existing = scopeService.getById(id);
|
||||||
|
|
|
@ -54,7 +54,7 @@ import com.google.gson.JsonParser;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/api/clients")
|
@RequestMapping("/api/clients")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public class ClientAPI {
|
public class ClientAPI {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -120,6 +120,7 @@ public class ClientAPI {
|
||||||
* @param principal
|
* @param principal
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||||
public String apiAddClient(@RequestBody String jsonString, Model m, Authentication auth) {
|
public String apiAddClient(@RequestBody String jsonString, Model m, Authentication auth) {
|
||||||
|
|
||||||
|
@ -160,6 +161,7 @@ public class ClientAPI {
|
||||||
* @param principal
|
* @param principal
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@RequestMapping(value="/{id}", method = RequestMethod.PUT, consumes = "application/json", produces = "application/json")
|
@RequestMapping(value="/{id}", method = RequestMethod.PUT, consumes = "application/json", produces = "application/json")
|
||||||
public String apiUpdateClient(@PathVariable("id") Long id, @RequestBody String jsonString, Model m, Authentication auth) {
|
public String apiUpdateClient(@PathVariable("id") Long id, @RequestBody String jsonString, Model m, Authentication auth) {
|
||||||
|
|
||||||
|
@ -204,6 +206,7 @@ public class ClientAPI {
|
||||||
* @param modelAndView
|
* @param modelAndView
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
|
@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
|
||||||
public String apiDeleteClient(@PathVariable("id") Long id, ModelAndView modelAndView) {
|
public String apiDeleteClient(@PathVariable("id") Long id, ModelAndView modelAndView) {
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.google.gson.JsonParser;
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/api/whitelist")
|
@RequestMapping("/api/whitelist")
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
@PreAuthorize("hasRole('ROLE_USER')")
|
||||||
public class WhitelistAPI {
|
public class WhitelistAPI {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -59,6 +59,7 @@ public class WhitelistAPI {
|
||||||
* @param p
|
* @param p
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||||
public String addNewWhitelistedSite(@RequestBody String jsonString, ModelMap m, Principal p) {
|
public String addNewWhitelistedSite(@RequestBody String jsonString, ModelMap m, Principal p) {
|
||||||
|
|
||||||
|
@ -80,6 +81,7 @@ public class WhitelistAPI {
|
||||||
/**
|
/**
|
||||||
* Update an existing whitelisted site
|
* Update an existing whitelisted site
|
||||||
*/
|
*/
|
||||||
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@RequestMapping(value="/{id}", method = RequestMethod.PUT, consumes = "application/json", produces = "application/json")
|
@RequestMapping(value="/{id}", method = RequestMethod.PUT, consumes = "application/json", produces = "application/json")
|
||||||
public String updateWhitelistedSite(@PathVariable("id") Long id, @RequestBody String jsonString, ModelMap m, Principal p) {
|
public String updateWhitelistedSite(@PathVariable("id") Long id, @RequestBody String jsonString, ModelMap m, Principal p) {
|
||||||
|
|
||||||
|
@ -106,6 +108,7 @@ public class WhitelistAPI {
|
||||||
* Delete a whitelisted site
|
* Delete a whitelisted site
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||||
@RequestMapping(value="/{id}", method = RequestMethod.DELETE)
|
@RequestMapping(value="/{id}", method = RequestMethod.DELETE)
|
||||||
public String deleteWhitelistedSite(@PathVariable("id") Long id, ModelMap m) {
|
public String deleteWhitelistedSite(@PathVariable("id") Long id, ModelMap m) {
|
||||||
WhitelistedSite whitelist = whitelistService.getById(id);
|
WhitelistedSite whitelist = whitelistService.getById(id);
|
||||||
|
|
|
@ -258,19 +258,19 @@
|
||||||
<div class="control-group" id="tokenEndpointAuthMethod">
|
<div class="control-group" id="tokenEndpointAuthMethod">
|
||||||
<label class="control-label"><span class="label label-default nyi"><i class="icon-road icon-white"></i> NYI </span> Token Endpoint Authentication Method</label>
|
<label class="control-label"><span class="label label-default nyi"><i class="icon-road icon-white"></i> NYI </span> Token Endpoint Authentication Method</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<label class="radio inline">
|
<label class="radio">
|
||||||
<input type="radio" name="tokenEndpointAuthMethod" value="SECRET_BASIC" <%=(tokenEndpointAuthMethod == 'SECRET_BASIC' ? 'checked' : '')%>> Client Secret over HTTP Basic
|
<input type="radio" name="tokenEndpointAuthMethod" value="SECRET_BASIC" <%=(tokenEndpointAuthMethod == 'SECRET_BASIC' ? 'checked' : '')%>> Client Secret over HTTP Basic
|
||||||
</label>
|
</label>
|
||||||
<label class="radio inline">
|
<label class="radio">
|
||||||
<input type="radio" name="tokenEndpointAuthMethod" value="SECRET_POST" <%=(tokenEndpointAuthMethod == 'SECRET_POST' ? 'checked' : '')%>> Client Secret over HTTP POST
|
<input type="radio" name="tokenEndpointAuthMethod" value="SECRET_POST" <%=(tokenEndpointAuthMethod == 'SECRET_POST' ? 'checked' : '')%>> Client Secret over HTTP POST
|
||||||
</label>
|
</label>
|
||||||
<label class="radio inline">
|
<label class="radio">
|
||||||
<input type="radio" name="tokenEndpointAuthMethod" value="SECRET_JWT" <%=(tokenEndpointAuthMethod == 'SECRET_JWT' ? 'checked' : '')%>> Client Secret via symmetrically-signed JWT assertion
|
<input type="radio" name="tokenEndpointAuthMethod" value="SECRET_JWT" <%=(tokenEndpointAuthMethod == 'SECRET_JWT' ? 'checked' : '')%>> Client Secret via symmetrically-signed JWT assertion
|
||||||
</label>
|
</label>
|
||||||
<label class="radio inline">
|
<label class="radio">
|
||||||
<input type="radio" name="tokenEndpointAuthMethod" value="PRIVATE_KEY_JWT" <%=(tokenEndpointAuthMethod == 'PRIVATE_KEY_JWT' ? 'checked' : '')%>> Asymmetrically-signed JWT assertion
|
<input type="radio" name="tokenEndpointAuthMethod" value="PRIVATE_KEY_JWT" <%=(tokenEndpointAuthMethod == 'PRIVATE_KEY_JWT' ? 'checked' : '')%>> Asymmetrically-signed JWT assertion
|
||||||
</label>
|
</label>
|
||||||
<label class="radio inline">
|
<label class="radio">
|
||||||
<input type="radio" name="tokenEndpointAuthMethod" value="NONE" <%=(tokenEndpointAuthMethod == 'NONE' ? 'checked' : '')%>> No authentication
|
<input type="radio" name="tokenEndpointAuthMethod" value="NONE" <%=(tokenEndpointAuthMethod == 'NONE' ? 'checked' : '')%>> No authentication
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue