asp.net mvc - Secure a single action with Forms Authentication & Basic Authentication simultaneously -
my mvc application secured using forms authentication
. have global filter applies authorizeattribute
.
i have controller called development
action called report
. can access fine authenticating in normal way , going http://localhost:8080/development/report. if not authenticated redirects me forms authentication login.
i trying embed page ios app user can view information without having manually authenticate themselves. confuse things ios app uses different authentication system, holds device id , unique token mvc app store.
what trying make report action available both via forms authentication , ios app using basic authentication username device id
, password token
. it's important when authenticated using method user can access report
action. what's best way implement whilst keeping secure?
i thinking of marking report
action allowanonymous
attribute , creating custom authentication action. best way?
authentication strategies that: strategies. they're not intended mixed , matched; pick 1 best suits application , go it.
that said, see 2 ways forward. either way, however, not allow use same action everything. best bet factor out shared code utility class or similar.
put 2 actions in separate projects. each project can implement own auth strategy. again, similar code can factored out utility class, , in case, shared via class library both projects may reference.
create separate action in same project , don't use
authorize
on or useallowanonymous
if it's part of controller authorized. turn off standard auth action , provide no protection. however, you're freed own "authorization" manually. can either check values of device id , token directly in action or create action filter so. choose depends on how need this. if one-off might want check directly in action quicker , easier. however, if one-off may still want use action filter you're prepare should use become more widespread.
Comments
Post a Comment