Giter VIP home page Giter VIP logo

basic-auth's Introduction

Создание веб-сервера для обработки HTTP-запросов c использованием Basic Authentication.


Требования

Для запуска проекта вам понадобятся следующие компоненты:

  • Go 1.20
  • mkcert

  1. Склонируйте репозиторий на вашу локальную машину:

    git clone https://github.com/Jhnvlglmlbrt/basic-auth
    
  2. Нужно установить mkcert:

    Ссылка

  3. Перейдите в директорию проекта:

    cd basic-auth
    
  4. Создать папку certs и сертификаты:

    mkdir certs && cd certs
    mkcert localhost
    
  5. Установить переменную окружения SSL_CERT_FILE, указывая путь к SSL-сертификату

    export SSL_CERT_FILE=путь/basic-auth/certs/ваше_название_сертификата
    
  6. Запустите сервер с авторизационными данными:

    AUTH_USERNAME=логин AUTH_PASSWORD=пароль go run .
    

Запросы с помощью Curl, чтобы убедиться, что проверки аутентификации работают правильно

 curl -i https://localhost:4000/unprotected

 curl -i https://localhost:4000/protected

 curl -i -u логин:пароль https://localhost:4000/protected

 curl -i -u логин:неправильный_пароль https://localhost:4000/protected

basic-auth's People

Contributors

jhnvlglmlbrt avatar

Watchers

 avatar

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.