Authorize / api security #737
Replies: 4 comments 1 reply
-
well as i do some testing i cant seem to get the restier controller to use the Authorize attribute and so that kills the use of this..... |
Beta Was this translation helpful? Give feedback.
-
This is an ASP.NET Core feature, not a Restier feature. You need to enable the ASP.NET Core pipeline to use Bearer tokens. In the latest build of Restier we made this a little easier: services .AddRestier(
options =>
{
options.EnableEndpointRouting = false;
options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
},
builder =>
{
// This delegate is executed after OData is added to the container.
// Add your Restier-specific services here.
builder.AddRestierApi<SomeApi>(routeServices =>
{
...
});
}); You need the EnableEndpointRouting set to false, since we don't support Endpoint Routing yet (it's under review). The RequireAuthenticatedUser extension is custom code we built for our app, but you can do something similar to get your filter working. Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
now i just have to deal with the swagger side of this..... i now get http 401 on the location but for swagger i had to use the metadata xml file to run thru a tool to make a json file for swagger.... now i need to update that .... have to work out some scripting to work that.... i wish i had a good idea on how to get this to work better with swagger...... |
Beta Was this translation helpful? Give feedback.
-
robert in case you have any ideas i want to give you some info on things i am trying to get working and if you have any good ideas please let me know. so i was able to get the restier odata to require authorization ! great ! but i found that nswag has no problem with the azure ad / authorize and token so i thought ok it will use nswag! BUT.... i have not found a way to get nswag to use a static json file as of yet! if i can get nswag to take a file i upload then i have a working swagger for restier ! a dot net package can convert the xml to json: as a command line it works like this:
this is klunky but i am now very close to a working swagger nswag is here: if i can just find out what to do to get it to read my json file in place of the runtime generator! another thought is to find a way to get the metadata direct from resiter to send to the library and then to nswag. i have been trying to find where in the nswag setup to just get it to take my file..... close but still no joy there. |
Beta Was this translation helpful? Give feedback.
-
i have a set of api items and i am trying to setup the requirements for callers to need to supply a token from azure ad.
seems like i have not been able to make that work and wonder if anyone have any examples for this?
Beta Was this translation helpful? Give feedback.
All reactions