oauth multiple resources authorization
This commit is contained in:
@@ -25,11 +25,6 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.springframework.ide.eclipse.core.springbuilder</name>
|
||||
<arguments>
|
||||
@@ -40,6 +35,11 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
<oauth
|
||||
site="http://localhost:8081/spring-security-oauth-server"
|
||||
client-id="clientId"
|
||||
client-id="sampleClientId"
|
||||
redirect-uri="http://localhost:8081/spring-security-oauth-ui-implicit/"
|
||||
scope="read"
|
||||
scope="read write"
|
||||
template="oauthTemp">
|
||||
</oauth>
|
||||
|
||||
@@ -34,9 +34,21 @@ app.config(function($locationProvider) {
|
||||
}).hashPrefix('!');
|
||||
});
|
||||
|
||||
app.config(['$httpProvider', function ($httpProvider) {
|
||||
$httpProvider.interceptors.push(function ($q,$rootScope) {
|
||||
return {
|
||||
'responseError': function (responseError) {
|
||||
$rootScope.message = responseError.statusText;
|
||||
console.log("error here");
|
||||
console.log(responseError);
|
||||
return $q.reject(responseError);
|
||||
}
|
||||
};
|
||||
});
|
||||
}]);
|
||||
|
||||
|
||||
app.controller('mainCtrl', function($scope,$resource,$http) {
|
||||
app.controller('mainCtrl', function($scope,$resource,$http,$rootScope) {
|
||||
|
||||
$scope.$on('oauth:login', function(event, token) {
|
||||
$http.defaults.headers.common.Authorization= 'Bearer ' + token.access_token;
|
||||
@@ -49,6 +61,38 @@ app.controller('mainCtrl', function($scope,$resource,$http) {
|
||||
$scope.getFoo = function(){
|
||||
$scope.foo = $scope.foos.get({fooId:$scope.foo.id});
|
||||
}
|
||||
|
||||
$scope.createFoo = function(){
|
||||
if($scope.foo.name.length==0)
|
||||
{
|
||||
$rootScope.message = "Foo name can not be empty";
|
||||
return;
|
||||
}
|
||||
$scope.foo.id = null;
|
||||
$scope.foo = $scope.foos.save($scope.foo, function(){
|
||||
$rootScope.message = "Foo Created Successfully";
|
||||
});
|
||||
}
|
||||
|
||||
// bar
|
||||
$scope.bar = {id:0 , name:"sample bar"};
|
||||
$scope.bars = $resource("http://localhost:8081/spring-security-oauth-resource/bars/:barId",{barId:'@id'});
|
||||
|
||||
$scope.getBar = function(){
|
||||
$scope.bar = $scope.bars.get({barId:$scope.bar.id});
|
||||
}
|
||||
|
||||
$scope.createBar = function(){
|
||||
if($scope.bar.name.length==0)
|
||||
{
|
||||
$rootScope.message = "Bar name can not be empty";
|
||||
return;
|
||||
}
|
||||
$scope.bar.id = null;
|
||||
$scope.bar = $scope.bars.save($scope.bar, function(){
|
||||
$rootScope.message = "Bar Created Successfully";
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
/*]]>*/
|
||||
|
||||
@@ -10,19 +10,47 @@
|
||||
<div th:include="header"></div>
|
||||
|
||||
<div class="container">
|
||||
<h1 class="col-sm-12">Foo Details</h1>
|
||||
<div class="alert alert-info" ng-show="message">{{message}}</div>
|
||||
<h1>Foo Details</h1>
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-12">
|
||||
<label class="col-sm-3">ID</label>
|
||||
<span>{{foo.id}}</span>
|
||||
<label class="col-sm-2">ID</label>
|
||||
<span class="col-sm-10"><input class="form-control" ng-model="foo.id"/></span>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<label class="col-sm-3">Name</label>
|
||||
<span>{{foo.name}}</span>
|
||||
<label class="col-sm-2">Name</label>
|
||||
<span class="col-sm-10"><input class="form-control" ng-model="foo.name"/></span>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<a class="btn btn-default" href="#" ng-click="getFoo()">New Foo</a>
|
||||
<a class="btn btn-default" href="#" ng-click="getFoo()">Get Foo</a>
|
||||
<a class="btn btn-default" href="#" ng-click="createFoo()">Create Foo</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<hr/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<h1>Bar Details</h1>
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-12">
|
||||
<label class="col-sm-2">ID</label>
|
||||
<span class="col-sm-10"><input class="form-control" ng-model="bar.id"/></span>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<label class="col-sm-2">Name</label>
|
||||
<span class="col-sm-10"><input class="form-control" ng-model="bar.name"/></span>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<a class="btn btn-default" href="#" ng-click="getBar()">Get Bar</a>
|
||||
<a class="btn btn-default" href="#" ng-click="createBar()">Create Bar</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user