// getAssignees returns a list of users who can be assigned to issues in this repository.
480148
func (repo *Repository) getAssignees(e Engine) (_ []*User, err error) {
	return repo.getUsersWithAccesMode(e, ACCESS_MODE_READ)
}
531249
func (a *AuthMiddleware) GetUser(r *http.Request) (interface{}, error) {
	peers := r.TLS.PeerCertificates
	if len(peers) > 1 {
		// when turning intermediaries on, don't forget to verify
		// https://github.com/kubernetes/kubernetes/pull/34524/files#diff-2b283dde198c92424df5355f39544aa4R59
		return nil, trace.AccessDenied("access denied: intermediaries are not supported")
	}
	localClusterName, err := a.AccessPoint.GetClusterName()
	if err != nil {
		return nil, trace.Wrap(err)
	}
	// with no client authentication in place, middleware
	// assumes not-privileged Nop role.
	// it theoretically possible to use bearer token auth even
	// for connections without auth, but this is not active use-case
	// therefore it is not allowed to reduce scope
	if len(peers) == 0 {
		return BuiltinRole{
			GetClusterConfig: a.AccessPoint.GetClusterConfig,
			Role:             teleport.RoleNop,
			Username:         string(teleport.RoleNop),
			ClusterName:      localClusterName.GetClusterName(),
		}, nil
	}
	clientCert := peers[0]
	certClusterName, err := tlsca.ClusterName(clientCert.Issuer)
	if err != nil {
		log.Warnf("Failed to parse client certificate %v.", err)
		return nil, trace.AccessDenied("access denied: invalid client certificate")
	}

	identity, err := tlsca.FromSubject(clientCert.Subject)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	// If there is any restriction on the certificate usage
	// reject the API server request. This is done so some classes
	// of certificates issued for kubernetes usage by proxy, can not be used
	// against auth server. Later on we can extend more
	// advanced cert usage, but for now this is the safest option.
	if len(identity.Usage) != 0 && !utils.StringSlicesEqual(a.AcceptedUsage, identity.Usage) {
		log.Warningf("Restricted certificate of user %q with usage %v rejected while accessing the auth endpoint with acceptable usage %v.",
			identity.Username, identity.Usage, a.AcceptedUsage)
		return nil, trace.AccessDenied("access denied: invalid client certificate")
	}

	// this block assumes interactive user from remote cluster
	// based on the remote certificate authority cluster name encoded in
	// x509 organization name. This is a safe check because:
	// 1. Trust and verification is established during TLS handshake
	// by creating a cert pool constructed of trusted certificate authorities
	// 2. Remote CAs are not allowed to have the same cluster name
	// as the local certificate authority
	if certClusterName != localClusterName.GetClusterName() {
		// make sure that this user does not have system role
		// the local auth server can not truste remote servers
		// to issue certificates with system roles (e.g. Admin),
		// to get unrestricted access to the local cluster
		systemRole := findSystemRole(identity.Groups)
		if systemRole != nil {
			return RemoteBuiltinRole{
				Role:        *systemRole,
				Username:    identity.Username,
				ClusterName: certClusterName,
			}, nil
		}
		return RemoteUser{
			ClusterName:      certClusterName,
			Username:         identity.Username,
			Principals:       identity.Principals,
			KubernetesGroups: identity.KubernetesGroups,
			RemoteRoles:      identity.Groups,
		}, nil
	}
	// code below expects user or service from local cluster, to distinguish between
	// interactive users and services (e.g. proxies), the code below
	// checks for presence of system roles issued in certificate identity
	systemRole := findSystemRole(identity.Groups)
	// in case if the system role is present, assume this is a service
	// agent, e.g. Proxy, connecting to the cluster
	if systemRole != nil {
		return BuiltinRole{
			GetClusterConfig: a.AccessPoint.GetClusterConfig,
			Role:             *systemRole,
			Username:         identity.Username,
			ClusterName:      localClusterName.GetClusterName(),
		}, nil
	}
	// otherwise assume that is a local role, no need to pass the roles
	// as it will be fetched from the local database
	return LocalUser{
		Username: identity.Username,
	}, nil
}
787046
func (ca *CertAuthorityV2) Signers() ([]ssh.Signer, error) {
	out := make([]ssh.Signer, 0, len(ca.Spec.SigningKeys))
	for _, keyBytes := range ca.Spec.SigningKeys {
		signer, err := ssh.ParsePrivateKey(keyBytes)
		if err != nil {
			return nil, trace.Wrap(err)
		}
		out = append(out, signer)
	}
	return out, nil
}
992591
func (v *version) CertificateSigningRequests() CertificateSigningRequestInformer {
	return &certificateSigningRequestInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
1111235
func (i *IssueRequest) GetAssignee() string {
	if i == nil || i.Assignee == nil {
		return ""
	}
	return *i.Assignee
}
1137200
func (p *provider) getUserTeams(token string) (sets.String, error) {
	userTeams := sets.NewString()
	err := p.page(p.githubUserTeamURL, token,
		func() interface{} {
			return &[]githubTeam{}
		},
		func(obj interface{}) error {
			for _, team := range *(obj.(*[]githubTeam)) {
				if len(team.Slug) > 0 && len(team.Organization.Login) > 0 {
					userTeams.Insert(strings.ToLower(team.Organization.Login + "/" + team.Slug))
				}
			}
			return nil
		},
	)
	return userTeams, err
}
1217107
func (m *Manager) GetAuthorizationsByUser(username string) (authorizations []Authorization, err error) {
	err = m.getAuthorizationCollection().Find(bson.M{"username": username}).All(&authorizations)
	if authorizations == nil {
		authorizations = []Authorization{}
	}
	return
}
913944
func (md *RootMetadataV2) GetUnresolvedParticipants() []keybase1.SocialAssertion {
	writers := md.WriterMetadataV2.Extra.UnresolvedWriters
	readers := md.UnresolvedReaders
	users := make([]keybase1.SocialAssertion, 0, len(writers)+len(readers))
	users = append(users, writers...)
	users = append(users, readers...)
	return users
}
1117389
func getSignedHeaders(signedHeaders http.Header) string {
	var headers []string
	for k := range signedHeaders {
		headers = append(headers, strings.ToLower(k))
	}
	sort.Strings(headers)
	return strings.Join(headers, ";")
}
992077
func (c *ApiController) GetAccountProjects() {

	//projects := GithubOauthRepositories{{FullName:"ArchCI/archci", HTMLURL:"https://github.com/ArchCI/archci", Language: "Go", Description: "The best CI system"}, {FullName:"ArchCI/simple-worker", Homepage:"https://github.com/ArchCI/simple-worker", Language:"Go", Description: "The client of ArchCI"}}

	/*
		r := c.Ctx.Request
		w := c.Ctx.ResponseWriter

		token := tkn

		sess, _ := globalSessions.SessionStart(w, r)
		defer sess.SessionRelease(w)

		if sess.Get("token") == nil {
			token = sess.Get("token").(*oauth2.Token)

			fmt.Println("hit token")

		}
	*/

	client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))

	projects, _, err := client.Repositories.List("", nil)
	if err != nil {
		fmt.Println("error getting repos")
		//return
	}

	/*
		[
		{
		"id": 36988569,
		"owner": {
		"login": "ArchCI",
		"id": 12673804,
		"avatar_url": "https://avatars.githubusercontent.com/u/12673804?v=3",
		"html_url": "https://github.com/ArchCI",
		"gravatar_id": "",
		"type": "Organization",
		"site_admin": false,
		"url": "https://api.github.com/users/ArchCI",
		"events_url": "https://api.github.com/users/ArchCI/events{/privacy}",
		"following_url": "https://api.github.com/users/ArchCI/following{/other_user}",
		"followers_url": "https://api.github.com/users/ArchCI/followers",
		"gists_url": "https://api.github.com/users/ArchCI/gists{/gist_id}",
		"organizations_url": "https://api.github.com/users/ArchCI/orgs",
		"received_events_url": "https://api.github.com/users/ArchCI/received_events",
		"repos_url": "https://api.github.com/users/ArchCI/repos",
		"starred_url": "https://api.github.com/users/ArchCI/starred{/owner}{/repo}",
		"subscriptions_url": "https://api.github.com/users/ArchCI/subscriptions"
		},
		"name": "aci",
		"full_name": "ArchCI/aci",
		"description": "Command-line client for ArchCI",
		"homepage": "http://archci.com",
		"default_branch": "master",
		"created_at": "2015-06-06T17:21:16Z",
		"pushed_at": "2015-06-14T01:00:11Z",
		"updated_at": "2015-06-28T13:58:55Z",
		"html_url": "https://github.com/ArchCI/aci",
		"clone_url": "https://github.com/ArchCI/aci.git",
		"git_url": "git://github.com/ArchCI/aci.git",
		"ssh_url": "git@github.com:ArchCI/aci.git",
		"svn_url": "https://github.com/ArchCI/aci",
		"language": "Go",
		"fork": false,
		"forks_count": 0,
		"open_issues_count": 0,
		"stargazers_count": 1,
		"watchers_count": 1,
		"size": 168,
		"permissions": {
		"admin": true,
		"pull": true,
		"push": true
		},
		"private": false,
		"has_issues": true,
		"has_wiki": true,
		"has_downloads": true,
		"team_id": null,
		"url": "https://api.github.com/repos/ArchCI/aci",
		"archive_url": "https://api.github.com/repos/ArchCI/aci/{archive_format}{/ref}",
		"assignees_url": "https://api.github.com/repos/ArchCI/aci/assignees{/user}",
		"blobs_url": "https://api.github.com/repos/ArchCI/aci/git/blobs{/sha}",
		"branches_url": "https://api.github.com/repos/ArchCI/aci/branches{/branch}",
		"collaborators_url": "https://api.github.com/repos/ArchCI/aci/collaborators{/collaborator}",
		"comments_url": "https://api.github.com/repos/ArchCI/aci/comments{/number}",
		"commits_url": "https://api.github.com/repos/ArchCI/aci/commits{/sha}",
		"compare_url": "https://api.github.com/repos/ArchCI/aci/compare/{base}...{head}",
		"contents_url": "https://api.github.com/repos/ArchCI/aci/contents/{+path}",
		"contributors_url": "https://api.github.com/repos/ArchCI/aci/contributors",
		"downloads_url": "https://api.github.com/repos/ArchCI/aci/downloads",
		"events_url": "https://api.github.com/repos/ArchCI/aci/events",
		"forks_url": "https://api.github.com/repos/ArchCI/aci/forks",
		"git_commits_url": "https://api.github.com/repos/ArchCI/aci/git/commits{/sha}",
		"git_refs_url": "https://api.github.com/repos/ArchCI/aci/git/refs{/sha}",
		"git_tags_url": "https://api.github.com/repos/ArchCI/aci/git/tags{/sha}",
		"hooks_url": "https://api.github.com/repos/ArchCI/aci/hooks",
		"issue_comment_url": "https://api.github.com/repos/ArchCI/aci/issues/comments{/number}",
		"issue_events_url": "https://api.github.com/repos/ArchCI/aci/issues/events{/number}",
		"issues_url": "https://api.github.com/repos/ArchCI/aci/issues{/number}",
		"keys_url": "https://api.github.com/repos/ArchCI/aci/keys{/key_id}",
		"labels_url": "https://api.github.com/repos/ArchCI/aci/labels{/name}",
		"languages_url": "https://api.github.com/repos/ArchCI/aci/languages",
		"merges_url": "https://api.github.com/repos/ArchCI/aci/merges",
		"milestones_url": "https://api.github.com/repos/ArchCI/aci/milestones{/number}",
		"notifications_url": "https://api.github.com/repos/ArchCI/aci/notifications{?since,all,participating}",
		"pulls_url": "https://api.github.com/repos/ArchCI/aci/pulls{/number}",
		"releases_url": "https://api.github.com/repos/ArchCI/aci/releases{/id}",
		"stargazers_url": "https://api.github.com/repos/ArchCI/aci/stargazers",
		"statuses_url": "https://api.github.com/repos/ArchCI/aci/statuses/{sha}",
		"subscribers_url": "https://api.github.com/repos/ArchCI/aci/subscribers",
		"subscription_url": "https://api.github.com/repos/ArchCI/aci/subscription",
		"tags_url": "https://api.github.com/repos/ArchCI/aci/tags",
		"trees_url": "https://api.github.com/repos/ArchCI/aci/git/trees{/sha}",
		"teams_url": "https://api.github.com/repos/ArchCI/aci/teams"
		}
		]
	*/

	c.Data["json"] = projects
	c.ServeJson()

}
262651
func (asl *AuthServerLdap) getGroups(username string) ([]string, error) {
	err := asl.Client.Bind(asl.User, asl.Password)
	if err != nil {
		return nil, err
	}
	req := ldap.NewSearchRequest(
		asl.GroupQuery,
		ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
		fmt.Sprintf("(memberUid=%s)", username),
		[]string{"cn"},
		nil,
	)
	res, err := asl.Client.Search(req)
	if err != nil {
		return nil, err
	}
	var groups []string
	for _, entry := range res.Entries {
		for _, attr := range entry.Attributes {
			groups = append(groups, attr.Values[0])
		}
	}
	return groups, nil
}
626877
func GetSignedInUserTeamList(c *m.ReqContext) Response {
	return getUserTeamList(c.OrgId, c.UserId)
}
564659
func GetIssueUserPairsByRepoIds(rids []int64, isClosed bool, page int) ([]*IssueUser, error) {
	if len(rids) == 0 {
		return []*IssueUser{}, nil
	}

	ius := make([]*IssueUser, 0, 10)
	sess := x.Limit(20, (page-1)*20).Where("is_closed=?", isClosed).In("repo_id", rids)
	err := sess.Find(&ius)
	return ius, err
}
442859
func UpdateIssueUserByAssignee(issue *Issue) (err error) {
	sess := x.NewSession()
	defer sess.Close()
	if err = sess.Begin(); err != nil {
		return err
	}

	if err = updateIssueUserByAssignee(sess, issue); err != nil {
		return err
	}

	return sess.Commit()
}
848397
func (c *Client) GetAccounts(accessToken string) (resp GetAccountsResponse, err error) {
	options := GetAccountsOptions{
		AccountIDs: []string{},
	}
	return c.GetAccountsWithOptions(accessToken, options)
}
404665
func (c *Client) GetUsers() ([]services.User, error) {
	out, err := c.Get(c.Endpoint("users"), url.Values{})
	if err != nil {
		return nil, trace.Wrap(err)
	}
	var items []json.RawMessage
	if err := json.Unmarshal(out.Bytes(), &items); err != nil {
		return nil, trace.Wrap(err)
	}
	users := make([]services.User, len(items))
	for i, userBytes := range items {
		user, err := services.GetUserMarshaler().UnmarshalUser(userBytes, services.SkipValidation())
		if err != nil {
			return nil, trace.Wrap(err)
		}
		users[i] = user
	}
	return users, nil
}
968190
func (c *Client) GetIncidents() (IncidentsResponse, error) {
	i := IncidentsResponse{}
	err := c.request("api/v2/incidents.json", &i)
	return i, err
}