You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vincbeck (via GitHub)" <gi...@apache.org> on 2025/01/15 22:16:58 UTC
[PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
vincbeck opened a new pull request, #45696:
URL: https://github.com/apache/airflow/pull/45696
`SimpleAuthManager` is a minimalist auth manager in core Airflow. It defines its own login form in order for users to log in. Example below:

Simple auth manager has its UI defined using Flask, you can then use it with Airflow 2 UI. But the goal is to use simple auth manager in Airflow 3. In order to use simple auth manager with Airflow 3 UI, we need to implement its views in the fastapi application. This is the goal of this PR.
After this PR is merged, I'll remove the UI/views definitions of simple auth manager in Flask. We do not need the simple auth manager to be compatible with Airflow 2 UI (although that was necessary for testing it).
As a result of this PR, multiple endpoints are added:
- <env_endpoint>/auth/webapp/login: the login form
- <env_endpoint>/auth/static/assets/index-......js: the JS/React artifact defining the login form
- POST <env_endpoint>/auth/token: to create a JWT token given username and password
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2602610114
> That's a little unclear for me where we're at and what we want to do for auth managers.
>
> For other auth managers, especially FAB one, do we plan to use the flask middleware to be able to render all of those flask views into fastapi ? (avoiding the flask <-> fastapi convertion, I think this is what was suggested by Jed.)
>
> Then we only do this work for the simple auth manager because we do not need backward compat and because it's more convenient to have that in native FastAPI ?
Yes to everything :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #45696:
URL: https://github.com/apache/airflow/pull/45696#discussion_r1919076869
##########
airflow/auth/managers/simple/ui/src/queryClient.ts:
##########
@@ -0,0 +1,36 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 { QueryClient } from "@tanstack/react-query";
+
+export const queryClient = new QueryClient({
+ defaultOptions: {
+ mutations: {
+ retry: 1,
+ retryDelay: 500,
+ },
+ queries: {
+ initialDataUpdatedAt: new Date().setMinutes(-6), // make sure initial data is already expired
+ refetchOnMount: true, // Refetches stale queries, not "always"
+ refetchOnWindowFocus: false,
+ retry: 1,
+ retryDelay: 500,
+ staleTime: 5 * 60 * 1000, // 5 minutes
+ },
+ },
Review Comment:
Thanks for the catch
##########
airflow/auth/managers/simple/ui/src/login/Controller.tsx:
##########
Review Comment:
Makes sense
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2602922129
tldr core + simple auth manager should not require flask to be installed at all.
That ship has already sailed if you are using the fab auth manager though, so might as well use the middleware and not rewrite stuff.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2603009251
> tldr core + simple auth manager should not require flask to be installed at all.
>
> That ship has already sailed if you are using the fab auth manager though, so might as well use the middleware and not rewrite stuff.
Yep, this is what I did in #45765 for FAB :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #45696:
URL: https://github.com/apache/airflow/pull/45696#discussion_r1919077689
##########
airflow/auth/managers/simple/ui/src/login/Form.tsx:
##########
@@ -0,0 +1,67 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 {Button, Field, Input, Stack} from "@chakra-ui/react";
+import {Controller, useForm} from "react-hook-form";
+import {LoginBody} from "./Controller";
+
+type LoginFormProps = {
+ readonly onLogin: (loginBody: LoginBody) => string;
+ readonly isPending: boolean;
+};
+
+export const LoginForm = ({ onLogin, isPending }: LoginFormProps) => {
+ const {
+ control, handleSubmit,
+ formState: { isValid },
+ } = useForm<LoginBody>({
+ defaultValues: {
+ username: "", password: "",
+ },
+ });
+
+ return <Stack spacing={4}>
+ <Controller
+ name="username"
+ control={control}
+ render={({field, fieldState}) => (
+ <Field.Root invalid={Boolean(fieldState.error)} required>
+ <Field.Label>Username</Field.Label>
+ <Input {...field} />
+ </Field.Root>)}
+ rules={{required: true}}
+ />
+
+ <Controller
+ name="password"
+ control={control}
+ render={({field, fieldState}) => (
+ <Field.Root invalid={Boolean(fieldState.error)} required>
+ <Field.Label>Username</Field.Label>
Review Comment:
Oopsie
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2605114083
> Any other concerns/questions?
No, thanks for answering my questions.
I think Brent is already working on the review and functional testing for this PR, he might loop back, let me know if you need a second pair of eyes, I don't want to duplicate the work if not needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2605126975
> > Any other concerns/questions?
>
> No, thanks for answering my questions.
>
> Overall code looks good and I agree with the general approach.
>
> I think Brent is already working on a detailed review and functional testing.
Fantastic! Thank you :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #45696:
URL: https://github.com/apache/airflow/pull/45696#discussion_r1917413841
##########
airflow/auth/managers/simple/simple_auth_manager.py:
##########
@@ -97,31 +101,36 @@
users = [u.split(":") for u in conf.getlist("core", "simple_auth_manager_users")]
return [{"username": username, "role": role} for username, role in users]
- def init(self) -> None:
+ @staticmethod
+ def get_passwords(users: list[dict[str, str]]) -> dict[str, str]:
user_passwords_from_file = {}
# Read passwords from file
- if os.path.isfile(self.get_generated_password_file()):
- with open(self.get_generated_password_file()) as file:
+ password_file = SimpleAuthManager.get_generated_password_file()
+ if os.path.isfile(password_file):
+ with open(password_file) as file:
passwords_str = file.read().strip()
user_passwords_from_file = json.loads(passwords_str)
- users = self.get_users()
usernames = {user["username"] for user in users}
- self.passwords = {
+ return {
username: password
for username, password in user_passwords_from_file.items()
if username in usernames
}
+
+ def init(self) -> None:
+ users = self.get_users()
+ passwords = self.get_passwords(users)
for user in users:
- if user["username"] not in self.passwords:
+ if user["username"] not in passwords:
# User dot not exist in the file, adding it
- self.passwords[user["username"]] = self._generate_password()
+ passwords[user["username"]] = self._generate_password()
- self._print_output(f"Password for user '{user['username']}': {self.passwords[user['username']]}")
+ self._print_output(f"Password for user '{user['username']}': {passwords[user['username']]}")
with open(self.get_generated_password_file(), "w") as file:
- file.write(json.dumps(self.passwords))
+ file.write(json.dumps(passwords))
Review Comment:
## Clear-text storage of sensitive information
This expression stores [sensitive data (password)](1) as clear text.
This expression stores [sensitive data (password)](2) as clear text.
This expression stores [sensitive data (password)](3) as clear text.
This expression stores [sensitive data (password)](4) as clear text.
[Show more details](https://github.com/apache/airflow/security/code-scanning/347)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #45696:
URL: https://github.com/apache/airflow/pull/45696#discussion_r1918745899
##########
airflow/auth/managers/simple/ui/src/login/Controller.tsx:
##########
@@ -0,0 +1,65 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/* global document */
+
+import React from "react";
+import {Alert, Container, Heading, Text} from "@chakra-ui/react";
+
+import {useCreateToken} from "src/queries/useCreateToken";
+import {LoginForm} from "src/login/Form";
+import type {ApiError} from "openapi-gen/requests/core/ApiError";
+import type {LoginResponse, HTTPExceptionResponse, HTTPValidationError} from "openapi-gen/requests/types.gen";
+
+export type LoginBody = {
+ username: string; password: string;
+};
+
+type ExpandedApiError = {
+ body: HTTPExceptionResponse | HTTPValidationError;
+} & ApiError;
+
+export const Login = () => {
+ const onSuccess = (data: LoginResponse) => {
+ // Redirect to index page with the token
+ globalThis.location.replace(`/webapp/?token=${data.jwt_token}`);
Review Comment:
We'll need to remember to change this whenever we drop the `/webapp`. Or better, have one source of truth on the UI base route
##########
airflow/auth/managers/simple/ui/src/login/Controller.tsx:
##########
@@ -0,0 +1,65 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/* global document */
Review Comment:
```suggestion
```
We don't need this.
##########
airflow/auth/managers/simple/ui/src/login/Form.tsx:
##########
@@ -0,0 +1,67 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 {Button, Field, Input, Stack} from "@chakra-ui/react";
+import {Controller, useForm} from "react-hook-form";
+import {LoginBody} from "./Controller";
+
+type LoginFormProps = {
+ readonly onLogin: (loginBody: LoginBody) => string;
+ readonly isPending: boolean;
+};
+
+export const LoginForm = ({ onLogin, isPending }: LoginFormProps) => {
+ const {
+ control, handleSubmit,
+ formState: { isValid },
+ } = useForm<LoginBody>({
+ defaultValues: {
+ username: "", password: "",
+ },
+ });
+
+ return <Stack spacing={4}>
+ <Controller
+ name="username"
+ control={control}
+ render={({field, fieldState}) => (
+ <Field.Root invalid={Boolean(fieldState.error)} required>
+ <Field.Label>Username</Field.Label>
+ <Input {...field} />
+ </Field.Root>)}
+ rules={{required: true}}
+ />
+
+ <Controller
+ name="password"
+ control={control}
+ render={({field, fieldState}) => (
+ <Field.Root invalid={Boolean(fieldState.error)} required>
+ <Field.Label>Username</Field.Label>
Review Comment:
```suggestion
<Field.Label>Password</Field.Label>
```
##########
airflow/auth/managers/simple/ui/src/login/index.test.tsx:
##########
@@ -0,0 +1,43 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/* global describe */
Review Comment:
```suggestion
```
##########
airflow/auth/managers/simple/ui/src/login/Form.tsx:
##########
@@ -0,0 +1,67 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 {Button, Field, Input, Stack} from "@chakra-ui/react";
+import {Controller, useForm} from "react-hook-form";
+import {LoginBody} from "./Controller";
+
+type LoginFormProps = {
+ readonly onLogin: (loginBody: LoginBody) => string;
+ readonly isPending: boolean;
+};
+
+export const LoginForm = ({ onLogin, isPending }: LoginFormProps) => {
+ const {
+ control, handleSubmit,
+ formState: { isValid },
+ } = useForm<LoginBody>({
+ defaultValues: {
+ username: "", password: "",
+ },
+ });
+
+ return <Stack spacing={4}>
+ <Controller
+ name="username"
+ control={control}
+ render={({field, fieldState}) => (
+ <Field.Root invalid={Boolean(fieldState.error)} required>
+ <Field.Label>Username</Field.Label>
+ <Input {...field} />
+ </Field.Root>)}
+ rules={{required: true}}
+ />
+
+ <Controller
+ name="password"
+ control={control}
+ render={({field, fieldState}) => (
+ <Field.Root invalid={Boolean(fieldState.error)} required>
+ <Field.Label>Username</Field.Label>
+ <Input {...field} type="password"/>
+ </Field.Root>)}
+ rules={{required: true}}
+ />
+
+ <Button disabled={!isValid || isPending} colorPalette="blue" onClick={() => void handleSubmit(onLogin)()}>
Review Comment:
Let's add a `type="submit"` here and wrap the <Stack> component with `<form></form>`. Then one can hit enter/return without having to focus on the Sign In button itself
##########
airflow/auth/managers/simple/ui/src/test-utils.tsx:
##########
@@ -0,0 +1,36 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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, { PropsWithChildren } from "react";
+import { ChakraProvider } from "@chakra-ui/react";
+import { MemoryRouter, MemoryRouterProps } from "react-router-dom";
+
+interface WrapperProps extends PropsWithChildren {
+ initialEntries?: MemoryRouterProps["initialEntries"];
+}
+
+export const Wrapper = ({ initialEntries, children }: WrapperProps) => {
+ return (
+ <ChakraProvider>
Review Comment:
```suggestion
<ChakraProvider value={defaultSystem}>
<QueryClientProvider client={queryClient}>
```
We need to pass the defaultSystem and also add a queryClient to our wrapper
##########
airflow/auth/managers/simple/ui/src/queryClient.ts:
##########
@@ -0,0 +1,36 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 { QueryClient } from "@tanstack/react-query";
+
+export const queryClient = new QueryClient({
+ defaultOptions: {
+ mutations: {
+ retry: 1,
+ retryDelay: 500,
+ },
+ queries: {
+ initialDataUpdatedAt: new Date().setMinutes(-6), // make sure initial data is already expired
+ refetchOnMount: true, // Refetches stale queries, not "always"
+ refetchOnWindowFocus: false,
+ retry: 1,
+ retryDelay: 500,
+ staleTime: 5 * 60 * 1000, // 5 minutes
+ },
+ },
Review Comment:
We don't have any queries and only one mutation, log in. So I don't think this is necessary.
##########
airflow/auth/managers/simple/ui/src/login/Controller.tsx:
##########
Review Comment:
Let's have the file name match the component name `Login.tsx`
##########
airflow/auth/managers/simple/ui/src/login/index.test.tsx:
##########
Review Comment:
`Login.test.tsx`
##########
airflow/auth/managers/simple/ui/src/login/Form.tsx:
##########
Review Comment:
`LoginForm.tsx`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #45696:
URL: https://github.com/apache/airflow/pull/45696#discussion_r1919076424
##########
airflow/auth/managers/simple/ui/src/login/Form.tsx:
##########
@@ -0,0 +1,67 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 {Button, Field, Input, Stack} from "@chakra-ui/react";
+import {Controller, useForm} from "react-hook-form";
+import {LoginBody} from "./Controller";
+
+type LoginFormProps = {
+ readonly onLogin: (loginBody: LoginBody) => string;
+ readonly isPending: boolean;
+};
+
+export const LoginForm = ({ onLogin, isPending }: LoginFormProps) => {
+ const {
+ control, handleSubmit,
+ formState: { isValid },
+ } = useForm<LoginBody>({
+ defaultValues: {
+ username: "", password: "",
+ },
+ });
+
+ return <Stack spacing={4}>
+ <Controller
+ name="username"
+ control={control}
+ render={({field, fieldState}) => (
+ <Field.Root invalid={Boolean(fieldState.error)} required>
+ <Field.Label>Username</Field.Label>
+ <Input {...field} />
+ </Field.Root>)}
+ rules={{required: true}}
+ />
+
+ <Controller
+ name="password"
+ control={control}
+ render={({field, fieldState}) => (
+ <Field.Root invalid={Boolean(fieldState.error)} required>
+ <Field.Label>Username</Field.Label>
+ <Input {...field} type="password"/>
+ </Field.Root>)}
+ rules={{required: true}}
+ />
+
+ <Button disabled={!isValid || isPending} colorPalette="blue" onClick={() => void handleSubmit(onLogin)()}>
Review Comment:
Sounds good
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #45696:
URL: https://github.com/apache/airflow/pull/45696
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2608236694
I dont understand what is going on ... The command `breeze release-management prepare-airflow-package --package-format wheel` fails because the pre-commit `Compile ui assets (manual)` fails because of `sh: 1: vite: not found`. See [error](https://github.com/apache/airflow/actions/runs/12916300336/job/36020735118?pr=45696).
However when I run the script `scripts/ci/pre_commit/compile_ui_assets.py` locally, it works like a charm. `vite` is listed in `package.json` so I really dont understand why it cannot find it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2596839843
> Tested locally. It works!
>
> I'd like us to match the main UI's setup a bit more. Use `pnpm` instead of `npm` and I want to see if we can share the same linting/prettier rules.
I agree that would be great. I made multiple tries but could not come up with something working. Typescript could not recognize types defined in the simple auth manager UI directory. We could give it another try later. I dont think this is a must have for now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2605123850
Question for the audience :)
I am looking into updating the basic tests to include tests from the simple auth manager UI as part of the [tests-ui](https://github.com/apache/airflow/blob/main/.github/workflows/basic-tests.yml#L87). Some caching is done that I am not familiar with. Do I need to do the same or just
```
- run: cd airflow/auth/managers/simple/ui && pnpm install --frozen-lockfile
- run: cd airflow/auth/managers/simple/ui && pnpm test
env:
FORCE_COLOR: 2
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2605160908
> Question for the audience :)
> I am looking into updating the basic tests to include tests from the simple auth manager UI as part of the [tests-ui](https://github.com/apache/airflow/blob/main/.github/workflows/basic-tests.yml#L87). Some caching is done that I am not familiar with. Do I need to do the same or just
I am not super familiar with this workflow but by the look of it I would say that caching the node_modules is always helpful. I think we can just follow the same logic and apply that to the `airflow/auth/managers/simple/ui/node_modules` folder.
(basically duplicating the Restore and Save cache before trying to `pnpm install`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update Simple auth manager to define its UI (login form) using fastapi [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #45696:
URL: https://github.com/apache/airflow/pull/45696#issuecomment-2603294050
Any other concerns/questions?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org