This is an important distinction, especially for SaaS teams. A successful login only tells part of the story. Knowing who changed a role, modified an account, or accessed sensitive resources is just as important when investigating security issues. I also like that you highlighted the gap between Keycloak events and application-level auditing. Both layers need to work together to give teams a reliable picture of what's happening.
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
Thanks! That's exactly the point. Authentication is only one part of the security world. When something goes wrong, having a clear trail of both identity-related events and actions inside the application can save teams a lot of time and guesswork.
Glad you found that distinction valuable!
The two-layer point is the part most teams miss. Keycloak can tell you who logged in, but not who changed an invoice.
On the app side, if youβre on .NET, an EF Core SaveChanges interceptor is a clean way to do it. It sees every changed entity with its original and current values, so you get before and after auditing without adding code to every service.
One thing Iβd add on integrity: give the appβs database user INSERT only on the audit table, no UPDATE or DELETE. Then even a bug or a compromised app canβt quietly rewrite history.
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
I like the point about restricting database permissions on the audit table. Even if you're capturing all the right events, you still need to make sure those records can't be quietly changed or deleted. And the EF Core interceptor is a practical approach for .NET teams. It makes application-level auditing much easier to maintain without spreading that logic across every service.
Thanks Hadil. For stricter setups, some teams also ship audit events to a separate store, so even a database admin canβt change them. For most apps, INSERT only already closes the biggest gap.
The detail about Keycloak recording the administrator's user ID instead of a name caught my attention β that is the kind of thing that wastes an hour in an incident if you do not know it in advance. Good practical write-up.
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
Exactly! It's one of those small details that can save you quite a bit of time when you're investigating an incident. Having the user ID is useful, but knowing that you still need to look up the corresponding account to identify the administrator makes the whole process more clear.
Exactly, that lookup step is the part people skip. The user ID alone does not name anyone until you match it in the Users section, so during an incident that extra step is where the time goes. Good point about keeping the admin events and the lookup together.
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
Absolutely! And that's exactly why having both pieces of information readily accessible makes such a difference. During an incident, nobody wants to spend extra time trying to figure out who an ID belongs to. It's a small detail, but it can make the investigation much smoother.
Founder of Hex16, a small web studio in Poland. I build Next.js sites and headless Shopify stores, with GSAP, Three.js and shaders where they earn their place, and look after technical SEO.
The before/after values part is where it gets fun in the EU. Once the audit log keeps the old and new email or address, it's a second copy of personal data with its own retention, and every GDPR deletion request now has to answer what happens to the log. Do you redact values after some time, or keep the full trail and treat the log as personal data too?
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
That's an important point, especially for SaaS products handling customer data in the EU. It's easy to focus on capturing enough information for investigations and overlook the privacy implications of keeping those records. I think audit logs need their own retention and data protection policies, with careful consideration of what information actually needs to be preserved. Keeping a useful history shouldn't mean holding on to every piece of personal data indefinitely.
Founder of Hex16, a small web studio in Poland. I build Next.js sites and headless Shopify stores, with GSAP, Three.js and shaders where they earn their place, and look after technical SEO.
Agreed. What I see most often is that retention gets decided for the main database and the audit log just inherits "forever" because nobody owns it. Thanks for the article, it's a good checklist to go through.
Authentication answering "who got in" is not the same as answering "who removed that account" or "who changed that role." Those are different records, and customers notice the gap the first time something goes wrong.
A useful audit line names the actor, the action, the target, and enough before/after detail that a support person can reconstruct the event without reading raw logs.
At Ascendra Ventures we put that trail into the acceptance criteria for SaaS and admin builds. Login is table stakes. Prove-who-did-what is what makes the product operable after launch.
Do you store that trail as first-class events, or do you reconstruct it from server logs when a ticket lands?
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
I completely agree that reconstructing what happened from scattered server logs after a support ticket arrives can quickly become a headache. Having audit events as a first-class part of the application makes a difference, especially when you need to give customers clear answers. Building this into acceptance criteria from the start is a great practice.
I research AI tools, APIs & agents β comparing specs, pricing and real user reports β then publish honest rankings so you don't waste money. Research-first, never sponsored fluff.
The two-layer point is the one most teams miss β Keycloak tells you who logged in, not who changed an invoice. umerfarooqofficial's EF Core interceptor is the neat version of that on .NET, it sees original and current values without code in every service. Do you run the audit table permissions locked down too, or is that the part teams usually leave for later?
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
I'd definitely put audit table permissions on the checklist from the beginning. It's easy to focus on capturing every change and forget about protecting the records themselves. Restricting updates and deletes helps preserve the integrity of the audit trail, which is just as important when you're investigating an incident.
The distinction between "login succeeded" and "who changed the permission after that" is the part most early SaaS dashboards skip. Curious how noisy Keycloak's audit stream got once you had more than a handful of admin users β did you filter by realm/client early, or drown first?
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
Good question! I think filtering becomes important pretty quickly as the number of users and administrative actions grows. Filtering by event type, user, and other available details can make investigations much easier. I'd also recommend centralizing the logs early, so teams can search and correlate activity without having to dig through everything manually. It's much easier to build that habit before the audit stream gets overwhelming!
I write about Next.js + TypeScript + AI engineering, with a focus on making sites discoverable to LLMs and AI search. Long-form notes at mudassirkhan.me
the line that a successful login event will not explain how a customer got admin rights is the useful framing, since the role assignment lives in admin events and nobody looks there first. one gap i would flag with Include Representation: it stores the request payload, so you want to scrub secrets and personal data before those events land in a central log. also the app level audit trail matters more than people expect, because keycloak never sees the business action. where do you draw the line on retention, keep admin events longer than login events?
Software Engineer β’ Technical Writer (300K+ readers & 25K+ followers) β’ Trusted by 20+ startups and tech companies worldwide
I turn brands into websites people π to use
That's a good catch about Include Representation! Capturing the request payload gives you more context, but it also means being careful about what gets stored and forwarded to external logging platforms. Scrubbing sensitive information before it reaches centralized logs is definitely worth considering.
As for retention, I think it makes sense to define different policies based on the type of event and its investigation value. Administrative changes may need a longer history than routine login activity, depending on the application's security and compliance requirements. The important thing is to make those decisions deliberately, with privacy and storage considerations in mind.
We're a place where coders share, stay up-to-date and grow their careers.
This is an important distinction, especially for SaaS teams. A successful login only tells part of the story. Knowing who changed a role, modified an account, or accessed sensitive resources is just as important when investigating security issues. I also like that you highlighted the gap between Keycloak events and application-level auditing. Both layers need to work together to give teams a reliable picture of what's happening.
Thanks! That's exactly the point. Authentication is only one part of the security world. When something goes wrong, having a clear trail of both identity-related events and actions inside the application can save teams a lot of time and guesswork.
Glad you found that distinction valuable!
The two-layer point is the part most teams miss. Keycloak can tell you who logged in, but not who changed an invoice.
On the app side, if youβre on .NET, an EF Core SaveChanges interceptor is a clean way to do it. It sees every changed entity with its original and current values, so you get before and after auditing without adding code to every service.
One thing Iβd add on integrity: give the appβs database user INSERT only on the audit table, no UPDATE or DELETE. Then even a bug or a compromised app canβt quietly rewrite history.
I like the point about restricting database permissions on the audit table. Even if you're capturing all the right events, you still need to make sure those records can't be quietly changed or deleted. And the EF Core interceptor is a practical approach for .NET teams. It makes application-level auditing much easier to maintain without spreading that logic across every service.
Thanks Hadil. For stricter setups, some teams also ship audit events to a separate store, so even a database admin canβt change them. For most apps, INSERT only already closes the biggest gap.
The detail about Keycloak recording the administrator's user ID instead of a name caught my attention β that is the kind of thing that wastes an hour in an incident if you do not know it in advance. Good practical write-up.
Exactly! It's one of those small details that can save you quite a bit of time when you're investigating an incident. Having the user ID is useful, but knowing that you still need to look up the corresponding account to identify the administrator makes the whole process more clear.
Exactly, that lookup step is the part people skip. The user ID alone does not name anyone until you match it in the Users section, so during an incident that extra step is where the time goes. Good point about keeping the admin events and the lookup together.
Absolutely! And that's exactly why having both pieces of information readily accessible makes such a difference. During an incident, nobody wants to spend extra time trying to figure out who an ID belongs to. It's a small detail, but it can make the investigation much smoother.
The before/after values part is where it gets fun in the EU. Once the audit log keeps the old and new email or address, it's a second copy of personal data with its own retention, and every GDPR deletion request now has to answer what happens to the log. Do you redact values after some time, or keep the full trail and treat the log as personal data too?
That's an important point, especially for SaaS products handling customer data in the EU. It's easy to focus on capturing enough information for investigations and overlook the privacy implications of keeping those records. I think audit logs need their own retention and data protection policies, with careful consideration of what information actually needs to be preserved. Keeping a useful history shouldn't mean holding on to every piece of personal data indefinitely.
Agreed. What I see most often is that retention gets decided for the main database and the audit log just inherits "forever" because nobody owns it. Thanks for the article, it's a good checklist to go through.
Authentication answering "who got in" is not the same as answering "who removed that account" or "who changed that role." Those are different records, and customers notice the gap the first time something goes wrong.
A useful audit line names the actor, the action, the target, and enough before/after detail that a support person can reconstruct the event without reading raw logs.
At Ascendra Ventures we put that trail into the acceptance criteria for SaaS and admin builds. Login is table stakes. Prove-who-did-what is what makes the product operable after launch.
Do you store that trail as first-class events, or do you reconstruct it from server logs when a ticket lands?
I completely agree that reconstructing what happened from scattered server logs after a support ticket arrives can quickly become a headache. Having audit events as a first-class part of the application makes a difference, especially when you need to give customers clear answers. Building this into acceptance criteria from the start is a great practice.
The two-layer point is the one most teams miss β Keycloak tells you who logged in, not who changed an invoice. umerfarooqofficial's EF Core interceptor is the neat version of that on .NET, it sees original and current values without code in every service. Do you run the audit table permissions locked down too, or is that the part teams usually leave for later?
I'd definitely put audit table permissions on the checklist from the beginning. It's easy to focus on capturing every change and forget about protecting the records themselves. Restricting updates and deletes helps preserve the integrity of the audit trail, which is just as important when you're investigating an incident.
The distinction between "login succeeded" and "who changed the permission after that" is the part most early SaaS dashboards skip. Curious how noisy Keycloak's audit stream got once you had more than a handful of admin users β did you filter by realm/client early, or drown first?
Good question! I think filtering becomes important pretty quickly as the number of users and administrative actions grows. Filtering by event type, user, and other available details can make investigations much easier. I'd also recommend centralizing the logs early, so teams can search and correlate activity without having to dig through everything manually. It's much easier to build that habit before the audit stream gets overwhelming!
the line that a successful login event will not explain how a customer got admin rights is the useful framing, since the role assignment lives in admin events and nobody looks there first. one gap i would flag with Include Representation: it stores the request payload, so you want to scrub secrets and personal data before those events land in a central log. also the app level audit trail matters more than people expect, because keycloak never sees the business action. where do you draw the line on retention, keep admin events longer than login events?
That's a good catch about Include Representation! Capturing the request payload gives you more context, but it also means being careful about what gets stored and forwarded to external logging platforms. Scrubbing sensitive information before it reaches centralized logs is definitely worth considering.
As for retention, I think it makes sense to define different policies based on the type of event and its investigation value. Administrative changes may need a longer history than routine login activity, depending on the application's security and compliance requirements. The important thing is to make those decisions deliberately, with privacy and storage considerations in mind.