0

I want to add a custom parameter to angular-auth-oidc-client authorize method like this. With the custom parameter in this case the client_id I want to write some custom logic.

export class LoginComponent implements OnInit {

     constructor(private oidcSecurityService: OidcSecurityService) {
    }

     ngOnInit() {
      this.oidcSecurityService.authorize({customParams: { 'client_id': 'F93C5C9E-57DC-4889-86DD-66A98EAD94CC' } });
    }
}

In the backend I have setup identityserver4 in .net core 3.1 application. I have also implemented custom ProfileService

public class ProfileService : IProfileService
{
    protected UserManager<ApplicationUser> _userManager;

    public ProfileService(UserManager<ApplicationUser> userManager)
    {
        _userManager = userManager;
    }

    public async Task GetProfileDataAsync(ProfileDataRequestContext context)
    {
        //>Processing
        var user = await _userManager.GetUserAsync(context.Subject);

        var claims = new List<Claim>
        {
            new Claim("FullName", user.FullName),
        };

        context.IssuedClaims.AddRange(claims);
    }

    public async Task IsActiveAsync(IsActiveContext context)
    {
        //>Processing
        var user = await _userManager.GetUserAsync(context.Subject);
        
        context.IsActive = (user != null) && user.IsActive;
    }
}

Also in startup.cs

services.AddIdentityServer()
    .AddProfileService<ProfileService>();

How can I access the custom parameter that is sent from angular oidc client in my .net core application?

If any additional info is needed let me know.

Jyotirmaya Prusty
  • 278
  • 1
  • 8
  • 25

1 Answers1

0

IdentityServer is a certified OpenId Connect protocol implementation, Authorization request, has predefined structure, so you can't introduce any custom parameter you want.

According to the spec the only two "free" parameters are the state which is used by clients and should be sent back with response as it is, and acr_values which is specially aimed for sending additional parameters to the server.

But client_id is not a custom, but a standard and required parameter in the authorization request. So general case you just need to set it up properly.

d_f
  • 4,599
  • 2
  • 23
  • 34