kataras / kataras/iris

Help: how to proxy http requests after BasicAuth ?

Open
#1,749 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Condition:
I want to use iris's http basic auth feature to add login function to my web service. The procedure I expect is as follow:
a. user visit my web service, like www.test.com
b. iris's basic auth do the password validation
c. after authentication, iris proxy all the http request to my web service, like http://127.0.0.1:3000

Question:
I've done with the basic auth function following your example, and the login function is ok, but how should I do to proxy the http requests to my local service? What codes shuold be to proxy instead of ctx.Writef? Please help me with this, thanks a lot!
```
func h(ctx iris.Context) {
username, password, _ := ctx.Request().BasicAuth()
ctx.Writef("%s %s:%s", ctx.Path(), username, password)
}
```

Contributor guide

Open the contributing guide

Research direction

The handler h currently ends with ctx.Writef after BasicAuth; start from this handler and the Iris BasicAuth example to identify the framework's request-proxy entry point. Done means authenticated requests for www.test.com are forwarded to http://127.0.0.1:3000 instead of being rendered as text.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.