GithubHelp home page GithubHelp logo

darylbuckle / react-oauth2-authcode-provider Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 5.63 MB

A npm package for authenticating with OAuth2 Authorisation Code Flow in React SPAs.

Home Page: https://darylbuckle.github.io/react-oauth2-authcode-provider

HTML 1.75% TypeScript 95.04% CSS 3.21%

react-oauth2-authcode-provider's Issues

Security issue

The clientSecret parameter should never be used on the front-end.
Exposing the clientSecret inside the front end application at any time makes your application vulnerable to attack.

Please use a back-end/proxy to handle the clientSecret.

storagePrefix not working when useState = true

FYI - using storagePrefix is not working when useState = true.

It looks like the doAuthorizationCodeFlow processing in AuthCodeFunctions.tsx is not propagating the storagePrefix value in the getCodeLocation call so the state is being saved without the storagePrefix. This causes a 'State does not match' error in tradeCodeForToken in AuthCodeProvider.tsx since it's looking for the value with the storagePrefix.

Let me know if you need more details.

Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.

Given the following code:

i```
mport React from 'react'
import {AuthCodeProvider, AuthCodeFunctions} from 'react-oauth2-authcode-provider'
//import 'react-oauth2-authcode-provider/dist/index.css'

class Login extends React.Component {
constructor() {
super()

    this.tokenObtained = this.tokenObtained.bind(this)
    this.authenticationProps = {
        usePkce: false,
        authUrl: process.env.REACT_APP_AUTHORIZE_URL,
        tokenUrl: process.env.REACT_APP_ACCESS_TOKEN_URL,
        clientId: process.env.REACT_APP_CLIENT_ID,
        clientSecret: process.env.REACT_APP_CLIENT_SECRET,
        scope: ''
    }

    this.state = {
        tokenObject: null
    }
}

tokenObtained(token) {
    this.setState({tokenObject: token})
}

tokenAuth(token) {
    console.log('auth')
    console.log(token)
}

tokenRef(token) {
    console.log('ref')
    console.log(token)
}

tokenRec(token) {
    console.log('rec')
    console.log(token)
}

tokenError(error) {
    console.error(error)
}

render() {
    return (
        <AuthCodeProvider
            history={this.props.history}
            enableDebugLog={true}
            authenticationRequired={false}
            onReceiveAuthCode={(data) => this.tokenRec(data)}
            onTokenObtained={(data) => this.tokenObtained(data)}
            onGetAuthCode={(data) => this.tokenAuth(data)}
            onTokenRefreshed={(data) => this.tokenRef(data)}
            authenticationProps={this.authenticationProps}
      >
          <div>
            <p>You’ll now need to connect to Hoopla to grant Microsoft Teams access to your Hoopla data.</p>
            <button onClick={() => AuthCodeFunctions.doAuthorizationCodeFlow(this.authenticationProps)}>Connect To Hoopla</button>
          </div>
      </AuthCodeProvider>
    )
}

}

export default Login;


I receive `Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.` in `tokenObtained`. 

react-scripts 5.0 error

if I used the latest react-scripts, under errors are happened.

Compiled with problems:X

ERROR in ./node_modules/react-oauth2-authcode-provider/dist/index.modern.js 32:13-30

Module not found: Error: Can't resolve 'crypto' in '/node_modules/react-oauth2-authcode-provider/dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
	- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "crypto": false }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.