some improvements
This commit is contained in:
parent
c9dfecc519
commit
804842e7c5
4 changed files with 47 additions and 23 deletions
|
|
@ -301,9 +301,16 @@ func (c *Context) Admin() bool {
|
|||
return c.Token.Claims.GetBool(adminClaim)
|
||||
}
|
||||
|
||||
func (c *Context) ApproveLogin(user, challenge string) (rdr string, err error) {
|
||||
func (c *Context) ApproveLogin(u *core.User, challenge string) (rdr string, err error) {
|
||||
accept := client.NewAcceptLoginRequest(u.Username)
|
||||
accept.Acr = new(string)
|
||||
if u.Secret == "" {
|
||||
*accept.Acr = "pwd"
|
||||
} else {
|
||||
*accept.Acr = "mfa"
|
||||
}
|
||||
cr, resp, err := c.Srv.API.AdminApi.AcceptLoginRequest(context.Background()).
|
||||
AcceptLoginRequest(*client.NewAcceptLoginRequest(user)).
|
||||
AcceptLoginRequest(*accept).
|
||||
LoginChallenge(challenge).
|
||||
Execute()
|
||||
if err != nil {
|
||||
|
|
@ -314,7 +321,7 @@ func (c *Context) ApproveLogin(user, challenge string) (rdr string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (c *Context) ApproveConsent(challenge string) (rdr string, err error) {
|
||||
func (c *Context) ApproveConsent(u *core.User, challenge string) (rdr string, err error) {
|
||||
ci, err := c.Consent(challenge)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -324,6 +331,15 @@ func (c *Context) ApproveConsent(challenge string) (rdr string, err error) {
|
|||
accept.GrantAccessTokenAudience = ci.RequestedAccessTokenAudience
|
||||
accept.Remember = new(bool)
|
||||
*accept.Remember = true
|
||||
accept.Session = &client.ConsentRequestSession{
|
||||
IdToken: u.Claims,
|
||||
}
|
||||
/*
|
||||
map[string]string{
|
||||
"apps": "git",
|
||||
"git_group": "admin",
|
||||
},
|
||||
*/
|
||||
cr, resp, err := c.Srv.API.AdminApi.AcceptConsentRequest(context.Background()).
|
||||
AcceptConsentRequest(*accept).
|
||||
ConsentChallenge(challenge).
|
||||
|
|
@ -399,14 +415,11 @@ func (c *Context) RevokeSession(user, client string, all bool) (err error) {
|
|||
if client == "" && !all {
|
||||
return
|
||||
}
|
||||
req := c.Srv.API.AdminApi.RevokeConsentSessions(context.Background()).
|
||||
Subject(user)
|
||||
if all {
|
||||
req = req.All(all)
|
||||
} else {
|
||||
req = req.Client(client)
|
||||
}
|
||||
resp, err := req.Execute()
|
||||
resp, err := c.Srv.API.AdminApi.RevokeConsentSessions(context.Background()).
|
||||
Subject(user).
|
||||
Client(client).
|
||||
All(all).
|
||||
Execute()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue