MCPcopy
hub / github.com/vouch/vouch-proxy / GetUserInfo

Method GetUserInfo

pkg/providers/nextcloud/nextcloud.go:37–66  ·  view source on GitHub ↗

GetUserInfo provider specific call to get userinfomation

(r *http.Request, user *structs.User, customClaims *structs.CustomClaims, ptokens *structs.PTokens, opts ...oauth2.AuthCodeOption)

Source from the content-addressed store, hash-verified

35
36// GetUserInfo provider specific call to get userinfomation
37func (Provider) GetUserInfo(r *http.Request, user *structs.User, customClaims *structs.CustomClaims, ptokens *structs.PTokens, opts ...oauth2.AuthCodeOption) (rerr error) {
38 client, _, err := common.PrepareTokensAndClient(r, ptokens, true)
39 if err != nil {
40 return err
41 }
42 userinfo, err := client.Get(cfg.GenOAuth.UserInfoURL)
43 if err != nil {
44 return err
45 }
46 defer func() {
47 if err := userinfo.Body.Close(); err != nil {
48 rerr = err
49 }
50 }()
51 data, _ := io.ReadAll(userinfo.Body)
52 log.Infof("Ocs userinfo body: %s", string(data))
53 if err = common.MapClaims(data, customClaims); err != nil {
54 log.Error(err)
55 return err
56 }
57 ncUser := structs.NextcloudUser{}
58 if err = json.Unmarshal(data, &ncUser); err != nil {
59 log.Error(err)
60 return err
61 }
62 ncUser.PrepareUserData()
63 user.Username = ncUser.Username
64 user.Email = ncUser.Email
65 return nil
66}

Callers

nothing calls this directly

Calls 3

PrepareUserDataMethod · 0.95
PrepareTokensAndClientFunction · 0.92
MapClaimsFunction · 0.92

Tested by

no test coverage detected