Coder Social home page Coder Social logo

2stacks / freeradius-django Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 1.0 287 KB

A freeradius container for use with django-freeradius

Home Page: http://www.2stacks.net/freeradius-django/

License: MIT License

Dockerfile 2.40% Makefile 16.90% Shell 19.16% Perl 8.11% Python 4.73% Ruby 0.94% PLSQL 9.60% PLpgSQL 24.49% GDB 0.07% TSQL 13.62%
freeradius django-freeradius

freeradius-django's Introduction

freeradius-django

Build Status Docker Stars Docker Pulls Build Details

This repository provides a Freeradius Server customized for use with django-freeradius. It follows the Freeradius configuration guidance in the django-freedius documentation. This projects goal is to make it easier for contributors to django-freeradius to get up and running without having to first master the complexities of Freeradius.

Getting Started

Clone or fork this repository or simply use the included docker-compose.yml on your docker host.

$ git clone --recurse-submodules https://github.com/2stacks/freeradius-django.git
$ cd freeradius-django

Note: The master branch of the django-freeradius project is included as a submodule for integration testing with Docker.

Edit Settings

The freeradius-django and postgres containers can be customized with environment variables set in docker-compose.yml

To run the full stack with docker-compose you must first create a settings file for the django server's database connection.

cp ./django-freeradius/tests/local_settings.example.py ./django-freeradius/tests/local_settings.py

Edit local_settings.py as follows

# ./django-freeradius/tests/local_settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'radius',
        'USER': 'debug',
        'PASSWORD': 'debug',
        'HOST': 'postgres',
        'PORT': '5432',
        'OPTIONS': {'sslmode': 'require'},
    },
}

ALLOWED_HOSTS = ['*']

A set of test certificates for Postgresql were generated with easyRSA. You may use these for testing however, they must be made readable by the Postgresql container before use.

$ sudo chown root:70 ./certs/postgres/*
$ sudo chmod 644 ./certs/postgres/*.crt
$ sudo chmod 640 ./certs/postgres/*.key

Note: If you skip this step the postgresql container will fail to start with the following error message;

[1] FATAL:  private key file "/server.key" must be owned by the database user or root

To generate new certificates for Freeradius, please see the sections below on generating new certs.

Run Containers

This will launch the Freeradius stack which can be configured using environment variables to talk to a Postgresql Database and the django-freeradius REST API.

$ docker-compose build --pull
$ docker-compose up -d
$ docker-compose ps

Create Users

Create a super user account and/or a test user account.

$ docker-compose run --rm django python manage.py createsuperuser
$ docker-compose run --rm -v $PWD/scripts/users.csv:/users.csv django python manage.py batch_add_users --name users --file /users.csv

Test containers

$ docker run -it --rm --network freeradius-django_backend 2stacks/radtest radtest testing password freeradius 0 testing123

Be sure to use the account you created with 'createsuperuser' or the 'batch_add_users' script. If all goes well you should recieve a response similar to;

Sent Access-Request Id 234 from 0.0.0.0:57512 to 10.0.0.4:1812 length 77
        User-Name = "testing"
        User-Password = "password"
        NAS-IP-Address = 10.0.0.5
        NAS-Port = 0
        Message-Authenticator = 0x00
        Cleartext-Password = "password"
Received Access-Accept Id 234 from 10.0.0.4:1812 to 10.0.0.5:57512 length 26
        Session-Timeout = 10800

Customize freeradius-django

Below are steps you can use to customize the configuration of the freeradius-django container.

Copy raddb from the base container to your local host

From your docker host:

$ git clone https://github.com/2stacks/freeradius-django.git
$ cd freeradius-django
$ rm -rf ./backup/raddb
$ docker pull freeradius/freeradius-server:latest-alpine
$ docker run -it --rm -v $PWD/backup:/backup freeradius/freeradius-server:latest-alpine sh

From inside the container:

/ # cp -R /opt/etc/raddb /backup/
/ # exit

From your docker host:

$ sudo chown -R $USER:$USER backup/raddb
$ cp -R ./backup/raddb ./config/freeradius-alpine/

Configure and customize raddb

Once the updated raddb has been copied make custom changes as needed. The below files were modified from the originals in the freeradius/freeradius-server base container to creat this repository. Use 'git diff' to review the changes this repository made to the base container. Use 'git checkout <file_name>' to restore this repositories changes.

  • mods-available/sql
  • mods-available/rest
  • policy.d/canonicalization
  • sites-available/default
  • clients.conf

Generate new certs

From your docker host:

$ docker run -it --rm -v $PWD/raddb:/etc/raddb freeradius/freeradius-server:latest-alpine sh

From inside the container:

/ # cd /etc/raddb/certs/
/ # rm -f *.pem *.der *.csr *.crt *.key *.p12 serial* index.txt* dh passwords.mk
/ # ./bootstrap
/ # exit

From your docker host:

$ sudo chown -R $USER:$USER ./raddb/certs

Note: To create certificates for use in production environments follow directions in /etc/raddb/certs/README.

Build container

$ docker build --no-cache --pull -t 2stacks/freeradius-django .

freeradius-django's People

Contributors

2stacks avatar dependabot-preview[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

anush0247

freeradius-django's Issues

sql nas feature request

hi,

sql nas feature request

i create a nas in the webinterface but it has no effect, you have to enter it in yaml, please enable sql query to use entries in webgui

THX

docker-compose run --rm django python manage.py createsuperuser

docker-compose run --rm django python manage.py createsuperuser
Starting freeradius-django_postgres_1 ... done
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...
Waiting for PostgreSQL to become available...

When using a non-standard DB port, the containers freeradius-django freeradius 1 and freeradius-django_django_1 do not work correctly.

Hi, I am having problems using a non-standard postgres database port, I want to use 5437 instead of 5432 in my project. If I select a port for the 5432 database, the stack works fine, but when I select 5437, it doesn't. At the same time, the containers work, but in the freeradius-django_freeradius_1 logs I get Operation timed out, and in the freeradius-django_django_1 logs - Waiting for PostgreSQL to become available ...

In docker-compose.yml and ./django-freeradius/tests/local_settings.py I changed port 5432 to 5437.

Please help me figure it out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.