Skip to content

Commit

Permalink
Change login placeholders for remote authenticator (#8519)
Browse files Browse the repository at this point in the history
  • Loading branch information
guy-har authored Jan 23, 2025
1 parent 49becea commit f0ee280
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ OPENAPI_RUST_GENERATOR_IMAGE=openapitools/openapi-generator-cli:v7.5.0
OPENAPI_RUST_GENERATOR=$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_RUST_GENERATOR_IMAGE)
PY_OPENAPI_GENERATOR=$(DOCKER) run -e PYTHON_POST_PROCESS_FILE="/mnt/clients/python/scripts/pydantic.sh" --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_GENERATOR_IMAGE)

GOLANGCI_LINT_VERSION=v1.63.1
GOLANGCI_LINT_VERSION=v1.63.4
BUF_CLI_VERSION=v1.28.1

ifndef PACKAGE_VERSION
Expand Down
8 changes: 8 additions & 0 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,14 @@ components:
with an external auth service.
type: string
enum: [none, simplified, external]
username_ui_placeholder:
description: |
Placeholder text to display in the username field of the login form.
type: string
password_ui_placeholder:
description: |
Placeholder text to display in the password field of the login form.
type: string
login_url:
description: primary URL to use for login.
type: string
Expand Down
12 changes: 12 additions & 0 deletions clients/java/api/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions clients/java/docs/LoginConfig.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions clients/python/docs/LoginConfig.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion clients/python/lakefs_sdk/models/login_config.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions clients/python/test/test_login_config.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions clients/python/test/test_setup_state.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions clients/rust/docs/LoginConfig.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions clients/rust/src/models/login_config.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/assets/js/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,14 @@ components:
with an external auth service.
type: string
enum: [none, simplified, external]
username_ui_placeholder:
description: |
Placeholder text to display in the username field of the login form.
type: string
password_ui_placeholder:
description: |
Placeholder text to display in the password field of the login form.
type: string
login_url:
description: primary URL to use for login.
type: string
Expand Down
2 changes: 1 addition & 1 deletion docs/posts/deprecate-py-legacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ That is also going away. However we see much less usage of it.

### Where can I ask another question not covered here?

As always, our Slack htttps://lakefs.io/slack is the best place to interact
As always, our Slack https://lakefs.io/slack is the best place to interact
with the lakeFS community! Try asking on our `#dev` channel


Expand Down
10 changes: 9 additions & 1 deletion pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const (

pullRequestClosed = "CLOSED"
pullRequestOpen = "OPEN"

usernamePlaceholder = "Username"
passwordPlaceholder = "Password"
)

type actionsHandler interface {
Expand Down Expand Up @@ -4977,7 +4980,7 @@ func (c *Controller) GetTag(w http.ResponseWriter, r *http.Request, repository,
}

func newLoginConfig(c *config.BaseConfig) *apigen.LoginConfig {
return &apigen.LoginConfig{
loginConfig := &apigen.LoginConfig{
RBAC: &c.Auth.UIConfig.RBAC,
LoginUrl: c.Auth.UIConfig.LoginURL,
LoginFailedMessage: &c.Auth.UIConfig.LoginFailedMessage,
Expand All @@ -4986,6 +4989,11 @@ func newLoginConfig(c *config.BaseConfig) *apigen.LoginConfig {
LoginCookieNames: c.Auth.UIConfig.LoginCookieNames,
LogoutUrl: c.Auth.UIConfig.LogoutURL,
}
if c.UseUILoginPlaceholders() {
loginConfig.UsernameUiPlaceholder = swag.String(usernamePlaceholder)
loginConfig.PasswordUiPlaceholder = swag.String(passwordPlaceholder)
}
return loginConfig
}

func (c *Controller) GetSetupState(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 6 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,12 @@ func (c *BaseConfig) IsExternalPrincipalsEnabled() bool {
return c.IsAuthTypeAPI() && c.Auth.AuthenticationAPI.ExternalPrincipalsEnabled
}

// UseUILoginPlaceholders returns true if the UI should use placeholders for login
// the UI should use place holders just in case of LDAP, the other auth methods should have their own login page
func (c *BaseConfig) UseUILoginPlaceholders() bool {
return c.Auth.RemoteAuthenticator.Enabled
}

func (c *BaseConfig) IsAdvancedAuth() bool {
return c.IsAuthTypeAPI() && (c.Auth.UIConfig.RBAC == AuthRBACExternal || c.Auth.UIConfig.RBAC == AuthRBACInternal)
}
Expand Down
10 changes: 7 additions & 3 deletions webui/src/pages/auth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {useAPI} from "../../lib/hooks/api";

interface LoginConfig {
login_url: string;
username_ui_placeholder: string;
password_ui_placeholder: string;
login_failed_message?: string;
fallback_login_url?: string;
fallback_login_label?: string;
Expand All @@ -22,7 +24,9 @@ const LoginForm = ({loginConfig}: {loginConfig: LoginConfig}) => {
const router = useRouter();
const [loginError, setLoginError] = useState(null);
const { next } = router.query;

console.log(loginConfig);
const usernamePlaceholder = loginConfig.username_ui_placeholder || "Access Key ID";
const passwordPlaceholder = loginConfig.password_ui_placeholder || "Secret Access Key";
return (
<Row>
<Col md={{offset: 4, span: 4}}>
Expand All @@ -44,11 +48,11 @@ const LoginForm = ({loginConfig}: {loginConfig: LoginConfig}) => {
}
}}>
<Form.Group controlId="username" className="mb-3">
<Form.Control type="text" placeholder={"Access Key ID"} autoFocus/>
<Form.Control type="text" placeholder={usernamePlaceholder} autoFocus/>
</Form.Group>

<Form.Group controlId="password" className="mb-3">
<Form.Control type="password" placeholder={"Secret Access Key"}/>
<Form.Control type="password" placeholder={passwordPlaceholder}/>
</Form.Group>

{(!!loginError) && <AlertError error={loginError}/>}
Expand Down

0 comments on commit f0ee280

Please sign in to comment.