Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BK]: Add User Authentication (API) #12

Open
KevinLatino opened this issue Dec 12, 2024 · 23 comments · May be fixed by #18
Open

[BK]: Add User Authentication (API) #12

KevinLatino opened this issue Dec 12, 2024 · 23 comments · May be fixed by #18
Assignees

Comments

@KevinLatino
Copy link
Member

Important

Before applying, please read the Contributors Guide. Following the guide increases your chances of being assigned to this task.

Description

Implement an authentication mechanism for users, allowing login via wallet address and returning a signed JWT.

Tasks

  1. Create an authenticateUser service method in the UserService.
  2. Add the POST /auth/login endpoint to accept wallet address and return a signed JWT token.
  3. Write middleware to validate the token and attach user details to the request.
  4. Document authentication flow in Swagger/OpenAPI.

Example Service Implementation

import jwt from 'jsonwebtoken';
import { User } from '../entities/User';
import { AppDataSource } from '../data-source';

const SECRET_KEY = process.env.JWT_SECRET || 'defaultSecret';

class AuthService {
  static async authenticate(walletAddress: string): Promise<string> {
    const userRepo = AppDataSource.getRepository(User);
    const user = await userRepo.findOne({ where: { walletAddress } });

    if (!user) {
      throw new Error('User not found');
    }

    return jwt.sign({ id: user.id, role: user.role }, SECRET_KEY, { expiresIn: '1h' });
  }
}

Acceptance Criteria

  • POST /auth/login accepts wallet address and returns a JWT token.
  • Middleware validates the token and attaches user details to the request object.
  • All tests pass with >80% code coverage.

@KevinLatino KevinLatino changed the title 2. Add User Authentication (API) Add User Authentication (API) Dec 12, 2024
@Supa-mega
Copy link

I'd be happy to do this.

@akintewe
Copy link

I'm Oluwasola, an experienced TypeScript and Node.js developer passionate about building secure authentication systems. With my expertise in backend development and a deep understanding of JWT and wallet-based authentication, I'm excited to contribute to this project.
I've carefully reviewed the Contributors Guide and am fully prepared to implement a robust, secure authentication mechanism that meets all project requirements. My ETA is 12 hours

@Shukazuby
Copy link

I am Zubaidat, a backend developer with expertise in building secure and scalable APIs. I have experience with authentication mechanisms, JWT implementation, and API documentation using Swagger/OpenAPI.

Plan to Solve the Issue:

I will implement an authentication system enabling users to log in via their wallet address. The solution will include creating the authenticateUser service method in UserService, a POST /auth/login endpoint to handle login requests, and middleware to validate the JWT and attach user details to the request object. I will follow security practices, such as securely signing tokens and validating payloads. The entire authentication flow will be documented in Swagger/OpenAPI for clarity and ease of use.

ETA:
I estimate completing this task within 2 days, including development, testing, and documentation.

Thank you

@RajeshRk18
Copy link

RajeshRk18 commented Dec 12, 2024

I am a backend developer having proficiency in Typescript, Rust and Python. I have experience implementing complex auth mechanisms such as oauth, 2FA, and SSO. So, I have the confidence and ability to implement JWT based authentication.

Here is how I planned to approach it!

  • Implement authenticateUser in AuthService to generate a JWT token for users authenticated via wallet address.
  • Create a new route (/auth/login) to accept wallet address, authenticate the user, and return the JWT token.
  • Write middleware to validate the JWT token and attach the authenticated user details to the request.
  • Use Swagger/OpenAPI to describe the POST /auth/login endpoint, request body, and response schema.

And finally,

  • Write unit tests and integration tests to ensure >80% code coverage.

ETA: 2days

@mariocodecr
Copy link

Hii! My name is Mario Araya, I’m a Software Developer with 2+ years of experience. I have worked with backend technologies such as Cairo, Java, and C#, as well as frontend development using React, NextJS, and JavaScript/TypeScript. I’ve made contributions to open-source projects, completed a Starknet Bootcamp, exercises on NodeGuardians, finished Starklings, and participated in multiple hackathons. I’m also a member of the Dojo Coding community here in Costa Rica.

To implement the authentication mechanism, create a service method authenticateUser in the AuthService class to handle wallet-based login and generate a signed JWT token. Add a POST /auth/login endpoint that accepts the user's wallet address and returns the JWT.

@ShantelPeters
Copy link

ShantelPeters commented Dec 12, 2024

I’d like to work on this.

I am full stack developer with strong experience in Cairo , solidity ,JavaScript,typescript ,react , python etc… looking forward to contributing as this would be my first time contributing to this project…

ETA : 3 days

@zleypner
Copy link

Hi! I’m Anwar a Software Developer with +3 years of experience, and I would love
make a contribution to this project and contribute to the project's success.

I will implement an authentication mechanism for users, allowing login via wallet address and returning a signed JWT token. This involves creating the authenticateUser service method in the UserService and adding the POST /auth/login endpoint to accept a wallet address and return the JWT. I'll also write middleware to validate the token and attach user details to the request. The authentication flow will be documented in Swagger/OpenAPI, and I will ensure the implementation passes tests with over 80% code coverage. I estimate completing this task in 2-4 days.

@Amarjeet325
Copy link

Is it okay if I tackle this?

@ooochoche
Copy link

I am a blockchain developer and I have gone through the description and the required tasks to be completed, and I can make sure all accepted criteria are met

@Benjtalkshow
Copy link

I am a Full Stack Developer with a strong background in blockchain and extensive experience in Next.js/React, TypeScript, and Rust. I’ve made over 49 contributions to over 17 projects in the OnlyDust ecosystem, solving complex issues and delivering efficient, scalable solutions.

I can handle this task.
ETA is 3days.

@sonkeydotcom
Copy link

Hello, can I take this. I plan to implement a service to verify wallet addresses, generate a signed JWT, create the /auth/login endpoint, and write middleware to validate tokens and attach user details. Estimated completion: 2 days.

@Michaelkingsdev
Copy link

I can handle this particular task.

1 similar comment
@Michaelkingsdev
Copy link

I can handle this particular task.

@od-hunter
Copy link

Hi, please can I be assigned this please? This would be my first time contributing to this project and I would love to be the given the opportunity to contribute. I have experience in html, css, JavaScript,TypeScript and solidity, and Cairo.

To solve this issue, I’ll take the following steps:
1.⁠ ⁠I’ll create an authenticate method in UserService to check if a user exists based on their wallet address and generate a signed JWT if valid. Then I’ll use jsonwebtoken to create the token with user data (ID, role) and set an expiration time.
2.⁠ ⁠⁠I’ll implement a POST /auth/login route that accepts a wallet address, calls the authenticate method, and returns a signed JWT to the user.
3.⁠ ⁠⁠Next, I’ll create the middleware (sessionMiddleware) that extracts the token from the Authorization header, verifies it using jsonwebtoken, and attaches the decoded user details (id, role) to the request object.
4.⁠ ⁠Next, I’ll use the middleware on protected routes to ensure authentication by validating the JWT token before granting access.
5.⁠ ⁠⁠Lastly, I’ll write unit tests to ensure the login endpoint generates and returns a valid JWT and the middleware correctly validates the token and attaches user data to the request.

ETA: 3 days
Kindly assign me please, I’m ready to work

@psychemist
Copy link

Hi. I am a fullstack web developer and a recent alumni of Web3Bridge, the largest and most sought after blockchain developer community in Africa. I have extensive backend experience building user authenticatin systems for e-commerce and education websites. I am a new contributor to OnlyDust and would love to take on this task to increase my knowledge base and contribute to open source projects.

I would solve this task by:

  1. Create an authenticateUser service method in the UserService class.
  2. Implement an /auth/login API endpoint that receives a post request containing a wallet address and returns a signed JWT token.
  3. Write functional middleware that validates the generated token and attaches user details to the request.
  4. Add good documentation that explains the authentication flow in Swagger/OpenAPI.

I aim to complete this task within 6 hours after being assigned and setting up my development environment.

Thank you for the opportunity and I look forward to working with you.

@gregemax
Copy link

Mind if I take this issue? I have experience in backend development with TypeScript, JWT-based authentication, and middleware implementation. I can deliver the required authentication mechanism, ensure token validation, and document the flow in Swagger/OpenAPI. I’ll also maintain test coverage above 80%.

@mimisavage
Copy link

Can I start working on this?

@Guzbyte-tech
Copy link
Contributor

Hi @KevinLatino, I am a backend/Blockchain developer with experience building secure and efficient APIs, with a strong focus on authentication and user management systems. My expertise in backend development and recent hands-on experience with modern tools like Node.js, TypeScript, and TypeORM position me well to implement this feature with security and reliability as top priorities.

To implement the authentication mechanism, I will:

  1. Create a secure authenticateUser service method to validate the wallet address and return a signed JWT token.
  2. Add the POST /auth/login endpoint to handle login requests, ensuring proper input validation and error handling.
  3. Write a robust middleware to validate the token and attach user details to the request object for downstream use.
  4. Document the entire authentication flow in Swagger/OpenAPI, including the token validation middleware.
  5. Ensure >80% code coverage with well-structured unit and integration tests, simulating both success and failure scenarios.

Estimated Completion Time (ETA): 3 days

@Nityam573
Copy link

Can I be assigned to this?

1 similar comment
@1nonlypiece
Copy link

Can I be assigned to this?

@3th-Enjay
Copy link

I’d like to resolve this. I have experience doing this

@Villarley
Copy link
Contributor

hey @zleypner
Task assigned to you. Let me know if you need further clarification or additional support!😊

Here is our telegram group, please join https://t.me/starshopcr

@Villarley Villarley changed the title Add User Authentication (API) [BK]: Add User Authentication (API) Dec 13, 2024
@zleypner
Copy link

Hi @Villarley,
Thanks for assigning the task to me! I’ll will send a drat PR asap.

I’ve joined the Telegram group as well!

@zleypner zleypner linked a pull request Dec 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.