-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: #185 simplification of authorization
- Loading branch information
Showing
16 changed files
with
197 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...odule/oauth2/provider/OAuth2Provider.java → ...dule/oauth2/processor/OAuth2Provider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package pl.sknikod.kodemyauth.infrastructure.module.oauth2.provider; | ||
package pl.sknikod.kodemyauth.infrastructure.module.oauth2.processor; | ||
|
||
import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; | ||
|
||
public interface OAuth2Provider { | ||
String getRegistrationId(); | ||
boolean isApply(String registrationId); | ||
OAuth2ProviderResult retrieve(OAuth2UserRequest userRequest); | ||
OAuth2ProcessorResult retrieve(OAuth2UserRequest userRequest); | ||
} |
31 changes: 7 additions & 24 deletions
31
...provider/github/GithubOAuth2Provider.java → ...ocessor/github/GithubOAuth2Processor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...er/github/GithubOAuth2ProviderResult.java → ...r/github/GithubOAuth2ProcessorResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...knikod/kodemyauth/infrastructure/module/oauth2/processor/github/GithubOAuth2Provider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package pl.sknikod.kodemyauth.infrastructure.module.oauth2.processor.github; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; | ||
import org.springframework.stereotype.Component; | ||
import pl.sknikod.kodemyauth.infrastructure.module.oauth2.processor.OAuth2Provider; | ||
import pl.sknikod.kodemyauth.infrastructure.module.oauth2.processor.OAuth2ProcessorResult; | ||
import pl.sknikod.kodemyauth.infrastructure.module.oauth2.util.OAuth2RestTemplate; | ||
|
||
@Component | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class GithubOAuth2Provider implements OAuth2Provider { | ||
private static final String REGISTRATION_ID = "github"; | ||
private final OAuth2RestTemplate oAuth2RestTemplate; | ||
|
||
@Override | ||
public String getRegistrationId() { | ||
return REGISTRATION_ID; | ||
} | ||
|
||
@Override | ||
public boolean isApply(String registrationId) { | ||
return getRegistrationId().equals(registrationId); | ||
} | ||
|
||
@Override | ||
public OAuth2ProcessorResult retrieve(OAuth2UserRequest userRequest) { | ||
return new GithubOAuth2Processor(oAuth2RestTemplate).process(userRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.