Documentation ¶
Index ¶
- func AddClientSecret(ctx context.Context, objID string) (autorest.Response, error)
- func CreateADApplication(ctx context.Context) (graphrbac.Application, error)
- func CreateServicePrincipal(ctx context.Context, appID string) (graphrbac.ServicePrincipal, error)
- func DeleteADApplication(ctx context.Context, appObjID string) (autorest.Response, error)
- func GetCurrentUser(ctx context.Context) (graphrbac.AADObject, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClientSecret ¶
AddClientSecret adds a client secret (aka password credential) to the specified AAD app
func CreateADApplication ¶
func CreateADApplication(ctx context.Context) (graphrbac.Application, error)
CreateADApplication creates an Azure Active Directory (AAD) application
func CreateServicePrincipal ¶
CreateServicePrincipal creates a service principal on the specified Azure Active Directory application.
Example ¶
ctx := context.Background() app, err := CreateADApplication(ctx) if err != nil { helpers.PrintAndLog(err.Error()) } helpers.PrintAndLog("ad app created") sp, err := CreateServicePrincipal(ctx, *app.AppID) if err != nil { helpers.PrintAndLog(err.Error()) } helpers.PrintAndLog("service principal created") _, err = AddClientSecret(ctx, *app.ObjectID) if err != nil { helpers.PrintAndLog(err.Error()) } helpers.PrintAndLog("added client secret") helpers.SetResourceGroupName("CreateServicePrincipal") _, err = resources.CreateGroup(ctx, helpers.ResourceGroupName()) if err != nil { helpers.PrintAndLog(err.Error()) } helpers.PrintAndLog("created resource group") list, err := authorization.ListRoles(ctx, "roleName eq 'Contributor'") if err != nil { helpers.PrintAndLog(err.Error()) } helpers.PrintAndLog("list contributor role definition, with resource group scope") _, err = authorization.AssignRole(ctx, *sp.ObjectID, *list.Values()[0].ID) if err != nil { helpers.PrintAndLog(err.Error()) } helpers.PrintAndLog("create role definition") if !helpers.KeepResources() { _, err = resources.DeleteGroup(ctx, helpers.ResourceGroupName()) if err != nil { helpers.PrintAndLog(err.Error()) } _, err = DeleteADApplication(ctx, *app.ObjectID) if err != nil { helpers.PrintAndLog(err.Error()) } }
Output: ad app created service principal created added client secret created resource group list contributor role definition, with resource group scope create role definition
func DeleteADApplication ¶
DeleteADApplication deletes the specified AAD application
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.