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

feat: github enterprise SSO provider addition #3914

Merged
merged 2 commits into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/hoppscotch-common/locales/en.json
Expand Up @@ -103,8 +103,10 @@
"auth": {
"account_exists": "Account exists with different credential - Login to link both accounts",
"all_sign_in_options": "All sign in options",
"continue_with_auth_provider": "Continue with {provider}",
"continue_with_email": "Continue with Email",
"continue_with_github": "Continue with GitHub",
"continue_with_github_enterprise": "Continue with GitHub Enterprise",
"continue_with_google": "Continue with Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Email",
Expand Down
45 changes: 38 additions & 7 deletions packages/hoppscotch-common/src/components/firebase/Login.vue
Expand Up @@ -23,10 +23,10 @@
@click="provider.action"
/>

<hr v-if="additonalLoginItems.length > 0" />
<hr v-if="additionalLoginItems.length > 0" />

<HoppSmartItem
v-for="loginItem in additonalLoginItems"
v-for="loginItem in additionalLoginItems"
:key="loginItem.id"
:icon="loginItem.icon"
:label="loginItem.text(t)"
Expand Down Expand Up @@ -170,7 +170,7 @@ type AuthProviderItem = {
}

let allowedAuthProviders: AuthProviderItem[] = []
let additonalLoginItems: LoginItemDef[] = []
const additionalLoginItems: LoginItemDef[] = []

const doAdditionalLoginItemClickAction = async (item: LoginItemDef) => {
await item.onClick()
Expand Down Expand Up @@ -199,10 +199,33 @@ onMounted(async () => {
allowedAuthProviders = enabledAuthProviders

// setup the additional login items
additonalLoginItems =
platform.auth.additionalLoginItems?.filter((item) =>
res.right.includes(item.id)
) ?? []
platform.auth.additionalLoginItems?.forEach((item) => {
if (res.right.includes(item.id)) {
additionalLoginItems.push(item)
}

// since the BE send the OIDC auth providers as OIDC:providerName,
// we need to split the string and use the providerName as the text
if (item.id === "OIDC") {
res.right
.filter((provider) => provider.startsWith("OIDC"))
.forEach((provider) => {
const OIDCName = provider.split(":")[1]
const loginItemText = OIDCName
? () =>
t("auth.continue_with_auth_provider", {
provider: OIDCName,
})
: item.text

const OIDCLoginItem = {
...item,
text: loginItemText,
}
additionalLoginItems.push(OIDCLoginItem)
})
}
})

isLoadingAllowedAuthProviders.value = false
})
Expand Down Expand Up @@ -311,6 +334,14 @@ const authProvidersAvailable: AuthProviderItem[] = [
action: signInWithGithub,
isLoading: signingInWithGitHub,
},
// the authprovider either send github or github:enterprise and both are handled by the same route
{
id: "GITHUB:ENTERPRISE",
icon: IconGithub,
label: t("auth.continue_with_github_enterprise"),
action: signInWithGithub,
isLoading: signingInWithGitHub,
},
{
id: "GOOGLE",
icon: IconGoogle,
Expand Down