Catglobe.CgScript.Common
1.0.0
See the version list below for details.
dotnet add package Catglobe.CgScript.Common --version 1.0.0
NuGet\Install-Package Catglobe.CgScript.Common -Version 1.0.0
<PackageReference Include="Catglobe.CgScript.Common" Version="1.0.0" />
<PackageVersion Include="Catglobe.CgScript.Common" Version="1.0.0" />
<PackageReference Include="Catglobe.CgScript.Common" />
paket add Catglobe.CgScript.Common --version 1.0.0
#r "nuget: Catglobe.CgScript.Common, 1.0.0"
#:package Catglobe.CgScript.Common@1.0.0
#addin nuget:?package=Catglobe.CgScript.Common&version=1.0.0
#tool nuget:?package=Catglobe.CgScript.Common&version=1.0.0
Catglobe.ScriptDeployer
Easily handle development and deployment of sites that needs to run CgScripts on a catglobe site
This helper library makes it trivial to run and maintain 3 seperate branches of a site:
- Development
- Staging
- Production
Installation
npm install catglobe.cgscript.deployment
npm install catglobe.cgscript.runtime
Oidc client setup on server
Runtime
Runtime requires the user to log in to the Catglobe site, and then the server will call the CgScript with the user's credentials.
Adjust the following cgscript with the parentResourceId, clientId, clientSecret and name of the client and the requested scopes for your purpose and execute it on your Catglobe site.
number parentResourceId = 42;
string clientId = "13BAC6C1-8DEC-46E2-B378-90E0325F8132"; //use your own id -> store this in appsettings.json
bool canKeepSecret = true; //demo is a server app, so we can keep secrets
string clientSecret = "secret";
bool askUserForConsent = false;
string layout = "";
Array RedirectUri = {"https://localhost:7176/signin-oidc"};
Array PostLogoutRedirectUri = {"https://localhost:7176/signout-callback-oidc"};
Array scopes = {"email", "profile", "roles", "openid", "offline_access"};
Array optionalscopes = {};
LocalizedString name = new LocalizedString({"da-DK": "Min Demo App", "en-US": "My Demo App"}, "en-US");
OidcAuthenticationFlow_createOrUpdate(parentResourceId, clientId, clientSecret, askUserForConsent,
canKeepSecret, layout, RedirectUri, PostLogoutRedirectUri, scopes, optionalscopes, name);
Edit your appsettings.json file to include the following with the clientId, clientSecret and the requested scopes:
"CatglobeOidc": {
"Authority": "https://localhost:5001/",
"ClientId": "13BAC6C1-8DEC-46E2-B378-90E0325F8132",
"ClientSecret": "secret",
"PostLogoutRedirectUri": "https://localhost:7176/authentication/logout-callback",
"RedirectUri": "https://localhost:7176/authentication/login-callback",
"ResponseType": "code",
"DefaultScopes": [ "email", "offline_access", "roles" ],
"SaveTokens": true
},
"CatglobeApi": {
"FolderResourceId": 42,
"Site": "https://localhost:5001/"
},
asp.net setup
Runtime
In your start procedure, add the following:
const string SCHEMENAME = "CatglobeOidc"; //must match the section name in appsettings.json
// Add services to the container.
var services = builder.Services;
services.AddAuthentication(SCHEMENAME)
.AddOpenIdConnect(SCHEMENAME, oidcOptions => {
builder.Configuration.GetSection(SCHEMENAME).Bind(oidcOptions);
oidcOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme);
services.AddCgScript(builder.Configuration.GetSection("CatglobeApi"));
Optionally, setup refresh-token refreshing as part of the cookie handling:
services.AddSingleton<CookieOidcRefresher>();
services.AddOptions<CookieAuthenticationOptions>(CookieAuthenticationDefaults.AuthenticationScheme).Configure<CookieOidcRefresher>((cookieOptions, refresher) => {
cookieOptions.Events.OnValidatePrincipal = context => refresher.ValidateOrRefreshCookieAsync(context, SCHEMENAME);
});
You can find the CookieOidcRefresher here.
Usage of the library
Development
Development takes place on a developers personal device, which means that the developer can run the site locally and test it before deploying it to the staging server.
The authentication model is therefore that the developer logs into the using his own personal account. This account needs to have enough permission to set impersonation as configured on the scripts.
Staging and Deployment
number parentResourceId = 42;
string clientId = "DA431000-F318-4C55-9458-96A5D659866F"; //use your own id
string clientSecret = "verysecret";
number impersonationResourceId = User_getCurrentUser().ResourceId;
Array scopes = {"scriptdeployment:w"};
LocalizedString name = new LocalizedString({"da-DK": "Min Demo App", "en-US": "My Demo App"}, "en-US");
OidcServer2ServerClient_createOrUpdate(parentResourceId, clientId, clientSecret, impersonationResourceId, scopes, name);
How it works?
- get existing map
- get list of current scripts
- find new and pre-deploy (create resources and get id)
- find deleted and delete
- generate all scripts final form
- compare sha of each and find changed and update as needed
File name mapping to security
It is possible to specify which user a script runs under and if the script needs a user to be logged in.
See the documentation for ScriptFromFileOnDisk for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Catglobe.CgScript.Common:
Package | Downloads |
---|---|
Catglobe.CgScript.Deployment
Development and deployment support for sites that needs scripts to run on a Catglobe site. |
|
Catglobe.CgScript.Runtime
Development and deployment support for sites that needs scripts to run on a Catglobe site. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated | |
---|---|---|---|
1.8.2 | 88 | 7/30/2025 | |
1.8.1 | 84 | 7/30/2025 | |
1.8.0 | 132 | 7/11/2025 | |
1.7.0 | 149 | 6/2/2025 | |
1.6.0 | 166 | 3/19/2025 | |
1.5.0 | 151 | 3/19/2025 | |
1.4.4 | 118 | 2/25/2025 | |
1.4.3 | 107 | 2/25/2025 | |
1.4.2 | 102 | 2/25/2025 | |
1.4.1 | 121 | 2/14/2025 | |
1.4.0 | 158 | 12/12/2024 | |
1.3.0 | 120 | 12/10/2024 | |
1.2.1 | 127 | 11/29/2024 | |
1.2.0 | 129 | 11/28/2024 | |
1.1.0 | 144 | 11/27/2024 | |
1.0.1 | 118 | 11/27/2024 | |
1.0.0 | 131 | 11/27/2024 |