Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Authentification] ajout de Cerbère #1388

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

thoomasbro
Copy link
Collaborator

@thoomasbro thoomasbro force-pushed the thomas/ajout-cerbere branch 2 times, most recently from 18c437c to 11a611a Compare June 6, 2024 13:13
// add the names of the request headers into the list
val n = e.nextElement()
set.add(n)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est possible de remplacer les variables e et n par des noms un peu plus explicites?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui. C'est une copie du code de fish.

@@ -2,10 +2,11 @@
<html lang="fr">
<head>
<meta charset="utf-8" />
<link rel="preload" as="image" href="landing_background.png">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

penser à la remplacer? Ajouter un TODO ?

return (
<Wrapper data-cy="first-loader">
<FulfillingBouncingCircleSpinner className="update-vessels" color={THEME.color.lightGray} size={48} />
{isVesselShowed && <Icon.Vessel />}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

petit détail à voir avec Adeline aussi pour l'icône


################################################################################
# MonitorFish
MONITORFISH_API_KEY=""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on en a plus besoin de celui-ci normalement

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

les api publiques de MonitorFish ont toujours besoin d'une clé, que MonitorEnv soit cerberisé ou non.

"/error",
"/api/**",
"/version",
// TODO: secure SSE endpoints
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: tu comptais le faire dans cette PR ou un autre ticket est existant ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

il faut le faire dans une autre PR car c'est pas si évident. EventSource ne permet pas de passer les headers, mais pourrait passer correctement les cookies. Donc soit on change le back pour faire une sécu via cookies plutot que headers, soit on doit changer l'implem de EventSource coté client.

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component

@Component
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Component
@Configuration


return try {
userAuthorizationRepository.findByHashedEmail(hashedEmail)
} catch (e: Throwable) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: as-tu une raison particulière de catch les Error ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectivement, autoriser un type null en sortie de findByHashedEmail serait plus propre pour distinguer les erreurs de db du cas où juste l'utilisateur n'est pas en base.

return try {
userAuthorizationRepository.findByHashedEmail(hashedEmail)
} catch (e: Throwable) {
logger.info("User $hashedEmail not found, defaulting to super-user=false")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: On laisse les utilisateurs anonymes en lecture seule, si je comprends bien

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui

backend/src/test/resources/application.properties Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Y-a-t'il moyen d'avoir une image plus légère ?

const auth = useAuth()
const { data: user } = useGetCurrentUserAuthorizationQueryOverride(undefined, { skip: !auth?.isAuthenticated })

if (!oidcConfig.IS_OIDC_ENABLED) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: un peu de refacto des conditions, sinon je m'y perds un peu. Qu'en penses-tu ?

Suggested change
if (!oidcConfig.IS_OIDC_ENABLED) {
if (!oidcConfig.IS_OIDC_ENABLED) {
return children;
}
if (!auth.isAuthenticated) {
return handleRedirect("/login", redirect);
}
if (requireSuperUser && !user?.isSuperUser) {
return handleRedirect("/register", redirect);
}
return children;
}
const handleRedirect = (path, redirect) => {
if (redirect) {
return <Navigate replace to={path} />;
}
return null;
}

frontend/src/pages/Login.tsx Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants