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

refactor sso provider selection #525

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

henrinie-nc
Copy link
Contributor

avoid using boolean values in envvars as yaml, ansible, .env evaluate them differently

avoid using boolean values in envvars as yaml, ansible, .env evaluate them differently
Copy link
Contributor

@NC-jsAhonen NC-jsAhonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes look ok to me. However, I recommend adding an explanation to Tunnistus vs Tunnistamo to the README. Those words are so similar that they are easily confused, and even when not, it is not clear what the difference is and what they are referring to. Will this documentation be added now or in a later PR?

@@ -31,6 +33,9 @@ const loginProviderTunnistusProperties: LoginProviderProps = {
sessionPollerSettings: { pollIntervalInMs: 300000 } // 300000ms = 5min
};

export const useTunnistamoOpenIdConnect = import.meta.env.VITE_USE_TUNNISTAMO_OPENID_CONNECT === 'true' || import.meta.env.VITE_USE_TUNNISTAMO_OPENID_CONNECT === true;
export const oidcProviderName: OidcProviderName = import.meta.env.VITE_OIDC_PROVIDER || 'tunnistus';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'tunnistamo' string is assigned to an env var, but 'tunnistus' is just a plain string without a reference to a variable. Looks a bit odd, but is there a reason for it? Could it be a bit cleaner if 'tunnistus' could also be defined in variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is defined in VITE_OIDC_PROVIDER, || 'tunnistus' is a fallback default value.
How do you suggest to change it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be defined as DEFAULT_PROVIDER_NAME. But I'm not sure, doesn't feel necessary, because when I think about it more, the string 'tunnistus' is used only here. Maybe defining it in a variable becomes necessary only if the exact 'tunnistus' string is used in several places, to avoid the pitfall of mistyping. So maybe there is no need to define it in a variable in these changes.

@henrinie-nc
Copy link
Contributor Author

The code changes look ok to me. However, I recommend adding an explanation to Tunnistus vs Tunnistamo to the README. Those words are so similar that they are easily confused, and even when not, it is not clear what the difference is and what they are referring to. Will this documentation be added now or in a later PR?

I don't intend to document it. My reasoning is that it should be pretty clear from the constants.ts file itself what they mean, both options point to urls of those services.

@henrinie-nc henrinie-nc merged commit 7a6710e into develop Sep 25, 2024
3 checks passed
@henrinie-nc henrinie-nc deleted the fix-sso-provider-selection branch September 25, 2024 11:06
@@ -31,6 +33,9 @@ const loginProviderTunnistusProperties: LoginProviderProps = {
sessionPollerSettings: { pollIntervalInMs: 300000 } // 300000ms = 5min
};

export const useTunnistamoOpenIdConnect = import.meta.env.VITE_USE_TUNNISTAMO_OPENID_CONNECT === 'true' || import.meta.env.VITE_USE_TUNNISTAMO_OPENID_CONNECT === true;
export const oidcProviderName: OidcProviderName = import.meta.env.VITE_OIDC_PROVIDER || 'tunnistus';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be defined as DEFAULT_PROVIDER_NAME. But I'm not sure, doesn't feel necessary, because when I think about it more, the string 'tunnistus' is used only here. Maybe defining it in a variable becomes necessary only if the exact 'tunnistus' string is used in several places, to avoid the pitfall of mistyping. So maybe there is no need to define it in a variable in these changes.

@henrinie-nc
Copy link
Contributor Author

There is a type that has both options, it should check for mistyping. Ofc it wont do that in envvars or dotenv files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants