Skip to content

Commit

Permalink
changed the process of finding which login provider to use , now it s…
Browse files Browse the repository at this point in the history
…tores it in cookies instead of reading the url
  • Loading branch information
feyruzb committed Jul 25, 2024
1 parent 68eaf7b commit 8f9a467
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
Binary file added analyzer/tools/build-logger/ldlogger
Binary file not shown.
Binary file added analyzer/tools/build-logger/ldlogger_32.so
Binary file not shown.
4 changes: 0 additions & 4 deletions web/api/authentication.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ service codeCheckerAuthentication {
string createLinkGoogle()
throws (1: codechecker_api_shared.RequestFailed requestError),

// Retrieves an OAuth token for the specified link.
string getOAuthToken(1: string link)
throws (1: codechecker_api_shared.RequestFailed requestError),

// Performs logout action for the user. Must be called from the
// corresponding valid session which is to be destroyed.
bool destroySession()
Expand Down
4 changes: 2 additions & 2 deletions web/server/codechecker_server/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def createLinkGoogle(self):
"""
This function is for creating an authentication link for OAuth for Google.
"""
oauth_config = self.oauth_config_google
oauth_config = self.oauth_config_google # get the google oauth config

if not oauth_config.get("enabled"):
raise codechecker_api_shared.ttypes.RequestFailed(
Expand Down Expand Up @@ -257,8 +257,8 @@ def performLogin(self, auth_method, auth_string):
codechecker_api_shared.ttypes.ErrorCode.AUTH_DENIED,
"User is not authorized to access this service.")

# return token
session = self.__manager.create_session("github@" + username + ":" + token['access_token'])

return session.token
elif auth_method == "oauth_google":
LOG.info("OAuth login GOOGLE... started")
Expand Down
42 changes: 23 additions & 19 deletions web/server/vue-cli/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ export default {
let code = null, state = null;
code = url.searchParams.get("code");
state = url.searchParams.get("state");
const provider = document.cookie.split(";").find(
c => c.includes("oauth_provider")).split("=")[1];
if (code != null && state != null) {
if (url.searchParams.get("scope") &&
url.searchParams.get("scope").includes("googleapis")
if (provider === "google"
) {
this.$store
.dispatch(LOGIN, {
Expand All @@ -178,24 +179,26 @@ export default {
});
return;
}
else if (provider === "github") {
this.$store
.dispatch(LOGIN, {
type: "oauth",
provider: "github",
url: window.location.href
})
.then(() => {
this.success = true;
this.error = false;
this.$store
.dispatch(LOGIN, {
type: "oauth",
provider: "github",
url: window.location.href
})
.then(() => {
this.success = true;
this.error = false;
const w = window.location;
window.location.href = w.protocol + "//" + w.host + w.pathname;
}).catch(err => {
this.errorMsg = `Failed to log in! ${err.message}`;
this.error = true;
this.$router.replace({ name: "login" });
});
const w = window.location;
window.location.href = w.protocol + "//" + w.host + w.pathname;
}).catch(err => {
this.errorMsg = `Failed to log in! ${err.message}`;
this.error = true;
this.$router.replace({ name: "login" });
});
return;
}
}
},
Expand All @@ -219,6 +222,7 @@ export default {
},
oauth(provider) {
new Promise(resolve => {
document.cookie = `oauth_provider=${provider}; path=*`;
if (provider === "google") {
authService.getClient().createLinkGoogle(
handleThriftError(url => {
Expand Down

0 comments on commit 8f9a467

Please sign in to comment.