Skip to content

Allow pre-caching discovery data before first request #219

@az-nextsec

Description

@az-nextsec

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

If I follow the documented implementation it is not until the first request with Bearer token hits a backend API that the getDiscovery() is executed.

If we're running behind a network proxy and there is a delay on executing this request this leaves the user frustrated. It would be great to be able to execute discovery phase BEFORE starting express app which means that the application has the JWKS and openid-configuration already when the first request hits.

Describe the ideal solution

Provide the ability to execute discovery before the first request.

Alternatives and current workarounds

A hacky workaround like so works:

    const auth0 = auth(auth0Opts);
    try {
        await auth0({
            is() { return false; },
            get(val) {
                if (val === 'Host') {
                    return 'localhost';
                }

                return undefined;
            },
            headers: {
                Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IndoYXRldmVyIn0=.eyJhIjoiYiJ9.dGVzdA=='
            },
            protocol: 'https',
            originalUrl: '/api',
            method: 'GET'
        }, {}, () => { });
    } catch {
        // Do nothing. However, this doesn't actually throw.
    }

Additional context

No response

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