Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.

C-408 Send OAuth read-only response#1311

Merged
nicoback2 merged 4 commits into
mainfrom
nkang--oauth-response
May 12, 2022
Merged

C-408 Send OAuth read-only response#1311
nicoback2 merged 4 commits into
mainfrom
nkang--oauth-response

Conversation

@nicoback2

Copy link
Copy Markdown
Contributor

Description

Form JWT containing user's profile information to send back to the redirect URI.

Dragons

Is there anything the reviewer should be on the lookout for? Are there any dangerous changes?

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide repro instructions & any configuration.

How will this change be monitored?

For features that are critical or could fail silently please describe the monitoring/alerting being added.

@nicoback2 nicoback2 requested a review from sliptype May 12, 2022 14:44
@audius-infra

Copy link
Copy Markdown
Collaborator

Preview this change https://demo.audius.co/nkang--oauth-response

@sliptype sliptype left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking great! The redirect validation is definitely interesting bc we aren't registering the url, but good enough for now

if (redirect_uri && typeof redirect_uri === 'string') {
let res: URL
try {
res = new URL(redirect_uri)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we just return here?

Suggested change
res = new URL(redirect_uri)
return new URL(redirect_uri)

const [password, setPassword] = useState('')
const [submitError, setSubmitError] = useState<string | null>(null)

useEffect(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind making isRedirectValid a ref?

You could use useMemo here I believe:

Suggested change
useEffect(() => {
const isRedirectValid = useMemo(() => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No real reason! I'll change it so it's more grokkable

return
}
const statePart = state != null ? `state=${state}&` : ''
const fragment = `#${statePart}token=${jwt}`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why put the token in the hash rather than as a query param?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is just convention from the OpenID spec which is what we're emulating with this flow
https://openid.net/specs/openid-connect-core-1_0.html#ImplicitFlowAuth

@audius-infra

Copy link
Copy Markdown
Collaborator

Preview this change https://demo.audius.co/nkang--oauth-response

@nicoback2 nicoback2 merged commit c99d02a into main May 12, 2022
@nicoback2 nicoback2 deleted the nkang--oauth-response branch May 12, 2022 23:01
@sliptype sliptype mentioned this pull request May 13, 2022
@AudiusProject AudiusProject deleted a comment from linear Bot Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants