Skip to content

Create login,signup api and added authentication using spring security.#1

Open
Sourabh-codesjava wants to merge 1 commit into
mainfrom
feature/authenticatewithjwt
Open

Create login,signup api and added authentication using spring security.#1
Sourabh-codesjava wants to merge 1 commit into
mainfrom
feature/authenticatewithjwt

Conversation

@Sourabh-codesjava
Copy link
Copy Markdown
Owner

Implemented authentication module using Spring Security and JWT.

Features added:

  • User Signup API
  • User Login API
  • JWT token generation
  • Spring Security authentication setup
  • Password encryption using PasswordEncoder
  • User persistence using Spring Data JPA and H2 database

Copy link
Copy Markdown
Collaborator

@Kapil9399 Kapil9399 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

work on the minor mistakes

.requestMatchers("/auth/**").permitAll()
.anyRequest().authenticated()
)
// .addFilterBefore(authFilter, UsernamePasswordAuthenticationFilter.class)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment from here

import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/home")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start api end point with "/api"

private String name;
@NotNull
private String password;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add all args constructor

private String name;
private String message;
private String token;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add all args constructor

@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;

String name;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make name variable as private


String name;

String password;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make password variable as private

String name;

String password;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add all args constructor

@@ -0,0 +1,32 @@
package com.example.SecurityDemo.security;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this file in service package


@Component
public class JwtUtil {
public static final String key="sourabhyadav747sourabhyadav747sourabhyadav747sourabhyadav747";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it dynamic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants