The Veza package provides data models, methods, and helpers for using the Open Authorization API. It provides helper methods to populate OAA templates for custom applications, filesystems, HRIS systems, and identity providers, and push the payloads to Veza. The SDK can also be used as a generic Veza API client.
The Veza SDK includes the following core components:
Veza.Sdk.Client: A base API client for making REST calls to a Veza tenant
Veza.OAA.Client: An OAA API client for interacting with integration providers, data sources, and pushing OAA metadata to a Veza tenant.
Create the Veza API connection and a new custom application:
usingVeza.OAA;usingVeza.OAA.Application;usingVeza.OAA.Base;// inside namespace/classOAAClient oaaClient =new(api_key:<your_api_key>, url:<veza_tenant_url>);CustomApplication customApp =new(name:"sample app", applicationType:"sample", description:"This is a sample application");
Once the CustomApplication class is instantiated, you can use its public methods to populate the new app with users, groups, resources, and permissions metadata:
// add custom permissionscustomApp.AddCustomPermission(name:"Admin", permissions:newList<Permission> {Permission.DataRead,Permission.DataWrite,Permission.MetadataRead,Permission.MetadataWrite,Permission.NonData }, applyToSubResources:true ); // define custom user propertiescustomApp.DefinedProperties[typeof(User)].DefineProperty("is_guest",typeof(bool)); // add userUser user =customApp.AddUser(name:"bob");user.AddIdentity("bob@example.com");user.IsActive=true;user.CreatedAt="2001-01-01T00:00:00.000Z".FromRFC3339();user.DeactivatedAt="2003-03-01T00:00:00.000Z".FromRFC3339();user.LastLoginAt="2002-02-01T00:00:00.000Z".FromRFC3339();user.PasswordLastChangedAt="2004-04-01T00:00:00.000Z".FromRFC3339();user.SetProperty(name:"is_guest", value:false); // define group propertiescustomApp.DefinedProperties[typeof(Group)].DefineProperty("group_id",typeof(int)); // add groupGroup group1 =customApp.AddGroup("group1");group1.CreatedAt="2001-01-01T00:00:00.000Z".FromRFC3339();group1.SetProperty(name:"group_id",1);customApp.Users["bob"].AddGroup("group1");Group group2 =customApp.AddGroup("group2");group2.AddGroup("group1"); // idp identitiescustomApp.AddIdPIdentity("user01@example.com"); // define role propertiescustomApp.DefinedProperties[typeof(Role)].DefineProperty("custom",typeof(bool)); // add roles Role role1 = customApp.AddRole(name: "role1", permissions: new List<string> { "all", "Admin", "Manage_Thing" });
role1.SetProperty(name:"custom", value:false); // define resource propertiescustomApp.DefineResourceProperty("private",typeof(bool),"thing"); // add resourcesResource thing1 =customApp.AddResource(name:"thing1", resourceType:"thing", description:"thing1");thing1.SetProperty(name:"private",false);thing1.AddTag(name:"tag1", value:"This is a value @,-_.");Resource cog1 =thing1.AddSubResource(name:"cog1", resourceType:"cog"); cog1.AddConnection(id: "service_account@some-project.iam.gserviceaccount.com", nodeType: "GoogleCloudServiceAccount");
// authorizationscustomApp.Users["bob"].AddRole(name:"role1", applyToApplication:true);customApp.Groups["group2"].AddRole(name:"role1", resources:newList<Resource> { thing1 });customApp.IdPIdentities["user01@example.com"].AddRole(name:"role1", applyToApplication:true);return customApp;
Once all identities, permissions, and resources are added to the CustomApplication object, use the client connection to push the data to Veza:
The Veza.OAA namespace provides exception types for common errors that occur when interacting with Veza APIs.
An OAAClientException is raised if there are errors interacting with the Veza API.
A TemplateException is raised if a provided payload does not conform to the template requirements. The inner exception will contain details about the exact issues encountered.
Additional Documentation
Each OAA connector will be slightly different, depending on the methods each source application or service provides for retrieving entities, authorization, and other required metadata. You should consult the API documentation for your application when considering how you will source the information, and refer to existing Veza-supported OAA connectors for real-world examples.
OAA connector source code and Veza components are thoroughly annotated for reference when building your own integrations.
For additional information about developing a custom OAA integration, please see Open Authorization API section of the User Guide.