This episode is brought to you by WorkOS. If you're building a B2B SaaS app, at some point, your customers will start asking for enterprise features like single sign-on, skim, provisioning, role-based access control, and audit trails. That's where WorkOS comes in, with ease-to-use and flexible APIs that help you ship enterprise features on day one without slowing down your core product development. Today, some of the hottest startups in the world are already powered by WorkOS, including ones you probably know, like Perplexity, Vercel, Jasper, and Webflow. WorkOS also provides a generous free tier of up to 1 million monthly active users for its user management solution.
making it the perfect authentication and authorization solution for growing companies. It comes standard with rich features like social logins, bot protection, MFA, roles, and permissions, and more. If you're currently looking to build SSO for your first enterprise customer, you should consider using WorkOS. Integrate in minutes and start shipping enterprise plans today. Check it all out at WorkOS.com. That's WorkOS.com. Hello, and welcome to another episode of The Bike Shed, a weekly podcast from your friends at ThoughtBot about developing great software. I'm Joelle Kinville. And I'm Stephanie Min, and together we're here to share a bit of what we've learned along the way.
So, Stephanie, what's new in your world? So I have a new little software productivity quality of life thing to share, which is Notion Calendar for managing multiple calendars. Specifically, I oftentimes have like a client calendar on a client Google account, for example, in addition to my Thoughtbot calendar. And it has been such a pain to negotiate having both calendars and forgetting to block stuff off on each of them and then getting calendar invitations for meetings during times that don't actually work for me. But other people didn't know that because.
I failed to do the tedium of syncing both of them. So I finally did something nice for myself, and I'm trying out Notion Calendar, which I had heard is very useful for managing multiple calendars. Specifically, it has a really great autoblock function where you can choose either events in a series or just your entire calendar, and it will automatically block that time off across multiple calendars for you. So I'm really happy that I finally got that installed. Actually, not even installed. I mostly just use the web version of it. I also wanted to add that you don't...
really even need to be a Notion user to use Notion Calendar. It's like a whole separate little product. If you don't use Notion as your main note-taking platform. Yeah, that's right. I have heard that it does play well with, if you do use Notion, those things integrate pretty nicely. But I've been very happy just using it separately. And it has pretty much replaced my Google Calendar tab on my browser. It even lets you see your teammates' calendars and stuff. So I think they did a really good job making it kind of like that one-stop shop. So you don't need to be searching for functionality on.
multiple calendar applications. So how many different calendars are you syncing through Notion Calendar at this point? The answer is three now. Yeah, I think it might have even been four before when I had... a Word Calendar, a Thought About Word Calendar, a client Word Calendar, a personal one, and then another shared one for my household. But now it's down to three. And I don't know how anyone could manage more than that. Maybe there are people out there who do. And in that case, Notion Calendar is perhaps the tool for you. I feel like I have a vague sense of Notion Calendar being like a standalone sort of third-party calendar app that Notion acquired and then sort of rebranded as Notion Calendar. Am I right here? I don't know. That's a really good question. If they did, then that would be really smart.
But I have... known about it just as a, I've always known it as Notion Calendar. At one point, maybe I did have the misconception that it was something that was bundled with just Notion, the note-taking product, but it's not. So I'm happy with being able to just use that functionality and I think it does it really well. Maybe that actually is evidence that it might have been its own separate product and kind of focused on that. I always love talking about our tools and workflow here because then it's the kind of thing that we can check in in a few months and be like, hey, so how's Notion Calendar working out for you? Are you still using that? Yes. And we get to sort of learn from each other as we discover and try out new things. Yeah, I will also say the last little thing is I kind of like that it's
a standalone thing. I don't necessarily need or want it to become like my whole ecosystem of tooling. It's like I want a calendar that works really, really well as a calendar. And that at least for me is enough. That's fair. So Joel, what's new in your world? As of the time of recording this, it's November and it's the season where in the United States, you start going through registering for health plans, typically through an employer. And so I've been shopping and comparing health plans for health insurance.
And there's just always so many variables that go into a health plan. And like, these things are covered, but these are not. Or there's, you know, you pay up until a certain amount and then the plan kicks in, except for these things, except, except. And I was really struggling to get a good sense of like comparison. And I ended up building.
effectively a little simulation, just building out a spreadsheet of different types of scenarios of like, oh, a year where you have a bunch of like little medical costs or a year where you have a bunch of like big ones. And how would each plan then react to those sorts of scenarios and kind of graph them out? Like how much you're spending over the year? And I think that really allowed me to visualize, oh, this is how they react in different situations. And that was, I think what finally allowed me to make sense of like, oh, I see. So this plan is for people who are expecting this kind of year. This plan is for people that are expecting this kind of year. Or this plan is better sort of at the lower end, but this plan is better at the higher end or whatever it ends up being.
That sounds so useful. It also reminds me of occasionally, at least in my experience, picking health care plans in the U.S., the benefits will give examples of different scenarios like Ruth broke her leg and, you know, it costs like this much to see a doctor and like this much in medication or whatever. And it gave like a final cost of like, this is what Ruth paid. And then a different scenario for Paul has like an ongoing chronic illness, that kind of thing. So it seems like this is already a concept of something that helps people get the information they need to make the right choice for them.
it would be even better if you can plug that into different healthcare plans to evaluate your options. I'm curious, did you do this programmatically? I'm assuming that you did. I did not do it programmatically. This is just like Google Sheet. Some of these places I use formulas to calculate the numbers and some places I just straight up did the calculations by hand and wrote a raw number in.
So let's just say I didn't write it in a modular, reusable way, but I got the numbers for the scenarios that I wanted. How could you not? I'm just kidding. I know the programmer in me is like, oh, how do you do this? It's interesting because there's a lot of these things where I would want to reach for a conditional. I'm trying to keep formulas relatively simple and write that sort of more declarative style code that's purely as a math formula. It's sometimes hard to do with the...
something where you're saying, we need to start having conditionals in. So some things that are sort of built in that you can already do, like, hey, when you're handling something like a deductible, you can do like a minimum of two numbers or things like that. But calculation, minimum of the two calculations or something like that. But as it gets more complex, you have to start getting really fancy with the formulas. But yeah, free app idea for anyone out there who wants to take something you can plug in your plan or manual entry or automatic entry. That would be great. And show us five or six common scenarios, what your year might look like, and maybe graph your expenses over a year. I would love to see that. Yeah, I also would. And launch it in November. Clearly, we know all about building web products.
Another thing that's been new in my world is this week on my current client project, a request came in to build an impersonation feature. And I have a lot of really mixed feelings about impersonation. So impersonation typically is the thing that admins can do and they can like, you're logging as admin and then you can go to somebody's dashboard or something and convert your admin credentials into being this person and sort of take over their account. And now you, for the purpose of the session, you are that person and can basically do anything that they can do. And it's a thing that I see requested on a semi-regular basis. I'm curious, have you ever run into situations where you've had to either use or implement impersonation as a feature? Yes, I have not had to implement it, but I've worked on several applications that have it built in. And yeah, that's kind of a pretty big way the admin part of the app is used to maybe debug or inspect the state of a user who might be having some trouble and you need some support from a customer support team or something like that. And how do you feel about...
impersonation as a tool for doing that. Have you seen that work pretty well? I think this is a with great power comes great responsibility kind of feature. It is, I think it's like a dangerous feature in some ways, because the idea of someone being able to just do anything that they want on someone else's account, right, that can come with a lot of risk. And yeah, it's a very powerful, can be very useful. But at the same time, I don't think we fully think about the implications before deciding to do it, especially I've seen it be as easy as kind of like swapping out the user session. And so I think...
Maybe people will reach for it thinking that it's a quick way to get that power. But it also, in some ways, I think can really distort your system if you haven't set up the right guardrails around it. A potentially hot take that I have is that the need or the desire for impersonation is oftentimes a sign of poor admin tooling. So there's a variety of things that might motivate wanting impersonation. But a common one is we want customer support to be able to change things for a customer. And those things might be settings in that customer's dashboard. And so that's the actual core problem that you're trying to solve.
And then we sort of immediately jump to, oh, we should solve this using impersonation. And then it comes to the dev team and says, build impersonation for us. When actually sometimes if you step back and say, well, the core problem we're trying to solve is customer support people need to be able to make changes for customers to their settings. That can be solved in other ways. For example, just making that editable on an admin dashboard. You don't have to change checkbox you check on and off. The path of changing that doesn't have to go through logging in as that user.
Yeah, I would even go so far as to say what is preventing the user from doing it themselves, like being instructed how to do that or having a clear path forward for the user to resolve their own problems. I do think that impersonation can be valuable in seeing what's going on, kind of that debugging piece, right? Because, yeah, it's really challenging to troubleshoot something if you aren't able to see the same, observe the same behavior. But I think the doing things as that person can get a little tricky. That's a very different use case than just the fixing a setting on a user's account. Because I think that gets a little bit at...
how you interact with your customers. If you're doing something over a phone call, that might be a situation where it's really useful for you to see what's going wrong. But if you're doing this over like chat or email, maybe you can get a screenshot and that's fine. Or you could even, if you're on a computer, you can do a screen share call and then somebody can just show you, hey, this is what I'm dealing with. But a lot of customer support happens over the phone. So you might not have the ability to have a visual. Yeah. So I'm curious then when you were asked to implement impersonation.
What did you do? So I pulled the classic sort of product consultant move and asked like, why do we want this feature? What is the problem we're trying to solve? And then that spins off a conversation. And then we talk a little bit about the pros and cons of different approaches we're trying to do, the cost in terms of like the time to implement, and sort of the nuances around what you need.
A thing that I generally find concerning with true impersonation is the sort of hijacking of the identity. From the point of view of the system, Joel, the admin, is no longer the person who's logged in. I am now Stephanie, the customer. And especially in systems where you care about auditability, that can lead to some weird things. So you have to like, hopefully you're logging that I'm impersonating you. Because if I'm doing actions on your behalf, then you want to make sure that I'm not having an audit log that's claiming that I am you. It's another sort of vector for attack. So it's a thing you've got to be careful of in terms of security.
And it's also something you might want to be careful of in terms of authorization. If you allow someone to literally log in as someone else, then the things that I as an admin can do are all the things that you can do. And maybe from a customer support perspective, I would like a customer support person to be able to go to your dashboard and do some things, but I don't necessarily want them to have the ability to do all of the things that you can do as a client. And so being able to differentiate between those two scenarios and apply slightly different permission sets can be important. Yeah, I think that's especially true if there's sensitive data and things like that. I mentioned this idea of like distorting the system earlier because I was thinking about observability and analytics and how those can also be confusing when you have an impersonation system. Specifically, one of the experiences I had was when we would get notified of exceptions in our exception handler for, I think it was something like it was for an account that was inactive. And I remember being so confused about how an inactive account could even reach like a certain page or something like that. And it turned out.
that the reason for that was that an admin user who is logged in can impersonate someone else and then go to a page and trigger something that then confuses the system. But then the worst part, I think, was as a developer, I didn't know which admin this was. So I also couldn't then go help them out and find out whatever they were trying to do and then see if there was anything I could do for them. And yeah, we, I don't know, we just like never made a decision about that and then kind of continue to have to exist with these confusing notifications about issues with our system. That's where you have to really think about sort of the logging and audit trail side of this.
doing impersonation. I think there's sort of a range of solutions that you can go with. My preference is generally stopping short. If you do lean towards the impersonation side of things and you say, hey, we do need to see something as someone else, stopping just short of actual impersonation and saying, can the system render this view as it would for the person I want to impersonate while still maintaining my identity as the admin? such that then all of our systems around things like permissions can keep working as they already work, and things around logging and auditing can still keep working the way they work. So if I do an action on your dashboard, it will then log that I did it as the admin rather than you doing it.
Interesting. Do you think there's like a level of abstraction that you would separate those things then? I was kind of thinking about it like reading versus writing, but I wasn't sure if you had something else in mind. I think that there's a sense of differentiating who the logged in user is and who the user is that you're rendering views for. And those two things are maybe not always the same. Oh, yes. Okay, let's talk about the idea of current user then. Yeah, because the current user can sometimes mean multiple things. It's very easy in an app to tightly couple yourself to the current user. And so you have something like a dashboard page.
And every user has their own, but you don't go to slash user slash one to view a dashboard. You just go to slash dashboard. And then it's hard-coded to work on current user rather than reading an ID from the URL. that then makes it really tricky for anybody else to see that page. And so the sort of train of thought then is, well, the only way to allow anybody else to see that page is to take over current user through a mechanism like impersonation. Yeah, I think that's especially true if you end up having a lot of functionality being called from the current user. You know, I even, I see it in controllers and in views too, right? Where you're, like you said, calling methods on current user itself. Whereas I suspect that.
Even if you just assigned current user to another variable called user, you would be a little bit less locked in to this idea of coupling the idea of whoever the user is in the context of being the one that's locked in. So we've talked on the show a bunch about the book Sustainable Rails Development. And there's a section there where it talks about best practices around building your routing. And the practices that are generally recommended there are to build standard Rails resourceful things for every resource, and then to sort of layer on vanity URLs as aliases to things that already exist. So you might have, in this case, maybe something like creating a user show page based off an ID in the URL.
And then maybe you can do some sort of alias where dashboard is just that user's page, but rendered for the current user. And then you've got to make sure then you've got to be careful for enumeration attacks and things like that. And you lock it down via authorization so that you're only allowed to view that user's page for yourself and not for other people. But what's nice with that then is that if you're an admin, you can tweak the permissions a little bit to say admins are allowed to see some or all of those user's pages for anyone. And now you don't even need impersonation. You can just go to somebody's dashboard and see it. And maybe for you, there's like an actual URL. You're going to users three and users four to see different users' dashboards. And you don't need to be constantly sort of impersonating and going in as one person and out as another. You can just see the page, take action, navigate away. It's normal. Okay, interesting. So that's actually not where I thought you were going to go. It seems like you're eschewing the idea of impersonation entirely in favor of just more robust policies or more rich policies and features that then kind of are assigned through that model.
I think policy, like authorization is going to be important sort of whichever path you take. I think I'm arguing for designing your resources to be less tightly coupled to current user. It's a little bit like the functional programming idea of passing in your variables rather than relying on some sort of global state. So let's say I'm designing a function that does stuff with users. If I'm relying on a global variable current user, then it's tricky to try to call this function for any other user than the current user. Whereas if I pass a user in as an argument, I can run this on any arbitrary user and get the output that I want. So you're doing sort of the same thing for your URLs and your views. If you don't tie yourself to current user so tightly, you can then say, hey, this dashboard, usually I only render it for self. But if I have permissions, I can render it for anybody I want.
I think that's sort of my ideal path for designing something like this. Now we're sort of moving far away from impersonation. And so that's not always going to be the solution. But I think it's the, by default, what I would tend to reach for. Yeah, that's interesting because I was thinking more about it from a, when you said vanity routes, that kind of got me thinking about the idea of impersonation being a mask a little bit, right? You're pretending to be someone else.
For some reason, that idea was like, oh, maybe there's a way to bundle some kind of object that stands in for this idea of the concept of impersonation that holds whoever you're trying to impersonate as well as the person actually doing the things. So I like where you're going. I think this is probably where I'm going to end up going for this particular feature. The idea that we want something that approaches impersonation, but it's not true impersonation. We're not effectively doing a session hijack. You still are the admin from an identity perspective in the app, but you're seeing everything as if you were some other person.
Exactly how that's going to work, I'm looking at a couple of different ways, but one possibility is decorating a current user to have extra methods on it that can take care of the fact that, yes, you are the admin, but also you are trying to view as somebody else's profile. There's a pretty common problem, I think, that I see as a developer. And I think that impersonation falls pretty squarely into this, which is oftentimes people come to you with solutions and they're just like, implement the solution for me instead of coming with a problem and then sort of working through what are some technical solutions that could help. And in this case, it's coming and say, hey, I want impersonation rather than saying, oh, I need my client needs or my customer support people need better tooling to help clients debug. Or an admin needs to be able to make changes for people. And then you can talk a little bit about how to get there.
Yeah, I'm curious about, I think in some ways, what we as developers can provide in being a part of that problem solving process. Because I agree with you that I also tend to get things that maybe it was like kind of the first or even second idea when I think it is really important because not all of them are always like feasible from a technical perspective, right? Or just have different trade-offs to consider. And when devs are just kind of brought in to implement solutions, I think there's a real lost opportunity to... solve the right problem both for the people that we're trying to solve the problem for and for us as developers who then kind of have to live with navigating around these.
solutions that we may or may not have had a say in. I think that's often what I see as a mark of someone who's moving up from sort of junior developer into more intermediate is that ability to engage with like stories and tickets, not as a, oh, here's a spec that I must implement. And my role is turning tickets into code and starting to see a slightly larger picture, engaging with the product, talking to the product people, talking to designers and be like, all right, so here's the solution that's proposed. Let's understand a little bit about why we're trying to do it. Is the scope about right? Here's a couple of different technical solutions with different trade-offs.
Or maybe something that's not quite what you asked, but I think it's solving the problem you're trying to fix, and it's technically much easier or much less costly. Yeah, I've definitely been in a lot of situations where I ask the question of, do we have to do that? Because if we didn't, then I could finish this tomorrow. I do think that is really challenging to almost just dissolve some of the constraints. I think people really like the specifications because it literally gives them a blueprint about what to do. But I think that some of the fun is in figuring out what is the actual goal as opposed to just what we are being able to do, like what the application does as opposed to what it is.
kind of enables or solves for. And sort of like classic agile ideas is the idea of cross-functional teams. So it's not just, oh, you know, these people over here are going to like... in a phase, sort of come up and design and spec out everything. And then we pass it over a wall and the devs just build it out and then we ship it. But you get people from different sides. So stakeholders, it may be a client, it may be a product person, you get designers, you get various technical people, you get them in a room and you get them working together. And that this results in teams that better solve the actual problems and they can iterate faster because they're all sort of talking to each other and they're working together from all other different perspectives. Because there's perspectives that we have as devs that a product person or a design person might not necessarily have. But also as devs, we don't necessarily fully understand what...
stakeholders are wanting or what customers are needing? What is it like to be a customer support person who's trying to help out somebody? Am I making assumptions about the tools I'm building for them because I am not them? I'm like, well, of course you're going to be at a laptop doing things for them when actually you're on the phone writing things down on a notepad and then at the end of the day you input into a computer or something like that. So having everybody's perspectives is really important. Yeah, I also think that...
You know, I can see how someone might think that impersonation will solve the problems by breaking down all the barriers so that support folks can have like the full agency. But I also think that in many ways, it just is trading for a new set of problems around kind of what we talked a little bit about earlier with auditability and security. And yeah, it's almost like going too deep into that direction when really they just needed a hammer or something like that. Those are perspectives that you probably need someone from the dev team to bring. You'd be like, oh, but how's this going to affect our audit log?
How does this affect security? Those are not necessarily things that someone in the product team has the answers to. It's also very easy for people on the product team to be thinking in a very positive sense, like happy path stuff. Here's the things that we want to do and here's the behaviors we want. And I think sometimes our job as developers is to obsess over the unhappy path and be like, but how does this go wrong? How might this be abused? What are the security implications of this? Could this be hacked? Oh yeah, I think...
In some ways, a really big portion of our jobs is preventing things from happening, preventing things from going wrong specifically. And that's so hard to quantify because the point is that it didn't happen. Do you feel like for yourself in your career, there was a point where you maybe crossed that line from just implementing tickets and specs to getting a little bit of a product sense and wanting to have those broader conversations? I think it definitely does come from experiencing the pain. And so it's really hard to explain to someone why this might not be a good idea because they see all they're maybe seeing the promise of it without having felt the frustration or kind of having to deal with the consequences later. So, you know, we all kind of have to learn from past mistakes. But I am really, really curious about I kind of described impersonation as going into the deep end of like giving people a lot of power. And like I said, that requires a lot of responsibility. We've talked on the show a lot before about.
developing iteratively or incrementally. Do you think that approach is a useful one to look at a problem like this? Depending on how your app is architected, it might be easier to just allow impersonation than to build a custom admin. Let's say you're not really set up with permissions and roles and things to say, hey, I want my admin to basically take on this user's... permissions and roles without necessarily becoming them. And so you might make a pragmatic choice where you say, hey, look, we're constrained for time. And this is a sort of a quick and dirty way to get where we want to be. But then you have to take into account potential risks that are there. So that's often what I will do with a client is sit down with a...
It's a product, but also a technical choice and talk through, okay, well, here are the pros and cons of each path you might take. And this path will be shorter, but maybe has a slightly heightened security risk or some extra edge cases. And then you're kind of boxed into a certain way. You won't be able to have more restricted permissions for that admin. But you go this way, it might take more work up front, or maybe our app is just not architecting in a way that we can slot in this other approach. So we're gonna need to rethink a lot of things before we can even go there.
Right now, you might be better off with an impersonation approach. But being able to put out those technical pros and cons and talk in terms of costs and risks is, I think, one of the really valuable ways that as thoughtbot consultants, we come to clients. Yeah, I am very, like my mind is kind of like spinning a little bit because in some ways this problem is actually very different from ones we've talked about before where it's quite easy to swap out or do that hijacking of like who the current user is as opposed to working incrementally getting you going faster. But the thought that I had, I think kind of fundamentally changes how you have to view your application if your understanding is now like anyone can do anything and without the proper kind of guardrails, like there's that like uncertainty about who actually is performing an action or who you are seeing the application as. Yeah, that.
has a very huge amount of risk. It breaks some assumptions that we have around what current user represents. Right. Which could be what you want, but probably most of the time it isn't. Then you have to sort of, because you have this assumption around what current user does, you might accidentally not cover some edge cases in other places. Where in some places you're like, oh yeah, I want to do something with current user where current user is the person who logged in or someone impersonating them. And there are other places where you might be doing something in the app and what you really want is literally the person that logged in.
If you're not careful, you might be like, oh yeah, current user, that's clearly the person that logged in and write some code and not realize, oh yeah, I forgot about the scenario where somebody might be impersonating here. So I think this is a really classic example of things people think they want but may not actually want. And I really enjoy kind of collecting problems like these because they come up pretty frequently and it's always an opportunity to kind of like learn from past mistakes and kind of learn from how other people have gone through the journey of doing this, realizing the trade-offs and then being able to hopefully make that decision better with more information next time. I'm wondering, do you have any final thoughts about navigating situations like these or problems like these? I think we sort of jumped into this.
being like, oh, this is a technical problem. We're going to dig into it. And as you said, really, it's not at its core a technical problem. There are technical elements to explore and some risks and security and things like that. But at its core, it's a product question. It's a asking the whys behind why do we want this thing? It's understanding your customer, bringing in different perspectives, talking to product, talking to design.
it's a little bit of putting on the product consultant hat, which is the hat that we wear as a job. That's what people hire us for. But it's a thing that is valuable, I think, at all roles in all companies where you can sort of, you're a dev working for a product company. Sometimes you just put on that product consultant hat and say, all right, let's ask the whys and understand the questions here. So are you suggesting that even if you don't work for a product consulting company, you may want to impersonate a product consultant in their mindset? That's terrible. And I love it. And on that note, shall we wrap up? Let's wrap up.
Show notes for this episode can be found at bikeshed.thoughtbot.com. If you enjoyed listening, one really easy way to support the show is to leave us a quick rating or even a review in iTunes. It really helps other folks find the show. If you have any feedback or questions, you can reach us at hosts at bikeshed.fm via email. Thank you so much for listening to The Bike Shed, and we'll see you next week. Bye!