Coder Social home page Coder Social logo

davidje13 / auth-backend Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 2.0 151 KB

minimal API for integration with external authentication providers

License: MIT License

JavaScript 11.33% TypeScript 74.00% HTML 14.67%
github-login gitlab-login google-login google-sso oauth

auth-backend's People

Contributors

davidje13 avatar

Watchers

 avatar  avatar

auth-backend's Issues

Support protected URL Sign In

To allow easy integration with alternative authentication mechanisms, it should be possible to configure a trusted URL where it is assumed that if the user can reach the URL, they are trusted. This could be used with a proxy configured to require Mutual TLS for the configured path, for example.

const config = {
  trustedEndpoint: {
    path: 'my-trusted-path',
    userIdHeader: 'X-Ssl-Cert-Hash',
  },
};

Which could be combined with an nginx config:

ssl_verify_client on;
ssl_client_certificate /path/to/cert.crt;
ssl_verify_client optional;

location /ssoprefix/my-trusted-path {
  if ($ssl_client_verify != "SUCCESS") { return 403; }
  proxy_set_header X-Ssl-Cert-Hash $ssl_client_fingerprint;
}

It may be desirable to have other options than userIdHeader, such as userId for a fixed user ID for anybody able to reach the endpoint.


Things to consider:

  • Care must be taken by the user to ensure the endpoint is fully protected. Might be worth allowing a configurable header-based password which can be set in the proxy as a bit of extra protection against accidental misconfigurations (wouldn't provide much protection though)
  • Should it be possible to configure multiple trusted endpoints? What would that look like?
  • How should this interact with the existing client-exposed authUrl property?

Fix GitLab sign in

GitLab seems to have updated their supported methods and now returns:

The authorization server does not support this response type.

Support WebAuthn sign in

This is mostly a client concern, but some server-side support will be needed for generating challenges.

Need to understand the create-account / login flows better;

What is the challenge for in the create step? Seems to be focused on adding credentials to an existing account, but here we can consider it creating a new account with the new credentials. In this case, maybe the challenge is superfluous?

Server needs to be able to generate input params for the calls:

const options = await fetch('/auth/webauthn').then((r) => r.json());
let key = await navigator.credentials.get({ publicKey: { challenge: new UInt8Array(options.challenge) } });
if (!key) {
  key = await navigator.credentials.create(options.create);
  await fetch('/auth/webauthn', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ key: key.response.attestationObject }), // is clientDataJSON needed?
    // ...
  });
}
// we now (possibly) have a key which we can use to respond to a server challenge to exchange for a JWT
{
  "challenge": [0, 0, 0, 0, 0, ..., 0],
  "create": {
    "publicKey": {
      "rp": {},
      "user": {},
      "pubKeyCredParams": [],
    }
  }
}

The intended WebAuthn flow is still unclear; is the expected flow to create first (but with excludeCredentials somehow?) then always use the same get call with data and a challenge to perform the JWT exchange?

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.