Skip to content

Commit

Permalink
Add provider name to be shown at the login screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cmintey committed Jan 4, 2024
1 parent b06598a commit 2ff8ef9
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ For usage, see [Usage - OpenID Connect](../usage/oidc.md)
| OIDC_CLIENT_ID | None | The client id of your configured client in your provider |
| OIDC_ADMIN_GROUP | None | If this group is present in the group claims, the user will be set as an admin |
| OIDC_ALWAYS_REDIRECT | False | If `True`, then the login page will be bypassed an you will be sent directly to your Identity Provider. You can still get to the login page by adding `?direct=1` to the login URL |
| OIDC_PROVIDER_NAME | OAuth | The provider name is shown in SSO login button. "Login with <OIDC_PROVIDER_NAME\>" |

### Themeing

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/overrides/api.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/lang/messages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@
"link-id": "Link ID",
"link-name": "Link Name",
"login": "Login",
"login-oidc": "Login with OIDC",
"login-oidc": "Login with",
"or": "or",
"logout": "Logout",
"manage-users": "Manage Users",
Expand Down
2 changes: 2 additions & 0 deletions frontend/lib/api/types/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface AdminAboutInfo {
allowSignup: boolean;
enableOidc: boolean;
oidcRedirect: boolean;
oidcProviderName: string;
versionLatest: string;
apiPort: number;
apiDocs: boolean;
Expand All @@ -37,6 +38,7 @@ export interface AppInfo {
allowSignup: boolean;
enableOidc: boolean;
oidcRedirect: boolean;
oidcProviderName: string;
}
export interface AppStartupInfo {
isFirstLogin: boolean;
Expand Down
21 changes: 13 additions & 8 deletions frontend/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
</div>
<v-card-actions v-if="allowOidc" class="justify-center">
<div class="max-button">
<v-btn color="primary" large rounded class="rounded-xl" block @click.native="oidc_authenticate">
{{ $t("user.login-oidc") }}
<v-btn color="primary" large rounded class="rounded-xl" block @click.native="oidcAuthenticate">
{{ $t("user.login-oidc") }} {{ oidcProviderName }}
</v-btn>
</div>
</v-card-actions>
Expand Down Expand Up @@ -182,11 +182,15 @@ export default defineComponent({
const allowSignup = computed(() => appInfo.value?.allowSignup || false);
const allowOidc = computed(() => appInfo.value?.enableOidc || false);
const oidcRedirect = computed(() => appInfo.value?.allowSignup || false);
const oidcRedirect = computed(() => appInfo.value?.oidcRedirect || false);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
const oidcProviderName = computed(() => appInfo.value?.oidcProviderName || "OAuth")
if (allowOidc && oidcRedirect && !isCallback() && !isDirectLogin()) {
oidc_authenticate()
}
whenever(
() => allowOidc.value && oidcRedirect.value && !isCallback() && !isDirectLogin(),
() => oidcAuthenticate(),
{immediate: true}
)
function isCallback() {
return router.currentRoute.query.state;
Expand All @@ -196,7 +200,7 @@ export default defineComponent({
return router.currentRoute.query.direct
}
async function oidc_authenticate() {
async function oidcAuthenticate() {
try {
await $auth.loginWith("oidc")
} catch (error) {
Expand Down Expand Up @@ -243,7 +247,8 @@ export default defineComponent({
allowSignup,
allowOidc,
authenticate,
oidc_authenticate,
oidcAuthenticate,
oidcProviderName,
passwordIcon,
inputType,
togglePasswordShow,
Expand Down
1 change: 1 addition & 0 deletions mealie/core/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def LDAP_ENABLED(self) -> bool:
OIDC_SIGNUP_ENABLED: bool = True
OIDC_ADMIN_GROUP: NoneStr
OIDC_AUTO_REDIRECT: bool = False
OIDC_PROVIDER_NAME: str = "OAuth"

@property
def OIDC_READY(self) -> bool:
Expand Down
1 change: 1 addition & 0 deletions mealie/routes/app/app_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def get_app_info():
allow_signup=settings.ALLOW_SIGNUP,
enable_oidc=settings.OIDC_READY,
oidc_redirect=settings.OIDC_AUTO_REDIRECT,
oidc_provider_name=settings.OIDC_PROVIDER_NAME,
)


Expand Down
1 change: 1 addition & 0 deletions mealie/schema/admin/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class AppInfo(MealieModel):
allow_signup: bool
enable_oidc: bool
oidc_redirect: bool
oidc_provider_name: str


class AppTheme(MealieModel):
Expand Down
1 change: 1 addition & 0 deletions template.env
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ OIDC_AUTH_ENABLED=False
#OIDC_CONFIGURATION_URL=https://auth.example.com/.well-known/openid-configuration
#OIDC_CLIENT_ID=mealie
#OIDC_AUTO_REDIRECT=False
#OIDC_PROVIDER_NAME=OAuth

0 comments on commit 2ff8ef9

Please sign in to comment.