Giter Site home page Giter Site logo

domainconnection's Introduction

Warning

This repo is no longer maintained this also means that this is an earlier version of the currently published version of is-my.life domain connection. There will be no more package or vulnerability fixes, if you want to use it I recommend checking for vulnerabilities first and fixing them.

Discord Domain Connection

Integrates with your Cloudflare account so you can share your funny domain with your friends. This is related to the new Discord feature called Domain Connections.

How does it work?

  1. It uses Discord OAuth to limit who can log in and use this web-app.
  2. The web-app communicated through socket.io and can receive real-time data.
  • The only reason this web-app uses socket.io instead of rest API is that I stole a part of the code from one of my other project.
  1. It uses the Cloudflare API to update/create TXT records on your domain.
  2. That's all, it's a really simple explanation but if you can code you'll understand the code anyways.

Setting up

Empty .env

EXPRESS_SECRET="your secret"
CLIENT_ID="" # Discord Client ID
CLIENT_SECRET="" # Discord Client Secret
CLOUDFLARE_API_KEY="" # Cloudflare API Key

Discord Client ID, Secret and Redirect URI

  1. Go to the Developer Portal create a new Application and go to OAuth2, copy and paste the Client ID and Secret to your .env file.
  2. Add your redirect URI, if you're running this locally add http://localhost:8000/auth, if not then you know where you're gonna deploy this web-app. (Make sure the redirect URI ends with /auth).

Cloudflare API Token/Key

  1. Go to your profile > API tokens and click create a token.
  2. Use the edit zone DNS template, you can add filtering so only your IP address is allowed but that's not necessarry.
  3. Copy and paste the generated token to your .env file.

Express secret

Just set any secret you want, the easiest one which I recommend is generating a random string or password and setting that. This secret is just for the sessions and it's not required to access the site, but don't share the secret you set with anyone.

Configuration

Empty config.json

{
    "allowed_users": ["your discord id", "another discord id"],
    "socket_port": 4000,
    "http_port": 8000,
    "cors": ["http://localhost:8000", "http://localhost:4000"],
    "discord_auth_url": "",
    "discord_redirect_uri": "http://localhost:8000/auth",
    "domain": "your domain"
}

Allowed users

You can add allowed users who can access the web-app. Copy the ID of the user and add it to the allowed users array.

Ports

The http_port is the web-app's port which is how you access the website and socket_port is the socket.io port for communication. Make sure to update the CORS URLs as well!

Warning Currently the web-app connects to the same hostname and protocol for socket.io if you're exposing the socket.io connection on a different hostname or protocol you need to modify the code at public/script.js:11.

Discord Auth URL and Redirect URI

  1. Go back to the Developer Portal and select the application you created earlier.
  2. Go to OAuth2 > URL Generator.
  3. Select the identify scope and the redirect URI you added earlier.
  4. Copy the generated URL and set it as discord_auth_url.
  5. Set the discord_redirect_uri as the same redirect URI you added earlier in the Developer Portal.

Domain

Set the domain to a domain that you already own and already added to your Cloudflare account.

domainconnection's People

Contributors

zyrenth avatar dependabot[bot] avatar

Stargazers

Grafaffel avatar dia ♡ 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.