Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Domain - You should not be hitting this endpoint #504

Closed
mariancerny opened this issue Jun 5, 2018 · 1 comment
Closed

Custom Domain - You should not be hitting this endpoint #504

mariancerny opened this issue Jun 5, 2018 · 1 comment
Labels
bug This points to a verified bug in the code

Comments

@mariancerny
Copy link
Contributor

mariancerny commented Jun 5, 2018

We are using a custom Auth0 domain that is configured in Auth0.plist. However when showing embedded Lock login screen we get this errors:

DEBUG | ClassicRouter.swift:42 - No connections configured. Loading client info from Auth0...
INFO | CDNLoaderInteractor.swift:37 - Loading client info from client/{clientId}.js -- https://our.custom.domain
VERBOSE | CDNLoaderInteractor.swift:68 - Received jsonp alert("You should not be hitting this endpoint. Make sure to use the code snippets shown in the tutorial or contact [email protected] for help");
ERROR | CDNLoaderInteractor.swift:112 - Failed to parse alert("You should not be hitting this endpoint. Make sure to use the code snippets shown in the tutorial or contact [email protected] for help" with error Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
Fatal error: Your Auth0 credentials ClientId and/or Domain are invalid.: file Pods/Lock/Lock/ConnectionLoadingPresenter.swift, line 44

The issue seems to be that configuration is tried to be downloaded from
https://our.custom.domain/client/{clientId}.js
instead of from
https://cdn.auth0.com/client/{clientId}.js

Note: The CDN URL varies by region. For regions outside of the US, use https://cdn.[eu|au].auth0.com (eu for Europe or au for Australia).

Looking at the source code I did not find a way how to set a custom configuration URL. For our purpose I have modified the source code of CDNLoaderInteractor.swift and changed a line in private function cdnURL(from:)

guard let host = url.host, host.hasSuffix(".auth0.com") else { return url }

to

guard let host = url.host, host.hasSuffix(".auth0.com") else {
    return URL(string: "https://cdn.auth0.com")!
}

This issue seems to be similar to this one auth0/lock#1311 where the problem was missing configurationBaseUrl parameter. However it was in a different library (JavaScript version of Lock, not iOS/Swift version).

So the right solution might be adding such a configuration parameter to iOS version of Lock library as well. Or a similar change as I have made could be made to make it automagically work as it looks it should we working as stated here: https://auth0.com/docs/custom-domains/additional-configuration#auth0-js-and-other-sdks

Auth0.js and other SDKs

If you use Auth0.js or other SDKs, you will have to initialize the SDK using your custom domain.

(there is no mention that a configurationBaseUrl needs to be set).

Lock 2.5.1 / iOS 11

@cocojoe cocojoe added the bug This points to a verified bug in the code label Jun 5, 2018
@cocojoe
Copy link
Member

cocojoe commented Jun 5, 2018

Thanks for reporting, let me look into this and come back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

2 participants