Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/client/webclient/webconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@ type WebConfigAuthSettings struct {
LocalConnectorName string `json:"localConnectorName,omitempty"`
// PrivateKeyPolicy is the configured private key policy for the cluster.
PrivateKeyPolicy keys.PrivateKeyPolicy `json:"privateKeyPolicy,omitempty"`
// MOTD is message of the day. MOTD is displayed to users before login.
MOTD string `json:"motd"`
}
1 change: 1 addition & 0 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,7 @@ func (h *Handler) getWebConfig(w http.ResponseWriter, r *http.Request, p httprou
PreferredLocalMFA: cap.GetPreferredLocalMFA(),
LocalConnectorName: localConnectorName,
PrivateKeyPolicy: cap.GetPrivateKeyPolicy(),
MOTD: cap.GetMessageOfTheDay(),
Comment thread
flyinghermit marked this conversation as resolved.
}
}

Expand Down
43 changes: 27 additions & 16 deletions web/packages/teleport/src/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import React, { useState } from 'react';

import logoSrc from 'design/assets/images/teleport-medallion.svg';

import FormLogin from 'teleport/components/FormLogin';
import Logo from 'teleport/components/LogoHero';

import useLogin, { State } from './useLogin';
import Motd from './MOTD';

export default function Container() {
const state = useLogin();
Expand All @@ -41,25 +42,35 @@ export function Login({
isPasswordlessEnabled,
primaryAuthType,
privateKeyPolicyEnabled,
motd,
}: State) {
const [showMOTD, setShowMOTD] = useState<boolean>(true);
Comment thread
flyinghermit marked this conversation as resolved.
Outdated
Comment thread
flyinghermit marked this conversation as resolved.
Outdated

const acknowledgeMOTD = () => {
setShowMOTD(false);
};
return (
<>
<Logo src={logoSrc} />
<FormLogin
title={'Sign in to Teleport'}
authProviders={authProviders}
auth2faType={auth2faType}
preferredMfaType={preferredMfaType}
isLocalAuthEnabled={isLocalAuthEnabled}
onLoginWithSso={onLoginWithSso}
onLoginWithWebauthn={onLoginWithWebauthn}
onLogin={onLogin}
attempt={attempt}
clearAttempt={clearAttempt}
isPasswordlessEnabled={isPasswordlessEnabled}
primaryAuthType={primaryAuthType}
privateKeyPolicyEnabled={privateKeyPolicyEnabled}
/>
{motd && showMOTD ? (
Comment thread
flyinghermit marked this conversation as resolved.
Outdated
<Motd message={motd} onClick={acknowledgeMOTD} />
Comment thread
flyinghermit marked this conversation as resolved.
Outdated
) : (
<FormLogin
title={'Sign in to Teleport'}
authProviders={authProviders}
auth2faType={auth2faType}
preferredMfaType={preferredMfaType}
isLocalAuthEnabled={isLocalAuthEnabled}
onLoginWithSso={onLoginWithSso}
onLoginWithWebauthn={onLoginWithWebauthn}
onLogin={onLogin}
attempt={attempt}
clearAttempt={clearAttempt}
isPasswordlessEnabled={isPasswordlessEnabled}
primaryAuthType={primaryAuthType}
privateKeyPolicyEnabled={privateKeyPolicyEnabled}
/>
)}
</>
);
}
41 changes: 41 additions & 0 deletions web/packages/teleport/src/Login/MOTD/MOTD.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2023 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { Card, Box, Text, ButtonPrimary } from 'design';

export function MOTD({ message, onClick }: Props) {
return (
<Card bg="levels.surface" my={6} mx="auto" width="464px">
<Box p={6}>
<Text typography="h2" mb={3} textAlign="center" color="text.main">
Message of the day!
Comment thread
flyinghermit marked this conversation as resolved.
Outdated
</Text>
<Text typography="h5" mb={3} textAlign="center">
{message}
</Text>
<ButtonPrimary width="100%" mt={3} size="large" onClick={onClick}>
Continue
Comment thread
flyinghermit marked this conversation as resolved.
Outdated
</ButtonPrimary>
</Box>
</Card>
);
}

type Props = {
message: string;
onClick(): void;
};
17 changes: 17 additions & 0 deletions web/packages/teleport/src/Login/MOTD/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2023 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

export { MOTD as default } from './MOTD';
Comment thread
flyinghermit marked this conversation as resolved.
Outdated
2 changes: 2 additions & 0 deletions web/packages/teleport/src/Login/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function useLogin() {
const authProviders = cfg.getAuthProviders();
const auth2faType = cfg.getAuth2faType();
const isLocalAuthEnabled = cfg.getLocalAuthFlag();
const motd = cfg.getMOTD();

function onLogin(email, password, token) {
attemptActions.start();
Expand Down Expand Up @@ -87,6 +88,7 @@ export default function useLogin() {
isPasswordlessEnabled: cfg.isPasswordlessEnabled(),
primaryAuthType: cfg.getPrimaryAuthType(),
privateKeyPolicyEnabled,
motd,
};
}

Expand Down
6 changes: 6 additions & 0 deletions web/packages/teleport/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const cfg = {
authType: 'local' as AuthType,
preferredLocalMfa: '' as PreferredMfaType,
privateKeyPolicy: 'none' as PrivateKeyPolicy,
// MOTD is message of the day, displayed to users before login.
Comment thread
flyinghermit marked this conversation as resolved.
Outdated
motd: '',
},

proxyCluster: 'localhost',
Expand Down Expand Up @@ -280,6 +282,10 @@ const cfg = {
return cfg.auth ? cfg.auth.preferredLocalMfa : null;
},

getMOTD() {
return cfg.auth ? cfg.auth.motd : null;
},
Comment thread
flyinghermit marked this conversation as resolved.
Outdated

getLocalAuthFlag() {
return cfg.auth.localAuthEnabled;
},
Expand Down