GithubHelp home page GithubHelp logo

tdameros / 42-transcendence Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 0.0 24.61 MB

Competitive multiplayer pong game (42 transcendence)

Makefile 0.24% Dockerfile 0.28% Python 57.86% CSS 0.09% HTML 0.04% JavaScript 41.18% Shell 0.30%
42 42born2code 42school transcendence ft-transcendence django pong-game postgresql

42-transcendence's Introduction

Transcendence

Transcendence is a project at 42 School aimed at familiarizing us with web development by creating a competitive multiplayer version of Pong.

ft_transcendence.low.quality.mp4

Usage

Install the common dependencies.

pip3 install -r common/docker/requirements.txt

Generate the .env file using .env.example as a template.

cp .env.example .env

Generate .env files for each service

make generate_env

Start microservices

make

Open the website at https://localhost/

open https://localhost/

Features

  • Remote player functionality
  • Remote authentication capability
  • Microservices architecture implementation
  • 3D pong game integration
  • GDPR compliance
  • User and game statistics tracking
  • Support for multiple devices
  • Tournament feature accommodating up to 32 players
  • Ranking system implementation
  • Elo-based matchmaking system

Technologies

Microservices Architecture

Databases Architecture

Default Ports

  • Front: 443
  • Tournament: 6001
  • User management: 6002
  • User stats: 6003
  • Matchmaking: 6004
  • Notification: 6005
  • Game creator: 6006
  • Game server: 50200:50400

Documentation

42-transcendence's People

Contributors

a-levra avatar ethandelage avatar hferraud avatar tdameros avatar v-fries avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

42-transcendence's Issues

third party remote auth

OAuth 2.0, les grands principes pour briller en société :

OAuth définition simple :

C'est un protocole permettant à un client (une application tierce comme Pong) d'obtenir des autorisations d'accès à des ressources (comme des données utilisateur) sur un serveur, au nom d'un utilisateur, sans que cet utilisateur partage ses identifiants (nom d'utilisateur, mot de passe) avec l'application tierce.

Le client(pong) demande au end-user(les joueurs de pongs) de s'authentifier sur un Authorization Server(Github, intra42 ou autre) pour pouvoir accéder à des resources

Étapes d'Authentification OAuth 2.0 pour "Pong" avec "Intra 42"

  1. Enregistrement de l'Application "Pong" sur "Intra 42" (Client ID et Client Secret):

    • "Pong" s'enregistre en tant qu'application OAuth sur le site "Intra 42" pour obtenir un Client ID et un Client Secret.
  2. Définition des Scopes (Portées):

    • "Pong" spécifie les scopes (portées) d'accès nécessaires lorsqu'il fait la demande d'autorisation.
  3. Affichage du Bouton de Connexion "Intra 42" sur l'Interface Utilisateur de "Pong":

    • Sur l'interface utilisateur de "Pong", un bouton "Se connecter avec Intra 42" est affiché.
  4. Redirection vers le Serveur d'Autorisation "Intra 42":

    • L'utilisateur est redirigé vers la page d'authentification "Intra 42" où il doit se connecter avec ses identifiants Intra 42.
  5. Demande d'Autorisation:

    • Une fois connecté, "Intra 42" demande à l'utilisateur d'autoriser l'application "Pong" à accéder aux informations spécifiées.
  6. Redirection avec le Code d'Autorisation:

    • Si l'utilisateur donne son consentement, "Intra 42" redirige l'utilisateur vers l'URI de redirection spécifiée par "Pong", avec un code d'autorisation.
  7. Échange du Code d'Autorisation contre un Jeton d'Accès:

    • "Pong" utilise le code d'autorisation reçu pour faire une demande au serveur d'autorisation "Intra 42" en échange d'un jeton d'accès.
  8. Réception du Jeton d'Accès et éventuellement du Jeton de Rafraîchissement:

    • Si la demande est valide, le serveur d'autorisation renvoie un jeton d'accès à "Pong". Un jeton de rafraîchissement pourrait également être retourné.
  9. Stockage du Jeton d'Accès et Gestion de la Session:

    • "Pong" stocke le jeton d'accès de manière sécurisée. La gestion de session est assurée pour maintenir l'état d'authentification.
  10. Accès aux Ressources Protégées:

    • Avec le jeton d'accès, "Pong" peut maintenant faire des requêtes à l'API "Intra 42" pour obtenir les informations du profil de l'utilisateur en fonction des scopes accordés.
  11. Rafraîchissement du Jeton d'Accès (si nécessaire):

    • Si le jeton d'accès expire, "Pong" peut utiliser le jeton de rafraîchissement pour obtenir un nouveau jeton d'accès sans demander à l'utilisateur de se reconnecter.

Github

tout est dit ici :
https://docs.github.com/fr/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps
Pour s'identifier en utilisant OAuth2.0,
il faut rediriger les users sur : GET https://github.com/login/oauth/authorize
en précisant le client_id de Pong,
sur quelle redirect_uri renvoyer l'utilisateur,
quelle est lescope de donnée auquel Pong veut accéder (photo de profil par exemple),
et state la Chaîne aléatoire non modifiable. Elle est utilisée pour protéger contre les attaques de falsification de requête intersite.

Une fois que l'utilisateur autorise Pong à acceder à ses infos Github, Github renvoi l'utilisateur sur le redirect_uri,
et donne un code à fournir sur : POST https://github.com/login/oauth/access_token pour avoir un access token
Accept: application/json { "access_token":"gho_16C7e42F292c6912E7710c838347Ae178B4a", "scope":"repo,gist", "token_type":"bearer" }
Ensuite, Pong utilise cet access token pour accéder aux infos du user :

Authorization: Bearer OAUTH-TOKEN GET https://api.github.com/user

Intra 42

https://api.intra.42.fr/apidoc

My API UID and my API SECRETfor 42 OAuth :
https://profile.intra.42.fr/oauth/applications/18653

Once the APP UI and APP SECRET are store securely on the app server,
the app needs to get a token to OAuth42 service :
➜ ~ curl -X POST --data "grant_type=client_credentials&client_id=MY_AWESOME_UID&client_secret=MY_AWESOME_SECRET" https://api.intra.42.fr/oauth/token

Response :

{
"access_token":"...",
"token_type":"bearer",
"expires_in":7200,
"scope":"public",
"created_at":1703442552,
"secret_valid_until":1705860153
} 

https://api.intra.42.fr/apidoc/2.0/users/show.html
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" "https://api.intra.42.fr/v2/users/USER_ID"
The USER_ID can be the login (alevra) or number linked to this specific user (in my case 115866)

The JSON response of 42 :

[...]
  "image": {
    "link": "https://cdn.intra.42.fr/users/1234567890/andre.jpg",
    "versions": {
      "large": "https://cdn.intra.42.fr/users/1234567890/large_andre.jpg",
      "medium": "https://cdn.intra.42.fr/users/1234567890/medium_andre.jpg",
      "small": "https://cdn.intra.42.fr/users/1234567890/small_andre.jpg",
      "micro": "https://cdn.intra.42.fr/users/1234567890/micro_andre.jpgg"
    }
  },
[...]

Refactor docker network

Refactor the Docker networks to enable making requests to all microservices without being on the same network

Movement x and z

The server doesn't check the x and z position of the players during movement event

Error in user-management documentation

In the endpoint documentation POST /user/refresh-access-jwt, there is an error.
In the body, "refresh-jwt" must be renamed to "refresh-token".

{
    "refresh_token": "234235sfs3r2.."
}

Match management

Implement the following endpoints:

  • GET /tournament/{id}/matches/{match-id} (return match details)
  • PATCH /tournament/{id}/matches/{match-id} (to start a match, update the score or end a match)
  • GET /tournament/{id}/matches (returns all matches in a tournament)

Speed hack

It is possible to speed hack if movement events are spammed

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.