mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Auth: Hide forgot password if grafana auth is disabled (#79895)
* hide forgot password if grafana auth is disabled * fix test
This commit is contained in:
parent
e924627659
commit
5ae3249c36
@ -259,4 +259,6 @@ export interface AuthSettings {
|
|||||||
GoogleSkipOrgRoleSync?: boolean;
|
GoogleSkipOrgRoleSync?: boolean;
|
||||||
// @deprecated -- this is no longer used and will be removed in Grafana 11
|
// @deprecated -- this is no longer used and will be removed in Grafana 11
|
||||||
GenericOAuthSkipOrgRoleSync?: boolean;
|
GenericOAuthSkipOrgRoleSync?: boolean;
|
||||||
|
|
||||||
|
disableLogin?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@ type FrontendSettingsAuthDTO struct {
|
|||||||
GitLabSkipOrgRoleSync bool `json:"GitLabSkipOrgRoleSync"`
|
GitLabSkipOrgRoleSync bool `json:"GitLabSkipOrgRoleSync"`
|
||||||
// Deprecated: this is no longer used and will be removed in Grafana 11
|
// Deprecated: this is no longer used and will be removed in Grafana 11
|
||||||
OktaSkipOrgRoleSync bool `json:"OktaSkipOrgRoleSync"`
|
OktaSkipOrgRoleSync bool `json:"OktaSkipOrgRoleSync"`
|
||||||
|
|
||||||
|
DisableLogin bool `json:"disableLogin"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FrontendSettingsBuildInfoDTO struct {
|
type FrontendSettingsBuildInfoDTO struct {
|
||||||
|
@ -329,6 +329,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
|||||||
GithubSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.GitHubProviderName]),
|
GithubSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.GitHubProviderName]),
|
||||||
GitLabSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.GitlabProviderName]),
|
GitLabSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.GitlabProviderName]),
|
||||||
OktaSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.OktaProviderName]),
|
OktaSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.OktaProviderName]),
|
||||||
|
DisableLogin: hs.Cfg.DisableLogin,
|
||||||
}
|
}
|
||||||
|
|
||||||
if hs.pluginsCDNService != nil && hs.pluginsCDNService.IsEnabled() {
|
if hs.pluginsCDNService != nil && hs.pluginsCDNService.IsEnabled() {
|
||||||
|
@ -551,7 +551,7 @@ type Cfg struct {
|
|||||||
// AddChangePasswordLink returns if login form is disabled or not since
|
// AddChangePasswordLink returns if login form is disabled or not since
|
||||||
// the same intention can be used to hide both features.
|
// the same intention can be used to hide both features.
|
||||||
func (cfg *Cfg) AddChangePasswordLink() bool {
|
func (cfg *Cfg) AddChangePasswordLink() bool {
|
||||||
return !cfg.DisableLoginForm
|
return !(cfg.DisableLoginForm || cfg.DisableLogin)
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandLineArgs struct {
|
type CommandLineArgs struct {
|
||||||
|
@ -14,6 +14,9 @@ jest.mock('@grafana/runtime', () => ({
|
|||||||
post: postMock,
|
post: postMock,
|
||||||
}),
|
}),
|
||||||
config: {
|
config: {
|
||||||
|
auth: {
|
||||||
|
disableLogin: false,
|
||||||
|
},
|
||||||
loginError: false,
|
loginError: false,
|
||||||
buildInfo: {
|
buildInfo: {
|
||||||
version: 'v1.0',
|
version: 'v1.0',
|
||||||
|
@ -4,9 +4,9 @@ import React from 'react';
|
|||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
|
import { config } from '@grafana/runtime';
|
||||||
import { Alert, HorizontalGroup, LinkButton, useStyles2 } from '@grafana/ui';
|
import { Alert, HorizontalGroup, LinkButton, useStyles2 } from '@grafana/ui';
|
||||||
import { Branding } from 'app/core/components/Branding/Branding';
|
import { Branding } from 'app/core/components/Branding/Branding';
|
||||||
import config from 'app/core/config';
|
|
||||||
import { t } from 'app/core/internationalization';
|
import { t } from 'app/core/internationalization';
|
||||||
|
|
||||||
import { ChangePassword } from '../ForgottenPassword/ChangePassword';
|
import { ChangePassword } from '../ForgottenPassword/ChangePassword';
|
||||||
@ -48,13 +48,15 @@ export const LoginPage = () => {
|
|||||||
{!disableLoginForm && (
|
{!disableLoginForm && (
|
||||||
<LoginForm onSubmit={login} loginHint={loginHint} passwordHint={passwordHint} isLoggingIn={isLoggingIn}>
|
<LoginForm onSubmit={login} loginHint={loginHint} passwordHint={passwordHint} isLoggingIn={isLoggingIn}>
|
||||||
<HorizontalGroup justify="flex-end">
|
<HorizontalGroup justify="flex-end">
|
||||||
<LinkButton
|
{!config.auth.disableLogin && (
|
||||||
className={styles.forgottenPassword}
|
<LinkButton
|
||||||
fill="text"
|
className={styles.forgottenPassword}
|
||||||
href={`${config.appSubUrl}/user/password/send-reset-email`}
|
fill="text"
|
||||||
>
|
href={`${config.appSubUrl}/user/password/send-reset-email`}
|
||||||
Forgot your password?
|
>
|
||||||
</LinkButton>
|
Forgot your password?
|
||||||
|
</LinkButton>
|
||||||
|
)}
|
||||||
</HorizontalGroup>
|
</HorizontalGroup>
|
||||||
</LoginForm>
|
</LoginForm>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user