feat(auth): pre-register Fengling.Console as OAuth client
This commit is contained in:
parent
5cdcba7e57
commit
ee48b93fae
69
docs/task-11-pre-register-console-client.md
Normal file
69
docs/task-11-pre-register-console-client.md
Normal file
@ -0,0 +1,69 @@
|
||||
# Task 11: Pre-register Fengling.Console as OAuth Client
|
||||
|
||||
## Task Description
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/Fengling.AuthService/Data/SeedData.cs`
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### Step 1: Add Fengling.Console registration to SeedData
|
||||
|
||||
Edit: `src/Fengling.AuthService/Data/SeedData.cs`
|
||||
|
||||
Add after existing seed data:
|
||||
```csharp
|
||||
// Register Fengling.Console as OAuth client
|
||||
var consoleClient = await context.OAuthApplications
|
||||
.FirstOrDefaultAsync(c => c.ClientId == "fengling-console");
|
||||
if (consoleClient == null)
|
||||
{
|
||||
consoleClient = new OAuthApplication
|
||||
{
|
||||
ClientId = "fengling-console",
|
||||
ClientSecret = "console-secret-change-in-production",
|
||||
DisplayName = "Fengling 运管中心",
|
||||
RedirectUris = new[] { "http://console.fengling.local/auth/callback" },
|
||||
PostLogoutRedirectUris = new[] { "http://console.fengling.local/" },
|
||||
Scopes = new[] { "api", "offline_access" },
|
||||
GrantTypes = new[] { "authorization_code", "refresh_token" },
|
||||
ClientType = "confidential",
|
||||
ConsentType = "implicit",
|
||||
Status = "active",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
context.OAuthApplications.Add(consoleClient);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
```
|
||||
|
||||
### Step 2: Commit
|
||||
|
||||
```bash
|
||||
git add src/Fengling.AuthService/Data/SeedData.cs
|
||||
git commit -m "feat(auth): pre-register Fengling.Console as OAuth client"
|
||||
```
|
||||
|
||||
## Context
|
||||
|
||||
This task pre-registers Fengling.Console as an OAuth client in the seed data. This allows the console to use OAuth2 authorization code flow for authentication.
|
||||
|
||||
**OAuth Client Configuration:**
|
||||
- ClientId: `fengling-console`
|
||||
- Redirect URI: `http://console.fengling.local/auth/callback`
|
||||
- Scopes: `api`, `offline_access`
|
||||
- Grant Types: `authorization_code`, `refresh_token`
|
||||
|
||||
## Verification
|
||||
|
||||
- [ ] Fengling.Console client added to seed data
|
||||
- [ ] Client configured with correct redirect URIs
|
||||
- [ ] Client has required scopes and grant types
|
||||
- [ ] Build succeeds
|
||||
- [ ] Committed to git
|
||||
|
||||
## Notes
|
||||
|
||||
- Client secret should be changed in production
|
||||
- Redirect URI matches Fengling.Console domain
|
||||
- Client will be created on first application startup
|
||||
@ -77,5 +77,27 @@ public static class SeedData
|
||||
await userManager.AddToRoleAsync(testUser, "User");
|
||||
}
|
||||
}
|
||||
|
||||
var consoleClient = await context.OAuthApplications
|
||||
.FirstOrDefaultAsync(c => c.ClientId == "fengling-console");
|
||||
if (consoleClient == null)
|
||||
{
|
||||
consoleClient = new OAuthApplication
|
||||
{
|
||||
ClientId = "fengling-console",
|
||||
ClientSecret = "console-secret-change-in-production",
|
||||
DisplayName = "Fengling 运管中心",
|
||||
RedirectUris = new[] { "http://console.fengling.local/auth/callback" },
|
||||
PostLogoutRedirectUris = new[] { "http://console.fengling.local/" },
|
||||
Scopes = new[] { "api", "offline_access" },
|
||||
GrantTypes = new[] { "authorization_code", "refresh_token" },
|
||||
ClientType = "confidential",
|
||||
ConsentType = "implicit",
|
||||
Status = "active",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
context.OAuthApplications.Add(consoleClient);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Fengling.AuthService")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d3810f5d43139224571e9558a8f9d1caf253a2af")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5cdcba7e57f11cbe819ef947fe4f31dfa3f31ce5")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Fengling.AuthService")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Fengling.AuthService")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@ -1 +1 @@
|
||||
6eb848986322eda4a24415ea7940bb6189775a7373c0cc69971ba237cf3fdeb1
|
||||
88557c3b57a3995d38feba9efb65b2d453135485aca705ead19cfd3379fa5af3
|
||||
|
||||
@ -1 +1 @@
|
||||
246db42ea15f5b11045c9c9e1cfc0e315b80d78a560048b99d9119120a177411
|
||||
a442fae7d5599fed904d1202772e57ff3d3723e8af039346ca13fe6adc50709d
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
{"GlobalPropertiesHash":"kj0YdTIP9epXJ4ydBR9yaRr5OemJ36+FlRmnBdiGrUE=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["nGadCmuBEG\u002BKUP6Powa57G4ZzOO6ibT7XQKZuYm3g44=","elQhyiEcBZcCHMIxyXyx47S4otwc/MEXjAYU/dca/hQ=","XrkTC/5D0wT4Vj8udAqp\u002B2DDPMQ5H3P4YZDu2X62NzI=","chR\u002BAL8taCFTQytCSiXtu6MS2y5z2GmMYAK8xprfbvA=","QUvWOS2l6Gf\u002Bb29f7UDXsp99Km48zx\u002BXUkHxYrdP5O4=","Zj1gozVje0UGK1srrd8TNGYUEXHzQpz/esP\u002BUaINhMs=","587UMkRW9Duvi09dG2y/rsS2zVrz865mHwElGvidCDE=","7HE6TnPvLegH\u002BkmPfdNuw7C6mM5Vgea4zehQVjDOli4="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
{"GlobalPropertiesHash":"kj0YdTIP9epXJ4ydBR9yaRr5OemJ36+FlRmnBdiGrUE=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["nGadCmuBEG\u002BKUP6Powa57G4ZzOO6ibT7XQKZuYm3g44=","elQhyiEcBZcCHMIxyXyx47S4otwc/MEXjAYU/dca/hQ=","XrkTC/5D0wT4Vj8udAqp\u002B2DDPMQ5H3P4YZDu2X62NzI=","chR\u002BAL8taCFTQytCSiXtu6MS2y5z2GmMYAK8xprfbvA=","QUvWOS2l6Gf\u002Bb29f7UDXsp99Km48zx\u002BXUkHxYrdP5O4=","Zj1gozVje0UGK1srrd8TNGYUEXHzQpz/esP\u002BUaINhMs=","587UMkRW9Duvi09dG2y/rsS2zVrz865mHwElGvidCDE=","2BIhuv/t6BVBKzkDXJ\u002BLBW5o61ISoGgjQ1cATL0tWlw="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
@ -1 +1 @@
|
||||
{"GlobalPropertiesHash":"cWEb6+iVjovCYrac7gX+Ogl5Z4cMpIEURSADGbv9ou0=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["nGadCmuBEG\u002BKUP6Powa57G4ZzOO6ibT7XQKZuYm3g44=","elQhyiEcBZcCHMIxyXyx47S4otwc/MEXjAYU/dca/hQ=","XrkTC/5D0wT4Vj8udAqp\u002B2DDPMQ5H3P4YZDu2X62NzI=","chR\u002BAL8taCFTQytCSiXtu6MS2y5z2GmMYAK8xprfbvA=","QUvWOS2l6Gf\u002Bb29f7UDXsp99Km48zx\u002BXUkHxYrdP5O4=","Zj1gozVje0UGK1srrd8TNGYUEXHzQpz/esP\u002BUaINhMs=","587UMkRW9Duvi09dG2y/rsS2zVrz865mHwElGvidCDE=","7HE6TnPvLegH\u002BkmPfdNuw7C6mM5Vgea4zehQVjDOli4="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
{"GlobalPropertiesHash":"cWEb6+iVjovCYrac7gX+Ogl5Z4cMpIEURSADGbv9ou0=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["nGadCmuBEG\u002BKUP6Powa57G4ZzOO6ibT7XQKZuYm3g44=","elQhyiEcBZcCHMIxyXyx47S4otwc/MEXjAYU/dca/hQ=","XrkTC/5D0wT4Vj8udAqp\u002B2DDPMQ5H3P4YZDu2X62NzI=","chR\u002BAL8taCFTQytCSiXtu6MS2y5z2GmMYAK8xprfbvA=","QUvWOS2l6Gf\u002Bb29f7UDXsp99Km48zx\u002BXUkHxYrdP5O4=","Zj1gozVje0UGK1srrd8TNGYUEXHzQpz/esP\u002BUaINhMs=","587UMkRW9Duvi09dG2y/rsS2zVrz865mHwElGvidCDE=","2BIhuv/t6BVBKzkDXJ\u002BLBW5o61ISoGgjQ1cATL0tWlw="],"CachedAssets":{},"CachedCopyCandidates":{}}
|
||||
Loading…
Reference in New Issue
Block a user