bcgov / common-web-utils

Common Front End JS utils and libraries
Apache License 2.0
1 stars 0 forks source link

Applying arguments to override options for some methods in Implicit Auth Manager #32

Open patricksimonian opened 5 years ago

patricksimonian commented 5 years ago

Is your feature request related to a problem? Please describe. I saw an example of the implicit auth manager where buttons to do redirects to the sso provider where based on different identity providers. This required (at this stage) for the config ssoIDPHint to be assigned on the fly.

const { idp } = this.props.location.state;
if (idp) implicitAuthManager.config.kcIDPHint = idp;
return (window.location = implicitAuthManager.getSSOLoginURI());

Ofcourse we want to avoid doing this.

@shelly @jleach any thoughts on a good implementation of this?

I have a few ideas.

  1. Register IDPs in the config on instantiation and then pass them as an argument into getSSOLoginUri
const options = {
 ...
idps: {
   github: 'foo',
   idir: 'bar'
  }
}

const iam = new ImplicitAuthManager(options);
iam.getSSOLoginUri('github')
  1. Allow to pass overrides into a function call based on relevant option properties

    iam.getSSOLoginUri({kcIDPHint: 'idir'});
  2. Allow specific arguments per function call

    iam.getSSOLoginURI('idir');