wso2 / product-is

Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
746 stars 724 forks source link

[Self Registration REST API] Wrong Content-Type in Register User successful response #5701

Open omindu opened 5 years ago

omindu commented 5 years ago

Moved from: https://wso2.org/jira/browse/IDENTITY-7373

Hi,

I'm using the Self Registration REST API (v0.9) of Identity Server 5.3.0.

This is what I added in /repository/conf/identity/identity.xml:

<SelfRegistration>
        <Enable>true</Enable>
        <LockOnCreation>true</LockOnCreation>
        <Notification>
            <InternallyManage>false</InternallyManage>
        </Notification>
        <ReCaptcha>false</ReCaptcha>
 </SelfRegistration>

The important thing here is that I have disable the internal management of the notifications because I want to manage it myself.

So when I use the Register User (https://localhost:9443/api/identity/user/v0.9/me) resource of the API it returns the Validation Code so I can handle it. But the Content-Type of the response is application/json and the body is a plain text. Here is an example:

HTTP/1.1 201 Created
Date: Thu, 14 Jun 2018 07:10:42 GMT
Content-Type: application/json
Content-Length: 36
Server: WSO2 Carbon Server

8ff16bfe-64d5-43a4-95b7-d9d2285a4936

When there is an error all goes well because in that case the Content-Type is application/json and the body is a JSON:

HTTP/1.1 409 Conflict
Date: Thu, 14 Jun 2018 09:46:19 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Server: WSO2 Carbon Server

{"code":"20030","message":"Conflict","description":"User test_user already exists in the system. Please use a different username."}

Maybe a simple solution could be include the Validation Code in a JSON:

HTTP/1.1 201 Created
Date: Thu, 14 Jun 2018 07:10:42 GMT
Content-Type: application/json
Content-Length: 36
Server: WSO2 Carbon Server

{"code":"8ff16bfe-64d5-43a4-95b7-d9d2285a4936"}

The same happens with the Resend Code (https://localhost:9443/api/identity/user/v0.9/resend-code) resource of the API. Here is an example of response:

HTTP/1.1 201 Created
Date: Thu, 14 Jun 2018 09:49:35 GMT
Content-Type: application/json
Content-Length: 36
Server: WSO2 Carbon Server

81279f88-ae62-454e-9520-838a1ea80364

Thanks!

gayashanbc commented 5 years ago

I'm working on this issue.

gayashanbc commented 5 years ago

@omi Update: Fixing this issue will introduce a change in the existing API. It might break the flow in existing client applications due to the change in the API response. Hence, it was decided to return the response as it is without changing it.

Code snippet related to this issue is located at wso2-extensions/identity-governance repository, in this line.