Skip to content

Conversation

@Gobukgol
Copy link
Contributor

OAuth2 임시 구현하였습니다. 현재는 구글 계정으로 로그인 하도록 구현하였습니다.

회원가입 페이지가 나오는대로 User 엔티티 수정과 병행하여 수정 하도록 하겠습니다.

Gobukgol added 4 commits July 15, 2020 15:05
…ce 구현체 구현

OAuth2 로그인 성공 후 DB에 해당 유저가 없을 경우 DB 저장 후 세션을 저장함
현재 "/api/word/" 관련한 API 호출의 경우 권한이 사용자일 경우에만 허용, 나머지는 권한 상관없이 허용
로그아웃 성공시 임시로 "/" url로 돌아가도록 설정
Copy link
Contributor

@jyami-kim jyami-kim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나도 Oauth2 해본적이 없어서 뭔가 피드백을 못주겠당ㅋㅋ큐ㅜㅠㅠㅠ 가벼운 컨벤션만 봤어여

private String picture;

@Builder
public OAuthAttributes(final Map<String, Object> attributes, final String nameAttributeKey, final String name, final String email, final String picture) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private 으로 해주세여


@Override
public OAuth2User loadUser(final OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {
OAuth2UserService delegate = new DefaultOAuth2UserService();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 왜 빈으로 주입 안받음? 못받나??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

방금까지 OAuth 갑자기 안되는것 같아서 한참 헤매다가 내가 착각해가지고 삽질해서 지금 확인했는데 ㅠㅠ

일단 OAuth2 적용하는것은 동욱님 책 참고하면서 하는 중인데 빈으로 주입 받아서 하려니까 오류나서 안된다고 나오네....
예전에 professorlol 프로젝트 확인해보니까 지금 내가 구현한건 인터페이스 implements 해서 구현했고, professorlol 은 저 DefaultOAuth2UserService 상속받아서 구현해서 저렇게 가져오지않고 super.loadUser로 값을 가져오는 식으로 구현했더라고
일단 계속 확인해볼께 ㅠ

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

잉구ㅠㅜ 화이팅 오빠 시간 많으니까!! 정 하가 안되면 금토일 같이 봐도 좋으니ㅠㅜ 쉬엄쉬엄해여

private String email;
private String picture;

public AccessUser(final User user) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정적 팩터리로 바꾸면 좋을것같아여!


User user = save(attributes);

httpSession.setAttribute("user", new AccessUser(user));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지금 의존관계가 OauthAttribute가 User를 만들고 User가 AccessUser를 만드는건가??
저 httpSession은 어디에 필요해??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OauthAttribute가 소셜 로그인 했을때 구글에서 반환하는 값으로 User를 만들고 DB에 저장한다음에, AccessUser로 세션 저장하는 거인데 로그인 하고 단어 저장할때마다 세션 정보 필요할것 같아서 만들어 두었엉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants