Take a look at my .NET Core website boilerplate! Google/Reddit/Github OAuth, MaterializeCSS...

栏目: IT技术 · 发布时间: 4年前

内容简介:A basic .NET Core website boilerplate using PostgreSQL for storage, Adminer for db management, Let's Encrypt for SSL certificates and Nginx for routing.For an explanation of the docker-compose file separation, take a look at.

netcore-postgres-oauth-boiler

A basic .NET Core website boilerplate using PostgreSQL for storage, Adminer for db management, Let's Encrypt for SSL certificates and Nginx for routing.

Demo website.

Features

  • Vanilla .NET Core Server Setup:
    • Razor pages, upholstered with the Materialize css toolkit
    • Server -> client data rendering demo
    • Native Entity Framework database interface, with PostgreSQL
    • Asynchronous design
    • Auth gated route examples
  • User authentication via:
    • Regular email/password
    • Google
    • Github
    • Reddit
  • Auth method merging, linking and unlinking of social auth accounts
  • TLS/HTTPS:
    • Automatic certificate generation powered by Let's Encrypt
    • Hosting modes:
      • Self hosted mode (443/80 port access required)
      • Simple mode (just the Dockerfile, http only), for use with reverse proxy configurations
  • A lightweight PostgreSQL management tool included - Adminer

Configuration

  1. Open the docker-compose file you're going to use (depends on your platform) and set CERTBOT_EMAIL to your email for Let's Encrypt certificate generation. Moreover, set DOMAIN to your domain name. The domain should point to the IP of the machine you're running this project on.
  2. The file appsettingsExample.json needs to be renamed to appsettings.json with your own OAuth keys:
  • The process for obtaining a Google key is described here .
  • The method to create a Github app in order to get an API key is described here .
  • The process for creating a Reddit app in order to get an API key is described here .

Running the boilerplate

  • Standalone:
# clone the repo
$ git clone https://github.com/Scharkee/netcore-postgres-oauth-boiler.git
$ cd netcore-postgres-oauth-boiler
# perform configuration...

# generate TLS certificates and run on ports 80/443
# choose between docker-compose-linux.yml and docker-compose-windows.yml
$ docker-compose -f docker-compose-linux.yml up

For an explanation of the docker-compose file separation, take a look at.

  • Through Visual Studio:
  1. Launch Visual Studio
  2. Right-click on the docker-compose section in the Solution Explorer, and click Set as Startup Project
  3. Select either Debug or Release at the top and click the Docker Compose button to run.

Overview of services

  1. Boilerplate runs on port 3000, and is accessible through the configured domain with managed TLS
  2. PostgreSQL runs on 5432
  3. Adminer (for managing PostgreSQL) runs and can be accessed on port 8080 (localhost:8080 in a browser).
  4. Nginx runs on ports 80 and 443. Make sure no servers/web hosts/etc. are using those ports.

Running the boilerplate independently

If you're behind Nginx or a similar reverse proxy setup, you can either:

  1. Adjust the compose file so it no longer contains the Nginx container
  2. Run only the boilerplate (you will have to run PostgreSQL separately):
    DefaultConnection
    docker build . --tag boiler
    docker run boiler -p 3000:80 --name boiler
    

Running on Windows

Docker on Windows has an open issue with local volume mapping permissions, which results in PostgreSQL not being able to write to a (relative) local directory. Thus, when running on Windows (via run.sh), an external volume is created, which is managed by Docker.

Moreover, if you encounter a PR_END_OF_FILE_ERROR when trying to load the website, try executing:

$ docker exec nginx bash -c "mv /etc/nginx/conf.d/boiler.conf{.nokey,} ; nginx -s reload"

This seems to be a symlink issue with Windows Docker containers as well. After renaming the file once, it does not need to be touched anymore (unless you purge the nginx container).

Information & Sources

Contribution & Support

Submit bugs and requests through the project's issue tracker:

License

This project is licensed under the terms of the MIT license.


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

算法帝国

算法帝国

克里斯托弗•斯坦纳 / 李筱莹 / 人民邮电出版社 / 2014-6 / 49.00

人类正在步入与机器共存的科幻世界?看《纽约时报》畅销书作者讲述算法和机器学习技术如何悄然接管人类社会,带我们走进一个算法统治的世界。 今天,算法涉足的领域已经远远超出了其创造者的预期。特别是进入信息时代以后,算法的应用涵盖金融、医疗、法律、体育、娱乐、外交、文化、国家安全等诸多方面,显现出源于人类而又超乎人类的强大威力。本书是《纽约时报》畅销书作者的又一力作,通过一个又一个引人入胜的故事,向......一起来看看 《算法帝国》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具