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

Add iris middleware #6

Open
eabili0 opened this issue May 10, 2019 · 2 comments
Open

Add iris middleware #6

eabili0 opened this issue May 10, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@eabili0
Copy link
Contributor

eabili0 commented May 10, 2019

No description provided.

@eabili0 eabili0 added the enhancement New feature or request label May 10, 2019
@eabili0 eabili0 self-assigned this May 10, 2019
@claudiosegala
Copy link
Contributor

@abilioesteves you want the same that is implemented in GetMuxSecurityMiddleware but with Iris?

// GetMuxSecurityMiddleware verifies if the client is authorized to make this request
func (client *WhisperClient) GetMuxSecurityMiddleware() mux.MiddlewareFunc {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var tokenString string
var token Token
var err error
if tokenString, err = misc.GetAccessTokenFromRequest(r); err == nil {
if token, err = client.IntrospectToken(tokenString); err == nil {
if token.Active {
newR := r.WithContext(context.WithValue(r.Context(), TokenKey, token))
next.ServeHTTP(w, newR)
return
}
}
}
gohtypes.PanicIfError("Unauthorized user", 401, err)
})
}
}

@eabili0
Copy link
Contributor Author

eabili0 commented Oct 28, 2019

Yes, very similiar implementation, but for Iris @claudiosegala .

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

No branches or pull requests

2 participants