About firebase-auth-internal-app
firebase-auth-internal-app is an implementation guide for adding Firebase Authentication to internal applications. It covers domain restrictions, Custom Claims permission synchronization, and Firestore security rules, with environment-specific settings confirmed before implementation.
Key features
- 01Configure Firebase Authentication sign-in
- 02Restrict email domains with blocking functions
- 03Sync user permissions to Custom Claims
- 04Set up Firestore security rules
- 05Confirm domain, field, and role settings
Use cases
- 01Allow registration only from specified email domains
- 02Update token permissions when user documents change
- 03Set role-based access rules for the users collection
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ tanabee/ skills --skill firebase-auth-internal-appAfter installing, type/firebase-auth-internal-appin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
references/blocking_functions.mdcustom_claims.mdsecurity_rules.mdDetails
From the project READMEIntegrate Firebase Authentication into an internal application. Implement the following components.
Prerequisites
- A Firebase project has been created
- Firebase CLI is installed and logged in
- Firestore is enabled
- The
firebase-auth-basicsskill is available
Implementation
1. Authentication Setup
Follow the firebase-auth-basics skill to:
- Use AskUserQuestion to ask the user which authentication method to use
- Provision the selected authentication method (
firebase.jsonconfiguration or manual setup via Firebase Console) - Implement client-side authentication (initialization, sign-in, auth state monitoring, sign-out)
Refer to firebase-auth-basics for all authentication method options, provisioning steps, and client SDK implementation examples.
For non-web platforms (iOS / Android / Flutter / Unity, etc.), fetch the relevant platform information from the official documentation at https://firebase.google.com/docs/auth.
2. Domain Restriction via Blocking Functions
Implement based on references/blocking_functions.md.
Using beforeUserCreated, implement the following:
- Determine the domain from the user's email address
- If the domain is allowed, register user information in the Firestore
userscollection - If the domain is not allowed, return an error to reject sign-in
- Set the initial
rolein Custom Claims via the return value (return { customClaims: ... }), so it is included in the ID token from the first sign-in
Use AskUserQuestion to ask the user for the allowed email domain(s) (e.g., example.com). For multiple domains, ask for comma-separated input.
Also confirm the following:
- Fields to store in the
userscollection (default:email,role,createdAt)
3. Permission Management via Custom Claims
Implement based on references/custom_claims.md.
Use onDocumentWritten to monitor changes to users/{id} documents and sync permission information to Custom Claims:
- Initial claims are set by the
beforeUserCreatedreturn value (section 2); this trigger handles subsequent updates only - When the permission field in a
usersdocument is updated, reflect it in the ID token viasetCustomUserClaims - On the client side, Custom Claims in the token can be used for permission control
Default role values:
admin: Administratoruser: Regular userpending: Pending approvaldeleted: Deleted
The initial role for users who pass domain restriction is user. Confirm the following with the user:
- The permission field name to store in Custom Claims (default:
role) - Whether to customize the
roletypes (default:admin,user,pending,deleted)
4. Firestore Security Rules
Implement based on references/security_rules.md.
Define helper functions isUser() and isAdmin() based on the role Custom Claim, and set up security rules for the users collection as a minimum.
The application's other collections should also use isUser() and isAdmin() for access control.
Notes
- If any prerequisites are not met, notify the user which ones are missing before proceeding
- Always confirm environment-specific values such as allowed domains and app name with the user before setting them
- Blocking Functions use Cloud Functions for Firebase (2nd gen)
- Writing to the
userscollection uses thefirebase-adminSDK (server-side)