Skip to content

[Discussion] "Extend" DbAuth #7

Open
@pi0neerpat

Description

@pi0neerpat

Discussion

Redwood has its own self-hosted auth option now and its 💯 ! See dbAuth. I think we should completely overhaul this to "extend/merge" with dbAuth.

  • We receive all the advantages(eg. session management, cookies instead of JWTs) and maintenance of dbAuth
  • We will contribute more to dbAuth, instead of duplicating efforts here 🦾
  • Extending something that already exists, rather than making something new, is a better dev experience for both builders and maintainers
  • The package would be simpler, since it can focus on only the ethereum parts of this tool

Resources

Post I wrote on how to extend dbAuth: https://community.redwoodjs.com/t/combining-dbauth-oauth2/2452

Chatting on Discord with Oliver Lance:

In effect, you are losing part of the native AuthProvider's login mechanism, since you're replacing this whole method (note the client login method is actually full lowercase):

 logIn = async (options?: any) => {
   this.setState({ loading: true })
   const loginOutput = await this.rwClient.login(options)
   await this.reauthenticate()

   return loginOutput
 }

To follow your extension idea, we should actually do:

const dbAuth = new AuthProvider({ type: 'dbAuth' })
dbAuth.rwClient.login = login 

// OR

class AuthProviderOverride extends AuthProvider {
  constructor(props) {
    super(props)

    this.rwClient.login = () => {
      // my login override
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions