美文网首页
使用openwisp-radius提供web页面

使用openwisp-radius提供web页面

作者: 明明就_c565 | 来源:发表于2023-07-10 15:27 被阅读0次

安装radius服务器

https://www.jianshu.com/p/8cebfacde665

安装openwisp-radius 提供web

1,安装python虚拟环境

可参考:https://www.jianshu.com/p/2c20bd5d1fb0

2,创建虚拟环境

mkvirtualenv radius

3,安装openwisp-radius

pip install -U pip setuptools wheel

pip install openwisp-radius

4,创建django项目

django-admin startproject radius_app

5,编辑settings.py

vim radius_app/settings.py

import os

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.

BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production

# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = 'ui(^sg6cesrc82p$-urdd*m3qn6khtkb+t6zx)%0&e@l77ub_k'

# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True

ALLOWED_HOSTS = ['178.103.224.9']

PORT = 8080

INSTALLED_APPS = [

    'django.contrib.auth',

    'django.contrib.contenttypes',

    'django.contrib.sessions',

    'django.contrib.messages',

    'django.contrib.staticfiles',

    'django.contrib.humanize',

    # openwisp admin theme

    'openwisp_utils.admin_theme',

    # all-auth

    'django.contrib.sites',

    'allauth',

    'allauth.account',

    # admin

    'django.contrib.admin',

    # rest framework

    'rest_framework',

    'django_filters',

    # registration

    'rest_framework.authtoken',

    'dj_rest_auth',

    'dj_rest_auth.registration',

    # openwisp radius

    'openwisp_radius',

    'openwisp_users',

    'private_storage',

    'drf_yasg',

]

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

PRIVATE_STORAGE_ROOT = os.path.join(MEDIA_ROOT, 'private')

AUTH_USER_MODEL = 'openwisp_users.User'

SITE_ID = 1

'''

# 不注释掉会报错 ModuleNotFoundError: No module named 'openwisp_users.backends'  这个包可能有问题 待查

AUTHENTICATION_BACKENDS = (

    'openwisp_users.backends.UsersAuthenticationBackend',

)

'''

OPENWISP_RADIUS_FREERADIUS_ALLOWED_HOSTS = ['0.0.0.0']

#    'django.middleware.locale.LocaleMiddleware',  中文中间件

MIDDLEWARE = [

    'django.middleware.security.SecurityMiddleware',

    'django.contrib.sessions.middleware.SessionMiddleware',

    'django.middleware.common.CommonMiddleware',

    'django.middleware.csrf.CsrfViewMiddleware',

    'django.contrib.auth.middleware.AuthenticationMiddleware',

    'django.contrib.messages.middleware.MessageMiddleware',

    'django.middleware.clickjacking.XFrameOptionsMiddleware',

    'django.middleware.locale.LocaleMiddleware',

]

ROOT_URLCONF = 'radius_app.urls'

TEMPLATES = [

    {

        'BACKEND': 'django.template.backends.django.DjangoTemplates',

        'DIRS': [],

        'APP_DIRS': True,

        'OPTIONS': {

            'context_processors': [

                'django.template.context_processors.debug',

                'django.template.context_processors.request',

                'django.contrib.auth.context_processors.auth',

                'django.contrib.messages.context_processors.messages',

            ],

        },

    },

]

WSGI_APPLICATION = 'radius_app.wsgi.application'

# Database

# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {

    'default': {

        'ENGINE': 'django.db.backends.sqlite3',

        'NAME': BASE_DIR / 'db.sqlite3',

    }

}

# Password validation

# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [

    {

        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',

    },

    {

        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',

    },

    {

        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',

    },

    {

        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',

    },

]

# Internationalization

# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

# 汉语

# LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_URL = '/static/'

文档:https://openwisp-radius.readthedocs.io/en/latest/developer/setup.html

6,创建用户

./manage.py createsuperuser

(radius) [root@desktop-tzgy radius_app]# ./manage.py createsuperuser

Username: admin

Email address: admin@123.com

Password:

Password (again):

The password is too similar to the username.

Bypass password validation and create user anyway? [y/N]: y

Superuser created successfully.

(radius) [root@desktop-tzgy radius_app]#

7,运行

./manage.py runserver 0.0.0.0:8080

8,登录

9,登录成功

相关文章

网友评论

      本文标题:使用openwisp-radius提供web页面

      本文链接:https://www.haomeiwen.com/subject/nwcyedtx.html