Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthenticationService", "AuthenticationService.csproj", "{7FC0F7C8-6F5B-4FDC-B22E-55CD333E0FA0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7FC0F7C8-6F5B-4FDC-B22E-55CD333E0FA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FC0F7C8-6F5B-4FDC-B22E-55CD333E0FA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FC0F7C8-6F5B-4FDC-B22E-55CD333E0FA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FC0F7C8-6F5B-4FDC-B22E-55CD333E0FA0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7D63024A-BC8C-4438-AC15-FBD2D739D9FC}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using AuthenticationService.Models;
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;

namespace Authentication.Controllers;

[ApiController]
[Route("api/[controller]")]
public class AuthenticationController : ControllerBase
{
private static readonly string _userFilePath = "users.json";

// Register the new user with the credentials like Username, Email ID and Password
[HttpPost("register")]
public IActionResult Register([FromBody] User newUser)
{
var Users = LoadUsers();
if (Users.Any(u => u.Username == newUser.Username))
{
return BadRequest(new { message = "Username already exists" });
}
if (Users.Any(u => u.Email == newUser.Email))
{
return BadRequest(new { message = "Email already registered" });
}
newUser.Password = BCrypt.Net.BCrypt.HashPassword(newUser.Password);
Users.Add(newUser);
var json = JsonSerializer.Serialize(Users, new JsonSerializerOptions { WriteIndented = true });
System.IO.File.WriteAllText(_userFilePath, json);
return Ok(new { message = "User registered successfully" });
}

// Existing user can login using the credentials such as Email ID and password
[HttpPost("login")]
public IActionResult Login([FromBody] User login)
{
var Users = LoadUsers();
var user = Users.FirstOrDefault(u => u.Email == login.Email);
if (user == null || !BCrypt.Net.BCrypt.Verify(login.Password, user.Password))
{
return Unauthorized(new { message = "Invalid credentials" });
}

return Ok(new { username = user.Username, email = user.Email });
}

// 🔸 Load the user details from the local storage file
private static List<User> LoadUsers()
{
if (!System.IO.File.Exists(_userFilePath))
return new List<User>();

var json = System.IO.File.ReadAllText(_userFilePath);
return JsonSerializer.Deserialize<List<User>>(json) ?? new List<User>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace AuthenticationService.Models
{

/// <summary>
/// Represents a user with basic authentication details.
/// </summary>

public class User
{
/// <summary>
/// Gets or sets the username of the user.
/// </summary>
public string? Username { get; set; }

/// <summary>
/// Gets or sets the email address of the user.
/// </summary>
public string Email { get; set; }

/// <summary>
/// Gets or sets the password of the user.
/// </summary>
public string Password { get; set; }
}
}
36 changes: 36 additions & 0 deletions Annotations/Role based annotation/AuthenticationService/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// ✅ Add CORS configuration BEFORE building the app
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

// ✅ Use CORS middleware BEFORE authorization
app.UseCors();

app.UseHttpsRedirection();
app.UseAuthorization();

app.MapControllers();

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:19872",
"sslPort": 44310
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5063",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7132;http://localhost:5063",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
17 changes: 17 additions & 0 deletions Annotations/Role based annotation/AuthenticationService/users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"Username": "John",
"Email": "john@gmail.com",
"Password": "$2a$11$1zW3U/d6DC56zxifl8nATuGMQ8zhM8gmyx1t3fFtXAQg8a.xD5cBG"
},
{
"Username": "Andrew",
"Email": "andrew@gmail.com",
"Password": "$2a$11$lu2VT2RXFNqI5Up8DYSkUuo1nampE5REmWJXQEcsvD69.icuTXUta"
},
{
"Username": "Janet",
"Email": "janet@gmail.com",
"Password": "$2a$11$42zEoWxWxtReaL3Sgs9haer9Uxb3OnrWa1FM0T9icweSJphEimy/q"
}
]
23 changes: 23 additions & 0 deletions Annotations/Role based annotation/RoleBasedAnnotation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
70 changes: 70 additions & 0 deletions Annotations/Role based annotation/RoleBasedAnnotation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
45 changes: 45 additions & 0 deletions Annotations/Role based annotation/RoleBasedAnnotation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "syncfusion-pdf-viewer",
"version": "0.1.0",
"private": true,
"dependencies": {
"@syncfusion/ej2-base": "^31.2.2",
"@syncfusion/ej2-react-dropdowns": "^31.2.3",
"@syncfusion/ej2-react-pdfviewer": "^31.2.3",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.3.8",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-scripts": "^5.0.1"
}
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading