I am setting up an Auth Provider with an external service that implements OpenID Connect. Their endpoint requires a query parameter because their system uses tenant databases, and their users are not globally unique.

Our current idea is to create a new auth provider record for each of their tenants that are also our clients, and use each of those URLs from the Auth. Provider on each of their branded login page.

We would like to instead use a single Auth. Provider record and extend the Auth.AuthProviderPluginClass to generate the query parameter.

Is there any way we can access the url that initiates the flow from the initiate(...) method on Auth.AuthProviderPluginClass so I can read any query parameters passed in, and use that to generate my auth endpoint url?



OpenID Auth Provider Setup


Is this something you are looking for it is present in the documentation

global PageReference initiate(Map<string,string> 
        authProviderConfiguration, String stateToPropagate) 
            authUrl = authProviderConfiguration.get('Auth_Url__c'); 
            key = authProviderConfiguration.get('Key__c'); 

            // Here the developer can build up a request of some sort. 
            // Ultimately, they return a URL where we will redirect the user. 
            String url = authUrl + '?client_id='+ key +'&scope=USER,EXPRPT,LIST&redirect_uri='+ redirectUrl + '&state=' + stateToPropagate; 
            return new PageReference(url); 
| improve this answer | |

If I access the url from a site I can access the Site class to get the information I need. Since my users will be logging in from sites, this works perfectly.

I had to change the URL for the Auth flow from the url on the Auth.Provider record: https://salesforce.com/services/auth/.../ORGID/UrlSuffix


Site.getBaseSecureUrl() + '/services/auth/.../ORGID/UrlSuffix'

This still initiates the flow, and the Site class methods return the information about the site.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.