qor / auth

Golang Authentication solution
MIT License
734 stars 98 forks source link

access deny should not always redirect #4

Closed tnclong closed 7 years ago

tnclong commented 7 years ago

Hi @bodhi @jinzhu

Can you share your thought here?

https://github.com/qor/auth/blob/master/authority/authority.go#L33

https://github.com/qor/auth/blob/master/authority/authority.go#L81

After valid the roles, I want write proto(json) message to front-end instead of redirect to login page. I think the how to handle access deny is a configurable behavior.

// Config authority config
type Config struct {
    Auth                          AuthInterface
    Role                          *roles.Role
    // RedirectPathAfterAccessDenied string
        AccessDenyHandler func(w http.ResponseWriter, req *http.Request, auth AuthInterface)
}
tnclong commented 7 years ago

Thanks!

https://github.com/qor/auth/commit/47e5e51db6ccc9a89a9ac67942ed7d63f6229560