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

Enable subdomain restrictions on app #128

Merged
merged 11 commits into from
Apr 3, 2024
Merged

Enable subdomain restrictions on app #128

merged 11 commits into from
Apr 3, 2024

Conversation

skelz0r
Copy link
Member

@skelz0r skelz0r commented Mar 18, 2024

Cf README.

Principalement pour préparer la migration en N étapes, avec API Entreprise en premier.

@skelz0r skelz0r self-assigned this Mar 18, 2024
@skelz0r skelz0r force-pushed the features/subdomain branch 7 times, most recently from c6eefc7 to d481ec2 Compare March 20, 2024 15:39
@skelz0r
Copy link
Member Author

skelz0r commented Mar 21, 2024

@skelz0r skelz0r force-pushed the features/subdomain branch 2 times, most recently from ddfcb9e to f291e1b Compare March 25, 2024 11:18
@@ -4,6 +4,10 @@
get 'auth/:provider/callback', to: 'sessions#create'
get 'auth/failure', to: redirect('/')

if Rails.env.development?
get 'local-sign-in', to: 'authenticated_user#bypass_login'
Copy link
Contributor

Choose a reason for hiding this comment

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

Pourra t'on toujours détecter les bugs liés à MCP en local ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oui, c'est juste histoire de pouvoir bypass par exemple dgfip.localtest.me sans avoir à aller quémander à MCP d'ajouter milles domaines.


def registered_subdomain
Subdomain.find(app_subdomain)
rescue ActiveRecord::RecordNotFound
Copy link
Contributor

Choose a reason for hiding this comment

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

Si le sous-domaine n'existe pas, ne serait il pas mieux de rediriger l'url sans sous-domaine ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Dans ce contexte on veut extraire, en fonction de l'host, les demandes d'autorisations valident. La gestion d'une potentiellement redirection est géré au niveau du controller (en fonction par exemple des autorisations lié à la policy).

Copy link
Contributor

Choose a reason for hiding this comment

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

Mais il ne me semble pas avoir vu de gestion de redirection si le sous domaine n'est pas valide chez nous dans le controller.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tu as tout à fait raison, mais je ne pense pas que ça soit la responsabilité de l'applicatif de déterminer les possibles noms de domaines associé à cette application mais au serveur/host (dans notre cas, nginx).
De manière général la configuration du nom de domaine n'est jamais embed dans l'application.

Un autre argument: si le serveur nginx ne configure pas le nom de domaine dgfip.datapass.api.gouv.fr pour pointer sur cette application, on ne pourra jamais y accéder.

Copy link
Contributor

Choose a reason for hiding this comment

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

Donc nous sommes d'accord, mais nous ne ferons aucun white listing de sous domaine de notre côté ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Faudrait lister dans l'application tous les domaines possibles, donc par exemple staging1.v2.datapass.api.gouv.fr, ou encore staging3.v2.datapass.api.gouv.fr pour les whitelister.

On se retrouverait donc à maintenir 2 listes de domaines: une côté serveur et une côté applicatif. De plus cela implique de donner la connaissance archi à l'applicatif, ce qui n'est pas sa responsabilité.

Et l'argument le plus important pour moi : ça n'apporte rien fonctionnellement. La seule chose que ça va faire c'est rediriger sur le domaine "principal" (qui d'ailleurs devrait aussi être renseignée, mais quelle est le domaine principal ?) sans aucun différence fonctionnelle.

features/sous-domaine_tableau_de_bord.feature Outdated Show resolved Hide resolved
app/models/subdomain.rb Show resolved Hide resolved
@skelz0r skelz0r force-pushed the features/subdomain branch 7 times, most recently from 7e58f41 to ff8e342 Compare April 1, 2024 14:14
@skelz0r skelz0r changed the base branch from develop to ops/bugfixes April 1, 2024 14:15
@skelz0r
Copy link
Member Author

skelz0r commented Apr 1, 2024

PI j'ai rebase par rapport à la branche de multiple bugfix, je vais déployer celle-ci en staging pour avoir un vrai E2E "final"

Base automatically changed from ops/bugfixes to develop April 3, 2024 10:11
skelz0r added 6 commits April 3, 2024 11:11
Prepare to retrieve data based on subdomain in order to restrict access

Ref https://github.com/varvet/pundit?tab=readme-ov-file#additional-context
Allow dev to bypass MonComptePro restrictions on domains
Prepare to use subdomains in development
Thanks to subdomain we can only show a subset of authorization request
thanks to their definition `subdomains` attribute.
skelz0r added 4 commits April 3, 2024 11:11
Because of the change of the app host for subdomain testing, we need to
keep the original Capybara host for javascript testing within Docker,
which customize the UDP server (within spec/support/configure_javascript_driver.rb)

We have to use a global variable (because instance variable are not
persisted across tests)
@skelz0r skelz0r force-pushed the features/subdomain branch from ff8e342 to da5fd4b Compare April 3, 2024 10:11
@skelz0r skelz0r force-pushed the features/subdomain branch from da5fd4b to de44329 Compare April 3, 2024 15:56
@skelz0r skelz0r merged commit 4340115 into develop Apr 3, 2024
7 checks passed
@skelz0r skelz0r deleted the features/subdomain branch April 3, 2024 16:01
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.

3 participants