Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Twitch] no way to pass state from request #13

Open
dafreaki opened this issue Jun 29, 2022 · 3 comments
Open

[Twitch] no way to pass state from request #13

dafreaki opened this issue Jun 29, 2022 · 3 comments

Comments

@dafreaki
Copy link

dafreaki commented Jun 29, 2022

there is currently no way (or at least documentation) to pass the state via @UseTwitchAuth() using the request query params

@mjangir
Copy link
Owner

mjangir commented Jul 13, 2022

@dafreaki What exactly your use case is?

@icameron
Copy link

being able to pass the state of the request i.e a nonce or the referring url basically something that the callback can consume please see https://dev.twitch.tv/docs/authentication/getting-tokens-oauth

Parameter Required? Type Description
client_id Yes String Your app’s registered client ID.
force_verify No Boolean Set to true to force the user to re-authorize your app’s access to their resources. The default is false.
redirect_uri Yes URI Your app’s registered redirect URI. The authorization code is sent to this URI.
response_type Yes String Must be set to code.
scope Yes String A space-delimited list of scopes. The APIs that you’re calling will identify the scopes you must list. You must URL encode the list.
state No String Although optional, you are strongly encouraged to pass a state string to help prevent Cross-Site Request Forgery (CSRF) attacks. The server returns this string to you in your redirect URI (see the state parameter in the fragment portion of the URI). If this string doesn’t match the state string that you passed, ignore the response. The state string should be randomly generated and unique for each OAuth request.


@maddygoround
Copy link

I have modified the Authguard to support dynamic values for state.

  getAuthenticateOptions(context: ExecutionContext): IAuthModuleOptions {
    const request = context.switchToHttp().getRequest()
    return {
      state: Buffer.from(JSON.stringify(request.query)).toString('hex'),
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants