Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT 굿바이~ #81

Closed
Pyohwan opened this issue Apr 30, 2017 · 9 comments
Closed

JWT 굿바이~ #81

Pyohwan opened this issue Apr 30, 2017 · 9 comments
Assignees
Milestone

Comments

@Pyohwan
Copy link
Member

Pyohwan commented Apr 30, 2017

인증은 세션+쿠키를 쓰도록 바꿨습니다. 스프링이 제공해주는걸로 하는것이 가장 나은것 같네요.
쿠키는 톰캣에서 말아주는 JSESSIONID와 remember-me가 있어요. 이 두가지만 잘 들고 다니면 문제 없을듯.. (기존 x-auth-token 헤더는 날아갔습니다)

https://staging.jakduk.com:8080/swagger-ui.html#/Authentication
(참고로 이메일 로그인은 스웨거에 안나옴)

삭제 API

GET /api/auth/refresh JWT 토큰 갱신

변경 API

POST /api/login/social/{providerId} SNS 기반 로그인 (존재 하지 않는 회원이면 신규가입 진행)
->
POST /api/auth/login/{providerId} SNS 기반 로그인 (존재 하지 않는 회원이면 신규가입 진행)

path만 바뀌었음
.

GET /api/social/attempt SNS 기반 회원 가입시 필요한 회원 프로필 정보
->
GET /api/auth/user/attempt SNS 기반 회원 가입시 필요한 회원 프로필 정보

path 변경 및 x-attempt-token 파라미터 삭제.
.

POST /api/login 이메일 기반 로그인
->
POST /api/auth/login 이메일 기반 로그인

가장 크게 바뀐것인데 contentType이 application/json -> application/x-www-form-urlencoded
body는 remember-me 파라미터 추가
예제
curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "username=test05@test.com&password=2111&remember-me=true" http://localhost:8080/api/auth/login

@silverprize
Copy link
Member

@Pyohwan
Copy link
Member Author

Pyohwan commented May 1, 2017

@silverprize
고쳤어요.

Pyohwanui-MacBook-Pro:jakduk_ssh pyohwanjang$ curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "username=test05@test.com&password=1111&remember-me=true" https://staging.jakduk.com:8080/api/auth/login
HTTP/1.1 200 
Server: nginx/1.10.2
Date: Mon, 01 May 2017 04:20:47 GMT
Content-Type: application/json;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Set-Cookie: remember-me=dGVzdDA1QHRlc3QuY29tOjE0OTQ4MjIwMTI4MDQ6MGMyMWNkYTNlNGE0MGNlMmNhNTA5ZjRiMzYxYjY1NjI; Max-Age=1209600; Expires=Mon, 15-May-2017 04:20:12 GMT; Path=/; HttpOnly
Set-Cookie: JSESSIONID=599FF401DE2A762C0579781341402B68; Path=/; HttpOnly

{}
Pyohwanui-MacBook-Pro:jakduk_ssh pyohwanjang$ curl -i -X GET -H "Content-Type: application/json" -H "Cookie: JSESSIONID=599FF401DE2A762C0579781341402B68" https://staging.jakduk.com:8080/api/user/profile/me
HTTP/1.1 200 
Server: nginx/1.10.2
Date: Mon, 01 May 2017 04:22:36 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY

{"email":"test05@test.com","username":"test05","about":"test05","providerId":"JAKDUK","footballClubName":{"language":"en","fullName":"SEONGNAM FC","shortName":"SEONGNAM"},"picture":null,"temporaryEmail":false}

@silverprize
Copy link
Member

@Pyohwan https://staging.jakduk.com:8080/swagger-ui.html#!/User/addSocialUserUsingPOST
가입성공후 JSESSIONID 안주는 게 맞나요?

@Pyohwan
Copy link
Member Author

Pyohwan commented May 1, 2017

새로 말아서 줘야 해여. 자동 로그인. 안되면 제 잘못

@silverprize
Copy link
Member

silverprize commented May 1, 2017

@Pyohwan response에 JSESSIONID 없어요

silverprize added a commit that referenced this issue May 1, 2017
secure cookie 적용
silverprize added a commit that referenced this issue May 1, 2017
secure cookie 적용
@Pyohwan
Copy link
Member Author

Pyohwan commented May 1, 2017

@silverprize
죄송. 기존꺼 재활용 하네요.

https://staging.jakduk.com:8080/swagger-ui.html#!/Authentication/loginSNSUserUsingPOST
요놈 날리고 받은 JSESSIONID로 쭉 갑니다.

@Pyohwan
Copy link
Member Author

Pyohwan commented May 1, 2017

로그아웃은 /api/auth/logout

@silverprize
Copy link
Member

silverprize commented May 1, 2017

@Pyohwan https://staging.jakduk.com:8080/swagger-ui.html#!/User/addSocialUserUsingPOST 에서 가입성공하면 JSESSIONID 못주나요?

silverprize added a commit that referenced this issue May 1, 2017
@Pyohwan
Copy link
Member Author

Pyohwan commented May 2, 2017

@silverprize 가입하고 나서 무조건 JSESSIONID 줄려고 했는데, 살펴보니 request 날릴때 JSESSIONID가 존재하면 새로 발급을 안해주더라고요. SNS 가입할때에는 request 시 JSESSEIONID가 존재해야하기 때문에 발급이 안되요.

반면 이메일 가입은 발급 해줄거에요.

아무튼 이부분 더 찾아볼께요.

silverprize added a commit that referenced this issue May 4, 2017
sns가입완료후 자동 로그인 실패 수정
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants