Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions fission/src/aps/APS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const APS_AUTH_KEY = "aps_auth"
const APS_USER_INFO_KEY = "aps_user_info"

const APS_SCOPES = "data:read"
const CLIENT_ID = "GCxaewcLjsYlK8ud7Ka9AKf9dPwMR3e4GlybyfhAK2zvl3tU"

const ENDPOINT_SYNTHESIS_CODE = `/api/aps/code`
Expand All @@ -14,7 +14,7 @@
const ENDPOINT_AUTODESK_AUTHENTICATION_AUTHORIZE = "https://developer.api.autodesk.com/authentication/v2/authorize"
const ENDPOINT_AUTODESK_AUTHENTICATION_TOKEN = "https://developer.api.autodesk.com/authentication/v2/token"
const ENDPOINT_AUTODESK_AUTHENTICATION_REVOKE = "https://developer.api.autodesk.com/authentication/v2/revoke"
const ENDPOINT_AUTODESK_USERINFO = "https://api.userprofile.autodesk.com/userinfo"
const ENDPOINT_AUTODESK_USERINFO = "https://api.aps.autodesk.com/userinfo"

Check warning on line 17 in fission/src/aps/APS.ts

View check run for this annotation

Autodesk Chorus / security/semgrep

app.chorus.semgrep.rules.njsscan.generic.node_username

A hardcoded username in plain text is identified. Store it properly in an environment variable.

Check warning on line 17 in fission/src/aps/APS.ts

View check run for this annotation

Autodesk Chorus / security/semgrep

app.chorus.semgrep.rules.njsscan.semantic_grep.generic.node_username

A hardcoded username in plain text is identified. Store it properly in an environment variable.

// biome-ignore-start lint/style/useNamingConvention: returned from api
export interface APSAuth {
Expand Down Expand Up @@ -190,7 +190,7 @@
response_type: "code",
client_id: CLIENT_ID,
redirect_uri: callbackUrl,
scope: "data:read",
scope: APS_SCOPES,
nonce: Date.now().toString(),
prompt: "login",
code_challenge: challenge,
Expand Down Expand Up @@ -232,7 +232,7 @@
client_id: CLIENT_ID,
grant_type: "refresh_token",
refresh_token: refreshToken,
scope: "data:read",
scope: APS_SCOPES,
}),
})
const json = await res.json()
Expand Down Expand Up @@ -323,7 +323,8 @@
const res = await fetch(ENDPOINT_AUTODESK_USERINFO, {
method: "GET",
headers: {
Authorization: auth.access_token,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.access_token,

Check notice on line 327 in fission/src/aps/APS.ts

View check run for this annotation

Autodesk Chorus / security/gitleaks

http-header-authorization

HTTP Header Authorization: possible secret committed to source code
},
})
const json = await res.json()
Expand All @@ -334,14 +335,12 @@
await this.requestAuthCode()
return
}
const info: APSUserInfo = {
this.userInfo = {
name: json.name,
givenName: json.given_name,
picture: json.picture,
email: json.email,
}

this.userInfo = info
} catch (e) {
console.error(e)
World.analyticsSystem?.exception("APS Login Failure: User Info")
Expand Down
8 changes: 4 additions & 4 deletions fission/src/test/APSTesting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,12 @@
await APS.loadUserInfo(mockAuth)

expect(mockFetch).toHaveBeenCalledWith(
"https://api.userprofile.autodesk.com/userinfo",
expect.stringContaining("autodesk.com"),
expect.objectContaining({
method: "GET",

Check notice on line 563 in fission/src/test/APSTesting.test.ts

View check run for this annotation

Autodesk Chorus / security/gitleaks

http-header-authorization

HTTP Header Authorization: possible secret committed to source code
headers: {
Authorization: mockAuth.access_token,
},
headers: expect.objectContaining({
Authorization: "Bearer " + mockAuth.access_token,
}),
})
)
})
Expand Down
Loading