Skip to content

Commit 8f9a467

Browse files
committed
changed the process of finding which login provider to use , now it stores it in cookies instead of reading the url
1 parent 68eaf7b commit 8f9a467

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

analyzer/tools/build-logger/ldlogger

38.4 KB
Binary file not shown.
38.5 KB
Binary file not shown.

web/api/authentication.thrift

-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ service codeCheckerAuthentication {
7777
string createLinkGoogle()
7878
throws (1: codechecker_api_shared.RequestFailed requestError),
7979

80-
// Retrieves an OAuth token for the specified link.
81-
string getOAuthToken(1: string link)
82-
throws (1: codechecker_api_shared.RequestFailed requestError),
83-
8480
// Performs logout action for the user. Must be called from the
8581
// corresponding valid session which is to be destroyed.
8682
bool destroySession()

web/server/codechecker_server/api/authentication.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def createLinkGoogle(self):
125125
"""
126126
This function is for creating an authentication link for OAuth for Google.
127127
"""
128-
oauth_config = self.oauth_config_google
128+
oauth_config = self.oauth_config_google # get the google oauth config
129129

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

260-
# return token
261260
session = self.__manager.create_session("github@" + username + ":" + token['access_token'])
261+
262262
return session.token
263263
elif auth_method == "oauth_google":
264264
LOG.info("OAuth login GOOGLE... started")

web/server/vue-cli/src/views/Login.vue

+23-19
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,11 @@ export default {
154154
let code = null, state = null;
155155
code = url.searchParams.get("code");
156156
state = url.searchParams.get("state");
157+
const provider = document.cookie.split(";").find(
158+
c => c.includes("oauth_provider")).split("=")[1];
157159
158160
if (code != null && state != null) {
159-
if (url.searchParams.get("scope") &&
160-
url.searchParams.get("scope").includes("googleapis")
161+
if (provider === "google"
161162
) {
162163
this.$store
163164
.dispatch(LOGIN, {
@@ -178,24 +179,26 @@ export default {
178179
});
179180
return;
180181
}
182+
else if (provider === "github") {
183+
this.$store
184+
.dispatch(LOGIN, {
185+
type: "oauth",
186+
provider: "github",
187+
url: window.location.href
188+
})
189+
.then(() => {
190+
this.success = true;
191+
this.error = false;
181192
182-
this.$store
183-
.dispatch(LOGIN, {
184-
type: "oauth",
185-
provider: "github",
186-
url: window.location.href
187-
})
188-
.then(() => {
189-
this.success = true;
190-
this.error = false;
191-
192-
const w = window.location;
193-
window.location.href = w.protocol + "//" + w.host + w.pathname;
194-
}).catch(err => {
195-
this.errorMsg = `Failed to log in! ${err.message}`;
196-
this.error = true;
197-
this.$router.replace({ name: "login" });
198-
});
193+
const w = window.location;
194+
window.location.href = w.protocol + "//" + w.host + w.pathname;
195+
}).catch(err => {
196+
this.errorMsg = `Failed to log in! ${err.message}`;
197+
this.error = true;
198+
this.$router.replace({ name: "login" });
199+
});
200+
return;
201+
}
199202
200203
}
201204
},
@@ -219,6 +222,7 @@ export default {
219222
},
220223
oauth(provider) {
221224
new Promise(resolve => {
225+
document.cookie = `oauth_provider=${provider}; path=*`;
222226
if (provider === "google") {
223227
authService.getClient().createLinkGoogle(
224228
handleThriftError(url => {

0 commit comments

Comments
 (0)