Skip to content

Commit

Permalink
fix: bugfix (keephq#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl authored Nov 20, 2023
1 parent 4b5c478 commit dd7405b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion keep-ui/app/alerts/alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default function Alerts({

useEffect(() => {
if (tenantId) {
console.log("Connecting to pusher")
const pusher = new Pusher(process.env.NEXT_PUBLIC_PUSHER_APP_KEY!, {
wsHost: process.env.NEXT_PUBLIC_PUSHER_HOST,
wsPort: process.env.NEXT_PUBLIC_PUSHER_PORT
Expand Down Expand Up @@ -109,7 +110,7 @@ export default function Alerts({
channel.bind("async-done", function (data: any) {
setIsAsyncLoading(false);
});

console.log("Connected to pusher")
return () => {
pusher.unsubscribe(channelName);
};
Expand Down
5 changes: 4 additions & 1 deletion keep-ui/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import NextAuth, { AuthOptions } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import Auth0Provider from "next-auth/providers/auth0";
import { getApiURL } from "utils/apiUrl";
import { AuthenticationType, NoAuthUserEmail } from "utils/authenticationType";
import { AuthenticationType, NoAuthUserEmail, NoAuthTenant } from "utils/authenticationType";

const authType = process.env.AUTH_TYPE as AuthenticationType;
/*
Expand Down Expand Up @@ -145,6 +145,7 @@ const noAuthOptions = {
id: 'keep-user-for-no-auth-purposes',
name: 'Keep',
email: NoAuthUserEmail,
tenantId: NoAuthTenant,
accessToken: 'keep-token-for-no-auth-purposes', // Static token for no-auth purposes - DO NOT USE IN PRODUCTION
};
},
Expand All @@ -155,11 +156,13 @@ const noAuthOptions = {
// If the user object exists, set the static token
if (user) {
token.accessToken = user.accessToken;
token.tenantId = user.tenantId;
}
return token;
},
async session({ session, token }) {
session.accessToken = token.accessToken as string;
session.tenantId = token.tenantId as string;
return session;
},
},
Expand Down
1 change: 1 addition & 0 deletions keep-ui/utils/authenticationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export enum AuthenticationType {
}

export const NoAuthUserEmail = "[email protected]";
export const NoAuthTenant = "keep";
6 changes: 2 additions & 4 deletions keep/api/core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ def verify_bearer_token(token: str = Depends(oauth2_scheme)) -> str:
def get_user_email_single_tenant(request: Request) -> str:
# if we don't want to use authentication, return the single tenant id
if (
os.environ.get(
"AUTH_TYPE",
)
== "false"
os.environ.get("AUTH_TYPE", AuthenticationType.NO_AUTH.value)
== AuthenticationType.NO_AUTH.value
):
return SINGLE_TENANT_UUID

Expand Down

0 comments on commit dd7405b

Please sign in to comment.