简体   繁体   中英

How to Add authentication for self hosted web API?

I have a self hosted Web API in console project. I need to authroize the user on role based or domain based.

How can i achieve it.

Sample Code :

-- Here how can i implement the Authentication and authorization --

public class Sample : ODataController
 {
[EnableQuery]
public IHttpActionResult Get(ODataQueryOptions<APINAME> opts)
                        {

                         }
}

You should use the both. In AD you set user groups and you assign specific permission to groups.

You need to keep in mind that users come and go but groups can stay definitely

I've worked on this kind of project 8 years ago.

  • The frontend was writing everything in a database (MS-SQL)
  • A windows service was querying a Status table which was reporting db activities
  • That windows service was applying the ACL according to the Status refs

We were in Windows Server environment, I was using CMD (MS DOS ICACLS )

In .Net or from Powershell or from MS DOS you can apply ACLs

Some resources

CACLS before ICACLS which seems more complex

An illustrations in Windows where you can see the changes you made

This other answer may help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM