Authentication Without a Dedicated Separate Database in .NET?

everyone!

Hi, guys! So, I have a small problem that I would like some help with. I am working on a future application for a small company as a freelance back-end web developer, and I am using .NET for it, and loving it so far! So, what I want to ask is the following, and I am sorry if it sounds a little dumb or something: is it possible to use ASP.NET Core’s tools for authentication (registering and login of users of the application) without a dedicated database specifically for it? Basically, this is what I want my application’s database to look like, even though I know that the recommended path is for all the tables that are prefixed with AspNet to be in a separate database (see image below, where I crossed out in red the stuff that I created for the application for security reasons, and only left the tables that ASP.NET Core creates by default for authentication):
MyDatabase on Microsoft SQL Server

Now, the reason why I was recommended by the senior dev of the Project (there are only two devs in the project: him and me, and I’m a junior), who is on the front-end, to follow this path of just one database is for economic reasons, as the Project is really small, and he told me that more than one database means spending more Money, and there are budget constraints.

The Problem

So, on to the technical issues I’ve been having. When I have a dedicated database specifically for authentication (which means I will have two DbContexts in my app – something like “MyApplicationDbContext” and “MyApplicationAuthorizationDbContext”), registering and login cause no problem at all: new users are saved on the database, and if you don’t log in and try to access certain routes without authorization, you won’t be able to do so; but if you do log in, you can access those routes with no problem at all. However, if I try to put everything in a single database (and therefore, use just one DbContext – which is what I want to do, due to financial reasons, as I said), registering is not a problem, but logging in is. Basically, I can log in, but the routes that require authorization can’t “recognize” that I am now an authorized user, and therefore I can’t access them (whereas I can if I have two databases). That is the problem I’ve been having, in a nutshell. And what puzzles me is that in both situations (both when I am working with two databases and when I am working with just one database) the users are saved on the database, logging in seems to be successful, and valid JwtTokens are returned by Swagger as a response.

Example

For example, let’s say that I have this user here (and I will attach some screenshots from Swagger and Microsoft SQL Server to walk you all through it):
Example user

When I register this user, everything goes well. Here is Swagger’s message after registering this user:
Screenshot from Swagger right after registering

And to prove that this user was indeed saved into the database, here is a screenshot of Microsoft SQL Server:
User saved in the database

Now, I haven’t logged in via Swagger yet, so let’s try to access a route that can only be accessed if you are authorized:
Access denial before login

Ok, now let’s log in. Having clicked the “Authorize” button on Swagger on the top right, and having inserted the JwtToken following the format “Bearer myJwtTokenIsInsertedHereAndItIsALongString” this is what I get:
After authorization

Right, so on to trying to access the route that can only be accessed by authorized users. As you can see, it’s like I hadn’t even logged in at all (or maybe the application doesn’t recognize the JwtToken? I don’t know):
Access denial even after login

So, what can be done in my situation? Is there a way to be able to use all the tools that Microsoft provides for authentication, while at the same time using just one database? Maybe I’m missing something? Or do I have to do everything from scratch if I want just one database for everything? (For example, manually create a HashPassword algorithm – and things of that nature – instead of relying on what is already built into the .NET framework, which does that for you automatically)

Observation: There is no email validation at the moment; that is, the application still doesn’t send an email confirmation or anything (it will be implemented in the future, of course), so at the moment one can insert whatever string she/he wants as an email.

Any help would be appreciated, and I am sorry for the long post!

New contributor

Antonio de Odilon Brito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật