Skip to content

Commit

Permalink
Disable local accounts when Guisso is enabled (#909)
Browse files Browse the repository at this point in the history
* Fix Debian Stretch repositories

They were moved to Debian's archive.

* Use Docker Compose v2

Instead of the old `docker-compose` v1 script

* Force x86_64 Docker images in development

We don't support ARM yet

* Disable Disable local accounts when Guisso is enabled

If we delegate authentication to Guisso, then stop using Devise's local
accounts.

We want to have this in production, since Guisso has CAPTCHA implemented
to avoid automated account creation - and we want to avoid implementing
CAPTCHA on each of our apps.
  • Loading branch information
matiasgarciaisaia authored May 24, 2023
1 parent cd74912 commit 3de250b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 21 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:
- name: Set environment up
run: |
mv docker-compose.ci.yml docker-compose.override.yml
docker-compose pull
docker-compose up -d db elasticsearch redis
docker-compose run --rm --no-deps web bundle
docker-compose run --rm --no-deps web rake db:setup
docker-compose run --rm --no-deps web rake db:test:prepare
docker compose pull
docker compose up -d db elasticsearch redis
docker compose run --rm --no-deps web bundle
docker compose run --rm --no-deps web rake db:setup
docker compose run --rm --no-deps web rake db:test:prepare
- name: Run specs
run: |
docker-compose run --rm web bundle exec rspec spec/ plugins/
docker-compose run --rm web bundle exec rspec -t js spec/integration/
docker-compose run --rm web bundle exec rake jasmine:ci
docker compose run --rm web bundle exec rspec spec/ plugins/
docker compose run --rm web bundle exec rspec -t js spec/integration/
docker compose run --rm web bundle exec rake jasmine:ci
build:
needs: test
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM ruby:2.3
# Cleanup expired Let's Encrypt CA (Sept 30, 2021)
RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f

RUN echo 'deb http://archive.debian.org/debian stretch main\n\
deb http://archive.debian.org/debian-security stretch/updates main' > /etc/apt/sources.list

# Install dependencies
RUN \
apt-get update && \
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM ruby:2.3
# Cleanup expired Let's Encrypt CA (Sept 30, 2021)
RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f

RUN echo 'deb http://archive.debian.org/debian stretch main\n\
deb http://archive.debian.org/debian-security stretch/updates main' > /etc/apt/sources.list

RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y libzmq3-dev nodejs && \
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ And open a browser tab in [http://localhost:8888](http://localhost:8888)
Run the following commands to have a stable development environment.
```
$ docker-compose run --rm --no-deps web bundle install
$ docker-compose up -d db
$ docker-compose run --rm web rake db:setup
$ docker-compose up
$ docker compose run --rm --no-deps web bundle install
$ docker compose up -d db
$ docker compose run --rm web rake db:setup
$ docker compose up
```
To setup and run test, once the web container is running:
```
$ docker-compose exec web bash
$ docker compose exec web bash
root@web_1 $ rake
```
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# We define here a route inside the locale thats just saves the current locale in the session
get 'omniauth/:provider' => 'omniauth#localized', as: :localized_omniauth

devise_for :users, skip: :omniauth_callbacks, controllers: {registrations: "registrations", sessions: 'sessions'}
devise_for :users, skip: [ :omniauth_callbacks, ( :registrations if Guisso.enabled? ) ], controllers: {registrations: "registrations", sessions: 'sessions'}
guisso_for :user

devise_scope :user do
Expand Down
12 changes: 6 additions & 6 deletions dev-setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
#!/bin/sh -e

docker-compose pull
docker-compose up -d db elasticsearch redis
docker-compose run --rm --no-deps web bundle
docker-compose run --rm --no-deps web rake db:setup
docker-compose run --rm --no-deps web rake db:test:prepare
docker compose pull
docker compose up -d db elasticsearch redis
docker compose run --rm --no-deps web bundle
docker compose run --rm --no-deps web rake db:setup
docker compose run --rm --no-deps web rake db:test:prepare
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ version: '2.0'
services:
db:
image: mysql:5.7
platform: linux/amd64
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- db:/var/lib/mysql

elasticsearch:
image: elasticsearch:1.7
platform: linux/amd64
command: elasticsearch -Des.network.host=0.0.0.0
volumes:
- elastic:/usr/share/elasticsearch/data

redis:
image: redis:4.0-alpine
platform: linux/amd64
volumes:
- redis:/data

Expand All @@ -29,6 +32,7 @@ services:
build:
context: .
dockerfile: Dockerfile-dev
platform: linux/amd64
environment:
RAILS_ENV:
ELASTICSEARCH_URL: 'elasticsearch:9200'
Expand Down
2 changes: 1 addition & 1 deletion on-web
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
docker-compose run --rm web "$@"
docker compose run --rm web "$@"

0 comments on commit 3de250b

Please sign in to comment.