Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with Microsoft.AspNetCore.OData, Version=8.0.0.0...? #5

Open
eric-miller-cdfw opened this issue Jan 7, 2021 · 4 comments

Comments

@eric-miller-cdfw
Copy link

It looks like the "core" version of the lib is referencing some .NET Framework API's... Also, the docs don't seem correct for how to configure startup.

Docs show ConfigServices like:

services.AddOData()
        .AddAuthorization(options =>
        {
            options.ScopesFinder = context =>
            {
                var userScopes = context.User.FindAll("Scope").Select(claim => claim.Value);
                return Task.FromResult(userScopes);
            };
            options.ConfigureAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
                .AddCookie();
        });

But the AddAuthorization() extension method seems to be for .NET Framework. So, I tried ...

services.AddODataAuthorization(options =>
            {
                options.ScopesFinder = context =>
                {
                    var userScopes = context.User.FindAll("Scope").Select(claim => claim.Value);
                    return System.Threading.Tasks.Task.FromResult(userScopes);
                };
            });

And, for authentication, I want to use Azure AD (Bearer tokens)

            services.AddMicrosoftIdentityWebApiAuthentication(Configuration);

And, in the Configure method:

            app.UseAuthentication();
            app.UseODataAuthorization();

But, I get the following exception at startup...

System.TypeLoadException: Could not load type 'Microsoft.AspNet.OData.Interfaces.IODataFeature' from assembly 'Microsoft.AspNetCore.OData, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
   at Microsoft.AspNetCore.OData.Authorization.ODataAuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
@Firas88Alkhatib
Copy link

WebApi Authorization currently only supports OData WebApi 7.x, AspNet.Core 3.1 with endpoint routing.

refer to :
https://docs.microsoft.com/en-us/odata/webapiauth/overview

@ekomut
Copy link

ekomut commented May 30, 2021

Could I ask, do you have any idea, when will development possible?
I do not find any information on microsoft website

@bytefish
Copy link

bytefish commented Nov 29, 2022

@eric-miller-cdfw @Firas88Alkhatib I think this is obviously a duplicate to #9. The referenced PR #13 is an effort to update the library to ASP.NET Core OData 8. If there is still interest, one could try to improve the PR as a community effort and maybe get it accepted.

@willsmithgithub
Copy link

Could really use this feature. Seem ODATA is being outpaced by this - https://learn.microsoft.com/en-us/azure/data-api-builder/overview-to-data-api-builder?tabs=azure-sql which is a shame as ODATA is much more mature. The data api supports authorization and more granular (property level). something this project could add as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants