swsnu / swppspr2015

Repository for discussing common issues that are not project-specific, SNU SWPP Spring 2015
https://sites.google.com/site/snuswppspr2015/
0 stars 0 forks source link

Data format on POST #4

Open jsjason opened 9 years ago

jsjason commented 9 years ago

We received a question on the format of the data body in POST requests (programming assignment 1).

The assignment page currently mentions an example: {'username': 'hi', 'password': '12345678'}. However, it is possible to send data in the form username=hi&password=12345678. This depends on the Content-type of the HTTP request.

If we set Content-type: application/x-www-form-urlencoded, then the data format must be like x=xx&xxx=xxxx. On the other hand, if we set Content-type: application/json then the data needs to be in JSON format. Regardless of the data format, Rails should be able to detect the Content-type and interpret the data body correctly. The assignment page is merely trying to say that the the grading will be done with JSON-formatted data.

One thing to note though: the form_for method of Rails will probably send data in the form user[username]=hi&user[password]=12345678. This is different from username=hi&password=12345678, the assignment specification. Make sure you handle this correctly.

simnalamburt commented 9 years ago

@jsjason 안녕하세요. 수강생 13학번 김지현입니다. 레일즈에서 기본으로 제공하는 CSRF 토큰 체크 기능을 꺼야하나요? 채점할때 문제가 생길것같습니다.

jsjason commented 9 years ago

This is a discussion page for everyone to see, @simnalamburt. Please write your questions and answers in English.

jsjason commented 9 years ago

Your question: Do we have to disable the defaul CSRF token filter function in Rails? I think there might some problems during grading.

jsjason commented 9 years ago

What kind of problems are you talking about?

simnalamburt commented 9 years ago

@jsjason 레일즈엔 기본으로 CSRF 방어기능이 켜져있는데, 이게 켜져있을경우 AJAX 요청을 보낼때 HTTP 헤더에 X-CSRF-Token에 CSRF 토큰을 넣어주지 않을경우 요청이 거부됩니다. 근데 수업시간때 딱히 여기에 관련된 내용을 배운적이 없어서 아마 수업에서 배운대로만 따라하면 많은 학생들이 이 옵션을 켠채로 과제를 할것같아서, 채점 프로그램이 작동하지 않을까 우려됩니다.

Rails blocks requests which doesn't have correct X-CSRF-Token and I see many students doing their homework without disabling this feature.

시간이 없어서 나중에 영어로 고치겠습니다. 죄송합니다.

Leeingnyo commented 9 years ago

There is a guide about that, https://sites.google.com/site/snuswppspr2015/programming-assignment please check '4. Grading' section.

jsjason commented 9 years ago

Thanks, @Leeingnyo. The csrf token problem @simnalamburt is talking about is probably related to the HTTP 422 status code situtation mentioned in the assignment page. Take a look.

simnalamburt commented 9 years ago

@Leeingnyo @jsjason Thank you very much

blandocs commented 9 years ago

 안녕하세요 조교님! 컴퓨터공학부 2013-11393 김현수입니다. 제가 js, json, rails 등 공부하면서 이번 숙제를 계속하였는데도 지식이 부족하여 아직도 숙제를 다하지 못하였습니다. hard deadline이라는게 오늘 저녁 6시까지 제출 못하면 그냥 0점인가요..? 듀를 조금 더 늘려주실 수는 없으신가요.. ㅠ