Monday, 8 July 2019

Setting custom domain using Angular oAuthservice and Identity server 4

We have Angular portal which communicates with identity server 4 and it works well with our own domain. We want to add support for custom domain and for that we are storing domain name in our database and whenever any angular portal link is opened, we grab the domain name from database and assign to authConfig as shown below:

Object.assign(authConfig, { issuer: domainNam });

this.oauthService.configure(authConfig);
        this.oauthService.tokenValidationHandler = new JwksValidationHandler();
        this.oauthService.loadDiscoveryDocumentAndTryLogin().then(() => {
.... rest of the code

It sets the domain name currently for issuer but it does not redirect to login page but instead it is showing me below error:

enter image description here

The link is made like this:

https://account.ourDomainName.io/connect/authorize?response_type=id_token%20token&client_id=WebApiImplicitClientId&state=OcTztAVWhhgJtfQYwXvJO3B9RD6rGkeKpQxM99ki&redirect_uri=https%3A%2F%2Fportal.ourDomainName.io%2Fauth-callback&scope=openid%20profile%20email%20aitapi&nonce=OcTztAVWhhgJtfQYwXvJO3B9RD6rGkeKpQxM99ki

What is going wrong here?

If issuer is not set then it works fine but when I dynamically set issuer, it is creating this problem.

authCOnfig is as below:

export const authConfig: AuthConfig = {

  // Url of the Identity Provider
  issuer: environment.identityServer.authority,

  // URL of the SPA to redirect the user to after login
  redirectUri: window.location.origin + "/auth-callback",
  // The SPA's id. The SPA is registerd with this id at the auth-server
  clientId: environment.identityServer.client_id,
  // set the scope for the permissions the client should request
  // The first three are defined by OIDC. The 4th is a usecase-specific one
  scope: environment.identityServer.scope,
  logoutUrl: environment.identityServer.authority + '/Account/Logout',
}



from Setting custom domain using Angular oAuthservice and Identity server 4

No comments:

Post a Comment