Skip to content

Allow using authentication service as a library #22

Description

@chadfurman

I'd like to pull in the backend and front-end js components separately. I have a GraphQL API and would like to write resolvers that use this service.

What do you think of making a monorepo (pnp-authentication) made up of the following packages:

  • pnp-authentication-users - package that provides tools for authentication, account creation, and generating password reset tokens
    • emits events like "userRegistering", "userRegistered", "loginFailed", "resetTokenGenerated", ...
  • pnp-authentication-email - a basic send-receive email package configured through the standard environment variables
    • "emailSendSuccess", "emailSendFailure", ...
  • pnp-authentication-jwt - a package for creating and verifying JWTs
    • events could be used for implementing a JWT caching system
  • pnp-authentication-avatar (image uploading, adding avatar data to schema)
    • default configuration to be compatible with existing schema expectations
  • pnp-authentication-recaptcha - utilities to add and verify a recaptcha
  • pnp-authentication-templates - Registers functions for generating templates
    • comes with the current set of template files

pnp-autnentication should allow for overiding any of these packages -- there should be a set API that these packages use to communicate, as well as a configure option when initializing the library to override any of the default API with a custom implementation.

Here is one theoretical way we could make this more of a configurable library while still staying true to the plug-and-play nature of the whole thing:

const authService = pnpAuthentication({
  jwt: {
    signJwt: function implementsJwtPackageApiForSignJwt(...) { ... },
    // other functions not mentioned here use the default from the package
  },
  templates: {
    login: renderLoginFuncion; // renderLoginFunction gets passed any config data needed to render the login page, and returns the complete HTML (CSS, JS, etc) necessary to render this view
  }
})

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