You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@syncope.apache.org by John Peter <sy...@gmail.com> on 2016/10/06 10:04:26 UTC

Suspend a user via REST ?

Hi,

I found rest api for suspending a user in [1]  but I think its not valid
for Syncope 2.0.0.
In [2], Can I use  /users/{key}/status for suspending a user ?

[1] https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade
[2] http://syncope.apache.org/rest/2.0/index.html

Thanks.

Re: Suspend a user via REST ?

Posted by Francesco Chicchiriccò <il...@apache.org>.
I have added a dedicate sample in the Client Library section (there are not yet plain HTTP / JSON samples there, sorry): 

https://ci.apache.org/projects/syncope/reference-guide.html#client-library 

It's example 14 at the moment. 

Regards. 

----- Il 6-ott-16, alle 15:27, John Peter <sy...@gmail.com> ha scritto: 

> Oh great ! Thanks for your quick fix.
> Thanks.

> On Thu, Oct 6, 2016 at 6:53 PM, Francesco Chicchiriccò < ilgrosso@apache.org >
> wrote:

>> On 6-oct-16, at 14:45, John Peter < syncope.user@gmail.com > wrote:

>>> Francesco,
>>> It doesn't work with username as value for the "key" field.
>>> POST /syncope/rest/users/user1/status
>>> {
>>> "operation": "ADD_REPLACE",
>>> "value": "",
>>> "onSyncope": true,
>>> "key": "user1",
>>> "type": "SUSPEND",
>>> "token": "",
>>> "resources": []
>>> }

>>> Response is
>>> {
>>> "status": 404,
>>> "type": "NotFound",
>>> "elements": [
>>> "NotFoundException: User user1"
>>> ]
>>> }

>>> I confirmed user1 exists in syncope.

>> Oh, I see (and also found why the trick is not working in this case)

>> I have just committed a quick-fix for this in

>> https://github.com/apache/syncope/commit/594d5cc3a2ea262b0158fb46d029cab52983a58e

>> it will be available in Syncope 2.0.1.

>> Still working on adding the sample to the reference guide...

>> Regards.

>>> On Thu, Oct 6, 2016 at 6:02 PM, Francesco Chicchiriccò < ilgrosso@apache.org >
>>> wrote:

>>>> On 6-oct-16, at 13:44, John Peter < syncope.user@gmail.com > wrote:

>>>>> It works!!
>>>>> Is this right ? I though it should have been done with just username.
>>>>> {
>>>>> "operation": "ADD_REPLACE",
>>>>> "value": "",
>>>>> "onSyncope": true,
>>>>> "key": "9248266f-bc58-48e0-8826-6fbc5808e03d",
>>>>> "type": "SUSPEND",
>>>>> "token": "",
>>>>> "resources": []
>>>>> }

>>>> Hi John,
>>>> it is definitely correct: I will add some notes in the reference guide (both as
>>>> HTTP / JSON and via SyncopeClient) as it looks like a common use case.

>>>> It is kind of undocumented trick, but you could pass along the actual username
>>>> as value for the "key" field, and it should work anyway.

>>>> Regards.

>>>>> On Thu, Oct 6, 2016 at 3:34 PM, John Peter < syncope.user@gmail.com > wrote:

>>>>>> Hi,
>>>>>> I found rest api for suspending a user in [1] but I think its not valid for
>>>>>> Syncope 2.0.0.
>>>>>> In [2], Can I use /users/{key}/status for suspending a user ?

>>>>>> [1] https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade
>>>>>> [2] http://syncope.apache.org/rest/2.0/index.html

>>>>>> Thanks.

>>>> --
>>>> Francesco Chicchiriccò

>>>> Tirasa - Open Source Excellence
>>>> http://www.tirasa.net/

>>>> Member at The Apache Software Foundation
>>>> Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
>>>> http://home.apache.org/~ilgrosso/

>> --
>> Francesco Chicchiriccò

>> Tirasa - Open Source Excellence
>> http://www.tirasa.net/

>> Member at The Apache Software Foundation
>> Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
>> http://home.apache.org/~ilgrosso/

-- 
Francesco Chicchiriccò 

Tirasa - Open Source Excellence 
http://www.tirasa.net/ 

Member at The Apache Software Foundation 
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail 
http://home.apache.org/~ilgrosso/ 

Re: Suspend a user via REST ?

Posted by John Peter <sy...@gmail.com>.
Oh great ! Thanks for your quick fix.

Thanks.

On Thu, Oct 6, 2016 at 6:53 PM, Francesco Chicchiriccò <il...@apache.org>
wrote:

> On 6-oct-16, at 14:45, John Peter <sy...@gmail.com> wrote:
>
> Francesco,
> It doesn't work with username as value for the "key" field.
> POST  /syncope/rest/users/user1/status
> {
>   "operation": "ADD_REPLACE",
>   "value": "",
>   "onSyncope": true,
>   "key": "user1",
>   "type": "SUSPEND",
>   "token": "",
>   "resources": []
> }
>
> Response is
> {
>   "status": 404,
>   "type": "NotFound",
>   "elements": [
>     "NotFoundException: User user1"
>   ]
> }
>
> I confirmed user1 exists in syncope.
>
>
> Oh, I see (and also found why the trick is not working in this case)
>
> I have just committed a quick-fix for this in
>
> https://github.com/apache/syncope/commit/594d5cc3a2ea262b0158fb46d029ca
> b52983a58e
>
> it will be available in Syncope 2.0.1.
>
> Still working on adding the sample to the reference guide...
>
> Regards.
>
> On Thu, Oct 6, 2016 at 6:02 PM, Francesco Chicchiriccò <
> ilgrosso@apache.org> wrote:
>
>> On  6-oct-16, at 13:44, John Peter <sy...@gmail.com> wrote:
>>
>> It works!!
>> Is this right ?  I though it should have been done with just username.
>> {
>>   "operation": "ADD_REPLACE",
>>   "value": "",
>>   "onSyncope": true,
>>   "key": "9248266f-bc58-48e0-8826-6fbc5808e03d",
>>   "type": "SUSPEND",
>>   "token": "",
>>   "resources": []
>> }
>>
>>
>> Hi John,
>> it is definitely correct: I will add some notes in the reference guide
>> (both as HTTP / JSON and via SyncopeClient) as it looks like a common use
>> case.
>>
>> It is kind of undocumented trick, but you could pass along the actual
>> username as value for the "key" field, and it should work anyway.
>>
>> Regards.
>>
>> On Thu, Oct 6, 2016 at 3:34 PM, John Peter <sy...@gmail.com>
>> wrote:
>>
>>> Hi,
>>> I found rest api for suspending a user in [1]  but I think its not valid
>>> for Syncope 2.0.0.
>>> In [2], Can I use  /users/{key}/status for suspending a user ?
>>>
>>> [1] https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade
>>> [2] http://syncope.apache.org/rest/2.0/index.html
>>>
>>> Thanks.
>>>
>> --
>> Francesco Chicchiriccò
>>
>> Tirasa - Open Source Excellence
>> http://www.tirasa.net/
>>
>> Member at The Apache Software Foundation
>> Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
>> http://home.apache.org/~ilgrosso/
>>
>
>
> --
> Francesco Chicchiriccò
>
> Tirasa - Open Source Excellence
> http://www.tirasa.net/
>
> Member at The Apache Software Foundation
> Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
> http://home.apache.org/~ilgrosso/
>

Re: Suspend a user via REST ?

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 6-oct-16, at 14:45, John Peter <sy...@gmail.com> wrote: 

> Francesco,
> It doesn't work with username as value for the "key" field.
> POST /syncope/rest/users/user1/status
> {
> "operation": "ADD_REPLACE",
> "value": "",
> "onSyncope": true,
> "key": "user1",
> "type": "SUSPEND",
> "token": "",
> "resources": []
> }

> Response is
> {
> "status": 404,
> "type": "NotFound",
> "elements": [
> "NotFoundException: User user1"
> ]
> }

> I confirmed user1 exists in syncope.

Oh, I see (and also found why the trick is not working in this case) 

I have just committed a quick-fix for this in 

https://github.com/apache/syncope/commit/594d5cc3a2ea262b0158fb46d029cab52983a58e 

it will be available in Syncope 2.0.1. 

Still working on adding the sample to the reference guide... 

Regards. 

> On Thu, Oct 6, 2016 at 6:02 PM, Francesco Chicchiriccò < ilgrosso@apache.org >
> wrote:

>> On 6-oct-16, at 13:44, John Peter < syncope.user@gmail.com > wrote:

>>> It works!!
>>> Is this right ? I though it should have been done with just username.
>>> {
>>> "operation": "ADD_REPLACE",
>>> "value": "",
>>> "onSyncope": true,
>>> "key": "9248266f-bc58-48e0-8826-6fbc5808e03d",
>>> "type": "SUSPEND",
>>> "token": "",
>>> "resources": []
>>> }

>> Hi John,
>> it is definitely correct: I will add some notes in the reference guide (both as
>> HTTP / JSON and via SyncopeClient) as it looks like a common use case.

>> It is kind of undocumented trick, but you could pass along the actual username
>> as value for the "key" field, and it should work anyway.

>> Regards.

>>> On Thu, Oct 6, 2016 at 3:34 PM, John Peter < syncope.user@gmail.com > wrote:

>>>> Hi,
>>>> I found rest api for suspending a user in [1] but I think its not valid for
>>>> Syncope 2.0.0.
>>>> In [2], Can I use /users/{key}/status for suspending a user ?

>>>> [1] https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade
>>>> [2] http://syncope.apache.org/rest/2.0/index.html

>>>> Thanks.

>> --
>> Francesco Chicchiriccò

>> Tirasa - Open Source Excellence
>> http://www.tirasa.net/

>> Member at The Apache Software Foundation
>> Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
>> http://home.apache.org/~ilgrosso/

-- 
Francesco Chicchiriccò 

Tirasa - Open Source Excellence 
http://www.tirasa.net/ 

Member at The Apache Software Foundation 
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail 
http://home.apache.org/~ilgrosso/ 

Re: Suspend a user via REST ?

Posted by John Peter <sy...@gmail.com>.
Francesco,

It doesn't work with username as value for the "key" field.

POST  /syncope/rest/users/user1/status
{
  "operation": "ADD_REPLACE",
  "value": "",
  "onSyncope": true,
  "key": "user1",
  "type": "SUSPEND",
  "token": "",
  "resources": []
}

Response is
{
  "status": 404,
  "type": "NotFound",
  "elements": [
    "NotFoundException: User user1"
  ]
}

I confirmed user1 exists in syncope.

GET  /syncope/rest/users/user1

{
  "@class": "org.apache.syncope.common.lib.to.UserTO",
  "creator": "admin",
  "creationDate": "2016-10-04T08:51:15.152+0000",
  "lastModifier": "admin",
  "lastChangeDate": "2016-10-06T12:43:27.347+0000",
  "key": "9248266f-bc58-48e0-8826-6fbc5808e03d",
  "type": "USER",
  "realm": "/",
  "status": "active",
  "password": null,
  "token": null,
  "tokenExpireTime": null,
  "username": "user1",
  "lastLoginDate": "2016-10-05T15:27:50.148+0000",
  "changePwdDate": "2016-10-06T07:56:07.176+0000",
  "failedLogins": 0,
  "securityQuestion": null,
  "securityAnswer": null,
  "mustChangePassword": false,
  "auxClasses": [],
  "plainAttrs": [],
  "derAttrs": [],
  "virAttrs": [],
  "resources": [],
  "roles": [],
  "dynRoles": [],
  "relationships": [],
  "memberships": [],
  "dynGroups": []
}

Thanks.


On Thu, Oct 6, 2016 at 6:02 PM, Francesco Chicchiriccò <il...@apache.org>
wrote:

> On  6-oct-16, at 13:44, John Peter <sy...@gmail.com> wrote:
>
> It works!!
> Is this right ?  I though it should have been done with just username.
> {
>   "operation": "ADD_REPLACE",
>   "value": "",
>   "onSyncope": true,
>   "key": "9248266f-bc58-48e0-8826-6fbc5808e03d",
>   "type": "SUSPEND",
>   "token": "",
>   "resources": []
> }
>
>
> Hi John,
> it is definitely correct: I will add some notes in the reference guide
> (both as HTTP / JSON and via SyncopeClient) as it looks like a common use
> case.
>
> It is kind of undocumented trick, but you could pass along the actual
> username as value for the "key" field, and it should work anyway.
>
> Regards.
>
> On Thu, Oct 6, 2016 at 3:34 PM, John Peter <sy...@gmail.com> wrote:
>
>> Hi,
>> I found rest api for suspending a user in [1]  but I think its not valid
>> for Syncope 2.0.0.
>> In [2], Can I use  /users/{key}/status for suspending a user ?
>>
>> [1] https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade
>> [2] http://syncope.apache.org/rest/2.0/index.html
>>
>> Thanks.
>>
> --
> Francesco Chicchiriccò
>
> Tirasa - Open Source Excellence
> http://www.tirasa.net/
>
> Member at The Apache Software Foundation
> Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
> http://home.apache.org/~ilgrosso/
>

Re: Suspend a user via REST ?

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 6-oct-16, at 13:44, John Peter <sy...@gmail.com> wrote: 

> It works!!
> Is this right ? I though it should have been done with just username.
> {
> "operation": "ADD_REPLACE",
> "value": "",
> "onSyncope": true,
> "key": "9248266f-bc58-48e0-8826-6fbc5808e03d",
> "type": "SUSPEND",
> "token": "",
> "resources": []
> }

Hi John, 
it is definitely correct: I will add some notes in the reference guide (both as HTTP / JSON and via SyncopeClient) as it looks like a common use case. 

It is kind of undocumented trick, but you could pass along the actual username as value for the "key" field, and it should work anyway. 

Regards. 

> On Thu, Oct 6, 2016 at 3:34 PM, John Peter < syncope.user@gmail.com > wrote:

>> Hi,
>> I found rest api for suspending a user in [1] but I think its not valid for
>> Syncope 2.0.0.
>> In [2], Can I use /users/{key}/status for suspending a user ?

>> [1] https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade
>> [2] http://syncope.apache.org/rest/2.0/index.html

>> Thanks.

-- 
Francesco Chicchiriccò 

Tirasa - Open Source Excellence 
http://www.tirasa.net/ 

Member at The Apache Software Foundation 
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail 
http://home.apache.org/~ilgrosso/ 

Re: Suspend a user via REST ?

Posted by John Peter <sy...@gmail.com>.
It works!!
Is this right ?  I though it should have been done with just username.

{
  "operation": "ADD_REPLACE",
  "value": "",
  "onSyncope": true,
  "key": "9248266f-bc58-48e0-8826-6fbc5808e03d",
  "type": "SUSPEND",
  "token": "",
  "resources": []
}

Thanks

On Thu, Oct 6, 2016 at 3:34 PM, John Peter <sy...@gmail.com> wrote:

> Hi,
>
> I found rest api for suspending a user in [1]  but I think its not valid
> for Syncope 2.0.0.
> In [2], Can I use  /users/{key}/status for suspending a user ?
>
> [1] https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade
> [2] http://syncope.apache.org/rest/2.0/index.html
>
> Thanks.
>