一键导入
ewl-user-management
Set up EWL user management with database schema, roles, identity providers, and the SystemUserManagementProvider
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Set up EWL user management with database schema, roles, identity providers, and the SystemUserManagementProvider
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Configure opencode on a new development machine for EWL work by creating the global AGENTS.md and granting access to the EWL source, EWL System Manager source, EWL folder, and EWL client systems directory. Use when setting up opencode on a new machine, or when the user asks to bootstrap, initialize, or configure global opencode for EWL.
Run local EWL Development Utility (DU) operations on EWL systems. Use when asked to run DU operations such as sync or update-data against a particular path or system.
Database schema migration using FluentMigrator with the EWL Data Migrator project
Inspect and troubleshoot EWL systems hosted in Azure — locating an installation's App Service, Container App Job, and Log Analytics workspace, and reliably reading Container App (data migrator) console and system logs. Use when checking whether a deploy's data migrator ran, reading container logs for a hosted installation, or investigating an installation's Azure resources. Companion to ewl-azure-pipelines, which covers the build/deploy pipelines that create these resources.
Test changes to EWL agent rules, subagents, skills, OpenCode plugins, and MCP tools by driving OpenCode headlessly, capturing transcripts, and cleaning up afterwards. Load this skill when verifying changes to anything under Library\Files\Agent Rules.md, Library\Files\Agents\, Library\Files\Agent Skills\, Library\Files\OpenCode Plugins\, or Library\Files\OpenCode Tools\.
Azure Pipelines CI/CD for EWL systems including build templates, deploy templates, and pipeline code generation
| name | ewl-user-management |
| description | Set up EWL user management with database schema, roles, identity providers, and the SystemUserManagementProvider |
EWL provides a built-in user management system with roles, authentication (local login codes or SAML), and a framework-provided admin UI. To use it you need database schema, a provider implementation, and configuration.
Create the required tables. For SQL Server:
create table UserRoles(
UserRoleId int not null constraint UserRolesPk primary key,
RoleName varchar( 100 ) not null
)
go
insert into UserRoles values( 1, 'Administrator' )
insert into UserRoles values( 2, 'Standard user' )
go
create table Users(
UserId int not null constraint UsersPk primary key,
EmailAddress varchar( 100 ) not null constraint UsersEmailAddressUnique unique,
RoleId int not null constraint UsersRoleIdFk references UserRoles,
Salt int not null,
SaltedPassword varbinary( 20 ) null,
LoginCodeSalt varbinary( 16 ) null,
HashedLoginCode varbinary( 20 ) null,
LoginCodeExpirationTime datetime2 null,
LoginCodeRemainingAttemptCount tinyint null,
LoginCodeDestinationUrl varchar( 500 ) not null
)
go
insert into Users values( next value for MainSequence, 'admin@example.com', 1, 0, NULL, NULL, NULL, NULL, NULL, '' )
go
create table UserRequests(
UserId int not null constraint UserRequestsUserIdFk references Users,
RequestTime datetime2 not null
)
go
Add role constants and caching to Development.xml:
<database>
<rowConstantTables>
<table tableName="UserRoles" nameColumn="RoleName" valueColumn="UserRoleId" />
</rowConstantTables>
<SmallTables>
<Table>UserRoles</Table>
</SmallTables>
</database>
Run sync to generate data-access classes.
Rename UsersModification.ewlt.cs to UsersModification.cs and add
pre-delete and constraint logic:
partial class UsersModification {
static partial void preDelete( List<UsersTableCondition> conditions, PostDeleteExecutor postDeleteExecutor ) {
foreach( var i in UsersTableRetrieval.GetRows( conditions.ToArray() ) )
UserRequestsModification.DeleteRows( new UserRequestsTableEqualityConditions.UserId( i.UserId ) );
}
static partial void populateConstraintNamesToViolationErrorMessages(
Dictionary<string, string> constraintNamesToViolationErrorMessages ) {
constraintNamesToViolationErrorMessages.Add(
"UsersEmailAddressUnique", "A user with this email address already exists." );
}
}
Create Library/Providers/UserManagement.cs implementing
SystemUserManagementProvider. Key methods:
GetIdentityProviders() -- return LocalIdentityProvider (and/or SAML)GetUsers() -- return all users ordered by emailGetUser( int userId ) -- look up by IDGetUser( string emailAddress ) -- look up by emailInsertOrUpdateUser() -- create or update usersDeleteUser() -- delete a userGetRoles() -- return available rolesThe LocalIdentityProvider requires callbacks for looking up users by email,
loading/storing login codes, and updating passwords.
Create Role objects from your role data:
private Role getRoleObject( int roleId ) =>
new( roleId, UserRolesRows.GetNameFromValue( roleId ), roleId == UserRolesRows.Administrator, false );
The third parameter marks admin roles (grants access to the /ewl admin area).
Check the current user in userCanAccess:
// Require login
protected override bool userCanAccess => SystemUser.Current is not null;
// Require specific roles
protected override bool userCanAccess =>
new[] { UserRolesRows.Administrator, UserRolesRows.BicycleMechanic }
.Contains( SystemUser.Current!.Role.RoleId );
Access control is hierarchical: child pages inherit parent restrictions.
The framework provides a user management UI at /ewl that allows
administrators to view, create, update, and delete users. This is
automatically available when the provider is implemented.
In development mode, a "Select User" page replaces the login page so you don't need to enter passwords.