You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "aritra24 (via GitHub)" <gi...@apache.org> on 2025/03/30 11:59:00 UTC
[PR] Added linter for simple auth [airflow]
aritra24 opened a new pull request, #48550:
URL: https://github.com/apache/airflow/pull/48550
Added linter and ran it, a bunch of
the files are auto updated. Still some
linting issues to fix.
<!--
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 [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/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] Added linter for simple auth [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #48550:
URL: https://github.com/apache/airflow/pull/48550#issuecomment-2766256789
Great work! Just one comment and one conflict we need to resolve.
I agree with Vincent, it would be great to share the eslint config but this is a great start and we can figure that out later.
--
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] Added linter for simple auth [airflow]
Posted by "aritra24 (via GitHub)" <gi...@apache.org>.
aritra24 commented on code in PR #48550:
URL: https://github.com/apache/airflow/pull/48550#discussion_r2021060051
##########
airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/src/login/Login.tsx:
##########
@@ -17,84 +17,118 @@
* under the License.
*/
-import React, {useState} from "react";
-import {Alert, CloseButton, Container, Heading, Text} from "@chakra-ui/react";
+import { useState } from "react";
+import { Alert, CloseButton, Container, Heading, Text } from "@chakra-ui/react";
-import {useCreateToken} from "src/queries/useCreateToken";
-import {LoginForm} from "src/login/LoginForm";
-import type {ApiError} from "openapi-gen/requests/core/ApiError";
-import type {LoginResponse, HTTPExceptionResponse, HTTPValidationError} from "openapi-gen/requests/types.gen";
+import { useCreateToken } from "src/queries/useCreateToken";
+import { LoginForm } from "src/login/LoginForm";
+import type { ApiError } from "openapi-gen/requests/core/ApiError";
+import type {
+ LoginResponse,
+ HTTPExceptionResponse,
+ HTTPValidationError,
+} from "openapi-gen/requests/types.gen";
import { useSearchParams } from "react-router-dom";
-import { useCookies } from 'react-cookie';
+import { useCookies } from "react-cookie";
export type LoginBody = {
- username: string; password: string;
+ password: string;
+ username: string;
};
type ExpandedApiError = {
body: HTTPExceptionResponse | HTTPValidationError;
} & ApiError;
-const LOCAL_STORAGE_DISABLE_BANNER_KEY = "disable-sam-banner"
+const LOCAL_STORAGE_DISABLE_BANNER_KEY = "disable-sam-banner";
export const Login = () => {
- const [searchParams, setSearchParams] = useSearchParams();
- const [cookies, setCookie] = useCookies(['_token']);
- const [isBannerDisabled, setIsBannerDisabled] = useState(localStorage.getItem(LOCAL_STORAGE_DISABLE_BANNER_KEY))
+ const [searchParams] = useSearchParams();
+ const [, setCookie] = useCookies(["_token"]);
+ const [isBannerDisabled, setIsBannerDisabled] = useState(
+ localStorage.getItem(LOCAL_STORAGE_DISABLE_BANNER_KEY),
+ );
const onSuccess = (data: LoginResponse) => {
// Redirect to appropriate page with the token
- const next = searchParams.get("next")
+ const next = searchParams.get("next");
- setCookie('_token', data.jwt_token, {path: "/", secure: globalThis.location.protocol !== "http:"})
+ setCookie("_token", data.jwt_token, {
+ path: "/",
+ secure: globalThis.location.protocol !== "http:",
+ });
- globalThis.location.replace(`${next ?? ""}`);
- }
- const {createToken, error: err, isPending, setError} = useCreateToken({onSuccess});
+ globalThis.location.replace(next ?? "");
+ };
+ const {
+ createToken,
+ error: err,
+ isPending,
+ setError,
+ } = useCreateToken({ onSuccess });
const error = err as ExpandedApiError;
- const error_message = error?.body?.detail;
+ const errorMessage = error.body.detail;
Review Comment:
There's a couple more things that are failing too, will look into fixing all of them and push a change.
--
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] Added linter for simple auth [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #48550:
URL: https://github.com/apache/airflow/pull/48550
--
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] Added linter for simple auth [airflow]
Posted by "aritra24 (via GitHub)" <gi...@apache.org>.
aritra24 commented on PR #48550:
URL: https://github.com/apache/airflow/pull/48550#issuecomment-2766758626
I think all the stuff is fixed now, resolving the conflicts was long so some things might've fallen through the cracks. So would request a closer look at that part for review. I tried to be as careful as possible though so hopefully nothing was missed.
--
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] Added linter for simple auth [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #48550:
URL: https://github.com/apache/airflow/pull/48550#issuecomment-2767268385
Known issue in main. Merging
--
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] Added linter for simple auth [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #48550:
URL: https://github.com/apache/airflow/pull/48550#discussion_r2021056517
##########
airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/src/login/Login.tsx:
##########
@@ -17,84 +17,118 @@
* under the License.
*/
-import React, {useState} from "react";
-import {Alert, CloseButton, Container, Heading, Text} from "@chakra-ui/react";
+import { useState } from "react";
+import { Alert, CloseButton, Container, Heading, Text } from "@chakra-ui/react";
-import {useCreateToken} from "src/queries/useCreateToken";
-import {LoginForm} from "src/login/LoginForm";
-import type {ApiError} from "openapi-gen/requests/core/ApiError";
-import type {LoginResponse, HTTPExceptionResponse, HTTPValidationError} from "openapi-gen/requests/types.gen";
+import { useCreateToken } from "src/queries/useCreateToken";
+import { LoginForm } from "src/login/LoginForm";
+import type { ApiError } from "openapi-gen/requests/core/ApiError";
+import type {
+ LoginResponse,
+ HTTPExceptionResponse,
+ HTTPValidationError,
+} from "openapi-gen/requests/types.gen";
import { useSearchParams } from "react-router-dom";
-import { useCookies } from 'react-cookie';
+import { useCookies } from "react-cookie";
export type LoginBody = {
- username: string; password: string;
+ password: string;
+ username: string;
};
type ExpandedApiError = {
body: HTTPExceptionResponse | HTTPValidationError;
} & ApiError;
-const LOCAL_STORAGE_DISABLE_BANNER_KEY = "disable-sam-banner"
+const LOCAL_STORAGE_DISABLE_BANNER_KEY = "disable-sam-banner";
export const Login = () => {
- const [searchParams, setSearchParams] = useSearchParams();
- const [cookies, setCookie] = useCookies(['_token']);
- const [isBannerDisabled, setIsBannerDisabled] = useState(localStorage.getItem(LOCAL_STORAGE_DISABLE_BANNER_KEY))
+ const [searchParams] = useSearchParams();
+ const [, setCookie] = useCookies(["_token"]);
+ const [isBannerDisabled, setIsBannerDisabled] = useState(
+ localStorage.getItem(LOCAL_STORAGE_DISABLE_BANNER_KEY),
+ );
const onSuccess = (data: LoginResponse) => {
// Redirect to appropriate page with the token
- const next = searchParams.get("next")
+ const next = searchParams.get("next");
- setCookie('_token', data.jwt_token, {path: "/", secure: globalThis.location.protocol !== "http:"})
+ setCookie("_token", data.jwt_token, {
+ path: "/",
+ secure: globalThis.location.protocol !== "http:",
+ });
- globalThis.location.replace(`${next ?? ""}`);
- }
- const {createToken, error: err, isPending, setError} = useCreateToken({onSuccess});
+ globalThis.location.replace(next ?? "");
+ };
+ const {
+ createToken,
+ error: err,
+ isPending,
+ setError,
+ } = useCreateToken({ onSuccess });
const error = err as ExpandedApiError;
- const error_message = error?.body?.detail;
+ const errorMessage = error.body.detail;
Review Comment:
This is failing. We probably want to remove the `as ExpandedAPIError` casting above and make sure we handle if the error doesn't have a `body`
--
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] Added linter for simple auth [airflow]
Posted by "aritra24 (via GitHub)" <gi...@apache.org>.
aritra24 commented on code in PR #48550:
URL: https://github.com/apache/airflow/pull/48550#discussion_r2021059323
##########
airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/src/login/Login.tsx:
##########
@@ -17,84 +17,118 @@
* under the License.
*/
-import React, {useState} from "react";
-import {Alert, CloseButton, Container, Heading, Text} from "@chakra-ui/react";
+import { useState } from "react";
+import { Alert, CloseButton, Container, Heading, Text } from "@chakra-ui/react";
-import {useCreateToken} from "src/queries/useCreateToken";
-import {LoginForm} from "src/login/LoginForm";
-import type {ApiError} from "openapi-gen/requests/core/ApiError";
-import type {LoginResponse, HTTPExceptionResponse, HTTPValidationError} from "openapi-gen/requests/types.gen";
+import { useCreateToken } from "src/queries/useCreateToken";
+import { LoginForm } from "src/login/LoginForm";
+import type { ApiError } from "openapi-gen/requests/core/ApiError";
+import type {
+ LoginResponse,
+ HTTPExceptionResponse,
+ HTTPValidationError,
+} from "openapi-gen/requests/types.gen";
import { useSearchParams } from "react-router-dom";
-import { useCookies } from 'react-cookie';
+import { useCookies } from "react-cookie";
export type LoginBody = {
- username: string; password: string;
+ password: string;
+ username: string;
};
type ExpandedApiError = {
body: HTTPExceptionResponse | HTTPValidationError;
} & ApiError;
-const LOCAL_STORAGE_DISABLE_BANNER_KEY = "disable-sam-banner"
+const LOCAL_STORAGE_DISABLE_BANNER_KEY = "disable-sam-banner";
export const Login = () => {
- const [searchParams, setSearchParams] = useSearchParams();
- const [cookies, setCookie] = useCookies(['_token']);
- const [isBannerDisabled, setIsBannerDisabled] = useState(localStorage.getItem(LOCAL_STORAGE_DISABLE_BANNER_KEY))
+ const [searchParams] = useSearchParams();
+ const [, setCookie] = useCookies(["_token"]);
+ const [isBannerDisabled, setIsBannerDisabled] = useState(
+ localStorage.getItem(LOCAL_STORAGE_DISABLE_BANNER_KEY),
+ );
const onSuccess = (data: LoginResponse) => {
// Redirect to appropriate page with the token
- const next = searchParams.get("next")
+ const next = searchParams.get("next");
- setCookie('_token', data.jwt_token, {path: "/", secure: globalThis.location.protocol !== "http:"})
+ setCookie("_token", data.jwt_token, {
+ path: "/",
+ secure: globalThis.location.protocol !== "http:",
+ });
- globalThis.location.replace(`${next ?? ""}`);
- }
- const {createToken, error: err, isPending, setError} = useCreateToken({onSuccess});
+ globalThis.location.replace(next ?? "");
+ };
+ const {
+ createToken,
+ error: err,
+ isPending,
+ setError,
+ } = useCreateToken({ onSuccess });
const error = err as ExpandedApiError;
- const error_message = error?.body?.detail;
+ const errorMessage = error.body.detail;
Review Comment:
Ack, will do that.
--
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] Added linter for simple auth [airflow]
Posted by "aritra24 (via GitHub)" <gi...@apache.org>.
aritra24 commented on PR #48550:
URL: https://github.com/apache/airflow/pull/48550#issuecomment-2764525017
There's still some linting issues that are failing and need fixing, also I am not sure if the duplication of the rules folder and some of the other files is 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] Added linter for simple auth [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #48550:
URL: https://github.com/apache/airflow/pull/48550#issuecomment-2766089471
Thank you! That was on my list! Ideally we would like to use the configuration from main UI but I do not know how to do that. For now we can duplicate and we can always improve later
--
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