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

OpenIDConnect v1 implementation #828

Merged
merged 1 commit into from
Oct 18, 2022
Merged

Conversation

jthann
Copy link
Collaborator

@jthann jthann commented Oct 13, 2022

OpenIDConnect integration implementation #827

@codecov-commenter
Copy link

Codecov Report

Base: 79.25% // Head: 77.22% // Decreases project coverage by -2.02% ⚠️

Coverage data is based on head (5d76f55) compared to base (b67c5ff).
Patch coverage: 0.71% of modified lines in pull request are covered.

❗ Current head 5d76f55 differs from pull request most recent head d82ecf4. Consider uploading reports for the commit d82ecf4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #828      +/-   ##
==========================================
- Coverage   79.25%   77.22%   -2.03%     
==========================================
  Files         101      102       +1     
  Lines       11188    11466     +278     
==========================================
- Hits         8867     8855      -12     
- Misses       1826     2112     +286     
- Partials      495      499       +4     
Impacted Files Coverage Δ
pkg/cluster/cluster_interface.go 76.92% <ø> (ø)
pkg/cluster/op.go 64.63% <0.00%> (-7.56%) ⬇️
pkg/protocols/httpprot/response.go 83.95% <ø> (ø)
pkg/v/v.go 51.92% <ø> (ø)
pkg/filters/oidcadaptor/oidcadaptor.go 0.75% <0.75%> (ø)
pkg/cluster/syncer.go 77.56% <0.00%> (-5.77%) ⬇️
pkg/object/mqttproxy/broker.go 74.79% <0.00%> (-1.01%) ⬇️
pkg/filters/proxy/pool.go 80.05% <0.00%> (+0.87%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@localvar localvar requested review from localvar and suchen-sci and removed request for localvar October 13, 2022 08:37
pkg/registry/registry.go Outdated Show resolved Hide resolved
pkg/filters/oidcadaptor/oidcadaptor.go Outdated Show resolved Hide resolved
pkg/filters/oidcadaptor/oidcadaptor.go Outdated Show resolved Hide resolved
pkg/filters/oidcadaptor/oidcadaptor.go Outdated Show resolved Hide resolved
pkg/filters/oidcadaptor/oidcadaptor.go Outdated Show resolved Hide resolved
pkg/filters/oidcadaptor/oidcadaptor.go Outdated Show resolved Hide resolved
pkg/filters/oidcadaptor/oidcadaptor.go Outdated Show resolved Hide resolved
pkg/filters/oidcadaptor/oidcadaptor.go Outdated Show resolved Hide resolved
doc/reference/filters.md Outdated Show resolved Hide resolved
pkg/filters/oidcadaptor/oidcadaptor.go Outdated Show resolved Hide resolved
Comment on lines 1001 to 1004
OIDC End-User basic profile map json encoded by standard base64 which header name is `X-Userinfo`
End-User origin request url before OpenID Connect or OAuth2.0 flow which header name is `X-Origin-ReqURL`
The ID Token returned by OpenID Connect flow which header name is `X-Id-Token`
The AccessToken returned by OpenId Connect or OAuth2.0 flow which header name is `X-Access-Token`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OIDC End-User basic profile map json encoded by standard base64 which header name is `X-Userinfo`
End-User origin request url before OpenID Connect or OAuth2.0 flow which header name is `X-Origin-ReqURL`
The ID Token returned by OpenID Connect flow which header name is `X-Id-Token`
The AccessToken returned by OpenId Connect or OAuth2.0 flow which header name is `X-Access-Token`
* **X-Userinfo**: Base64 encoded OIDC End-User basic profile.
* **X-Origin-ReqURL**: End-User origin request URL before OpenID Connect or OAuth2.0 flow.
* **X-Id-Token**: The ID Token returned by OpenID Connect flow.
* **X-Access-Token**: The AccessToken returned by OpenId Connect or OAuth2.0 flow.

and propose X-Userinfo to be X-User-Info, X-Origin-ReqURL to be X-Origin-Request-Url.

Comment on lines 24 to 31
"github.com/google/uuid"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"

"github.com/MicahParks/keyfunc"
"github.com/golang-jwt/jwt/v4"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"github.com/google/uuid"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
"github.com/MicahParks/keyfunc"
"github.com/golang-jwt/jwt/v4"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
"github.com/google/uuid"
"github.com/golang-jwt/jwt/v4"
"github.com/MicahParks/keyfunc"

spec *Spec
store

//Following are user custom defined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Following are user custom defined
// Following are user custom defined


Discovery string `json:"discovery"`

//If Discovery not configured, following should be configured for OAuth2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//If Discovery not configured, following should be configured for OAuth2
// If Discovery is not configured, the following should be configured for OAuth2

}

func (o *OIDCAdaptor) Init() {
//for testable delegate store interface operation to itself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//for testable delegate store interface operation to itself
// delegate store interface operation to itself for testing

if err != nil {
logger.Errorf("put origin req url error: %s", err)
}
//nonce is optional
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//nonce is optional
// nonce is optional

Comment on lines 181 to 184
for _, c := range req.Cookies() {
if spec.CookieName == c.Name {
return ""
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cookie name is not case-sensitive, propose to call req.Cookie

logger.Errorf("close error: %s", err)
}
}(resp.Body)
respBody, err := ioutil.ReadAll(resp.Body)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ioutil.ReadAll is Deprecated.

Suggested change
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)

Comment on lines 240 to 241
authCode := req.Request.URL.Query().Get("code")
state := req.Request.URL.Query().Get("state")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
authCode := req.Request.URL.Query().Get("code")
state := req.Request.URL.Query().Get("state")
authCode := req.Std().URL.Query().Get("code")
state := req.Std().URL.Query().Get("state")

Comment on lines 267 to 268
mapClaims, _ := parseToken.Claims.(jwt.MapClaims)
for k, v := range mapClaims {
userInfo[k] = v
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mapClaims, _ := parseToken.Claims.(jwt.MapClaims)
for k, v := range mapClaims {
userInfo[k] = v
}
if claims, ok := parseToken.Claims.(jwt.MapClaims); ok {
userInfo = claims
}

@suchen-sci suchen-sci merged commit 7a75cc8 into easegress-io:main Oct 18, 2022
@jthann jthann deleted the feat/oidc branch October 18, 2022 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants