feat: add OIDC feature support. (#373)

1. add nonce parameter.
2. add sub in userinfo endpoint.

Signed-off-by: 0x2a <stevesough@gmail.com>
This commit is contained in:
Steve0x2a
2021-12-15 21:42:16 +08:00
committed by GitHub
parent 370e835499
commit 98f6cc0085
7 changed files with 22 additions and 10 deletions

View File

@ -61,6 +61,7 @@ type RequestForm struct {
type Response struct {
Status string `json:"status"`
Msg string `json:"msg"`
Sub string `json:"sub"`
Data interface{} `json:"data"`
Data2 interface{} `json:"data2"`
}
@ -217,8 +218,14 @@ func (c *ApiController) GetAccount() {
}
organization := object.GetMaskedOrganization(object.GetOrganizationByUser(user))
c.ResponseOk(user, organization)
resp := Response{
Status: "ok",
Sub: userId,
Data: user,
Data2: organization,
}
c.Data["json"] = resp
c.ServeJSON()
}
// GetHumanCheck ...

View File

@ -51,8 +51,8 @@ func (c *ApiController) HandleLoggedIn(application *object.Application, user *ob
redirectUri := c.Input().Get("redirectUri")
scope := c.Input().Get("scope")
state := c.Input().Get("state")
code := object.GetOAuthCode(userId, clientId, responseType, redirectUri, scope, state)
nonce := c.Input().Get("nonce")
code := object.GetOAuthCode(userId, clientId, responseType, redirectUri, scope, state, nonce)
resp = codeToResponse(code)
if application.HasPromptPage() {

View File

@ -136,8 +136,9 @@ func (c *ApiController) GetOAuthCode() {
redirectUri := c.Input().Get("redirect_uri")
scope := c.Input().Get("scope")
state := c.Input().Get("state")
nonce := c.Input().Get("nonce")
c.Data["json"] = object.GetOAuthCode(userId, clientId, responseType, redirectUri, scope, state)
c.Data["json"] = object.GetOAuthCode(userId, clientId, responseType, redirectUri, scope, state, nonce)
c.ServeJSON()
}