Skip to content

Unused code, undocumented code, invalid code in the samples #826

@VictorioBerra

Description

@VictorioBerra

Microsoft.Identity.Web version

3.13.0

Web app sign-in

1-WebApp-OIDC/1-1-MyOrg

Web API (call Graph or downstream APIs)

2-WebApp-graph-user/2-1-Call-MSGraph

Deploy to Azure

5-WebApp-AuthZ/5-2-Groups

Auth Z

6-Deploy-to-Azure

Description

I am trying to learn the concepts, and bringing the code into my solution with my editor config lit up like a Christmas tree. I am struggling to understand what I need, and what I do not need.

Weird docs: https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/5-WebApp-AuthZ/5-2-Groups/Services/GraphHelper.cs#L32

No return after this?? https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/5-WebApp-AuthZ/5-2-Groups/Services/GraphHelper.cs#L39

Unused code: https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/5-WebApp-AuthZ/5-2-Groups/Services/GraphHelper.cs#L96C29-L96C42

Redundant cast: https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/5-WebApp-AuthZ/5-2-Groups/Services/GraphHelper.cs#L64C21-L64C71

requiredGroupIds is unused: https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/5-WebApp-AuthZ/5-2-Groups/Services/GraphHelper.cs#L106C121-L106C137

Too many permissions: https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/5-WebApp-AuthZ/5-2-Groups/Infrastructure/Constants.cs#L7

I tested this code, it worked great without "GroupMember.Read.All" is this really needed?

Reproduction steps

See code

Error message

No response

Id Web logs

No response

Relevant code snippets

`/// <param name="requiredGroups">List</param>`


if (principal == null || principal.Identity == null)
{
    await Task.CompletedTask;
}

Regression

No response

Expected behavior

Code should be clean, simple, easy to understand and free of sloppy or missing docs, unused methods, and non-working code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions