Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce18015

Browse files
committed
Merge branch 'main' into githubteams
2 parents7d72da3 +bacfd63 commitce18015

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ test-postgres: test-clean test-postgres-docker
175175
DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." --\
176176
-covermode=atomic -coverprofile="gotests.coverage" -timeout=30m\
177177
-coverpkg=./...,github.com/coder/coder/codersdk\
178-
-count=2 -race -failfast
178+
-count=1 -race -failfast
179179
.PHONY: test-postgres
180180

181181
test-postgres-docker:

‎cli/server.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,22 @@ func configureTLS(listener net.Listener, tlsMinVersion, tlsClientAuth, tlsCertFi
722722
returntls.NewListener(listener,tlsConfig),nil
723723
}
724724

725-
funcconfigureGithubOAuth2(accessURL*url.URL,clientID,clientSecretstring,allowSignupsbool,allowOrgs []string,allowTeams []string) (*coderd.GithubOAuth2Config,error) {
725+
funcconfigureGithubOAuth2(accessURL*url.URL,clientID,clientSecretstring,allowSignupsbool,allowOrgs []string,rawTeams []string) (*coderd.GithubOAuth2Config,error) {
726726
redirectURL,err:=accessURL.Parse("/api/v2/users/oauth2/github/callback")
727727
iferr!=nil {
728728
returnnil,xerrors.Errorf("parse github oauth callback url: %w",err)
729729
}
730+
allowTeams:=make([]coderd.GithubOAuth2Team,0,len(rawTeams))
731+
for_,rawTeam:=rangerawTeams {
732+
parts:=strings.SplitN(rawTeam,"/",2)
733+
iflen(parts)!=2 {
734+
returnnil,xerrors.Errorf("github team allowlist is formatted incorrectly. got %s; wanted <organization>/<team>",rawTeam)
735+
}
736+
allowTeams=append(allowTeams, coderd.GithubOAuth2Team{
737+
Organization:parts[0],
738+
Slug:parts[1],
739+
})
740+
}
730741
return&coderd.GithubOAuth2Config{
731742
OAuth2Config:&oauth2.Config{
732743
ClientID:clientID,

‎coderd/database/db_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import (
1414

1515
funcTestNestedInTx(t*testing.T) {
1616
t.Parallel()
17+
iftesting.Short() {
18+
t.SkipNow()
19+
}
1720

1821
uid:=uuid.New()
1922
sqlDB:=testSQLDB(t)

‎coderd/userauth.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88
"net/http"
9-
"strings"
109

1110
"github.com/google/go-github/v43/github"
1211
"github.com/google/uuid"
@@ -18,6 +17,12 @@ import (
1817
"github.com/coder/coder/codersdk"
1918
)
2019

20+
// GithubOAuth2Team represents a team scoped to an organization.
21+
typeGithubOAuth2Teamstruct {
22+
Organizationstring
23+
Slugstring
24+
}
25+
2126
// GithubOAuth2Provider exposes required functions for the Github authentication flow.
2227
typeGithubOAuth2Configstruct {
2328
httpmw.OAuth2Config
@@ -28,7 +33,7 @@ type GithubOAuth2Config struct {
2833

2934
AllowSignupsbool
3035
AllowOrganizations []string
31-
AllowTeams []string
36+
AllowTeams []GithubOAuth2Team
3237
}
3338

3439
func (api*API)userAuthMethods(rw http.ResponseWriter,_*http.Request) {
@@ -80,21 +85,13 @@ func (api *API) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
8085

8186
varallowedTeam*github.Team
8287
for_,team:=rangeteams {
83-
for_,organizationAndTeam:=rangeapi.GithubOAuth2Config.AllowTeams {
84-
parts:=strings.SplitN(organizationAndTeam,"/",2)
85-
iflen(parts)!=2 {
86-
httpapi.Write(rw,http.StatusInternalServerError, httpapi.Response{
87-
Message:"Team allowlist isn't formatted correctly.",
88-
Detail:fmt.Sprintf("Got %s, wanted <organization>/<team>",organizationAndTeam),
89-
})
90-
return
91-
}
92-
ifparts[0]!=*selectedMembership.Organization.Login {
88+
for_,allowTeam:=rangeapi.GithubOAuth2Config.AllowTeams {
89+
ifallowTeam.Organization!=*selectedMembership.Organization.Login {
9390
// This needs to continue because multiple organizations
9491
// could exist in the allow/team listings.
9592
continue
9693
}
97-
ifparts[1]!=*team.Slug {
94+
ifallowTeam.Slug!=*team.Slug {
9895
continue
9996
}
10097
allowedTeam=team

‎coderd/userauth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestUserOAuth2Github(t *testing.T) {
7878
client:=coderdtest.New(t,&coderdtest.Options{
7979
GithubOAuth2Config:&coderd.GithubOAuth2Config{
8080
AllowOrganizations: []string{"coder"},
81-
AllowTeams: []string{"another/something","coder/frontend"},
81+
AllowTeams: []coderd.GithubOAuth2Team{{"another","something"}, {"coder","frontend"}},
8282
OAuth2Config:&oauth2Config{},
8383
ListOrganizationMemberships:func(ctx context.Context,client*http.Client) ([]*github.Membership,error) {
8484
return []*github.Membership{{
@@ -214,7 +214,7 @@ func TestUserOAuth2Github(t *testing.T) {
214214
GithubOAuth2Config:&coderd.GithubOAuth2Config{
215215
AllowSignups:true,
216216
AllowOrganizations: []string{"coder"},
217-
AllowTeams: []string{"coder/frontend"},
217+
AllowTeams: []coderd.GithubOAuth2Team{{"coder","frontend"}},
218218
OAuth2Config:&oauth2Config{},
219219
ListOrganizationMemberships:func(ctx context.Context,client*http.Client) ([]*github.Membership,error) {
220220
return []*github.Membership{{

‎coderd/workspaces_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
343343
// to run various filters against for testing.
344344
funcTestWorkspaceFilter(t*testing.T) {
345345
t.Parallel()
346+
// Manual tests still occur below, so this is safe to disable.
347+
t.Skip("This test is slow and flaky. See: https://github.com/coder/coder/issues/2854")
348+
// nolint:unused
346349
typecoderUserstruct {
347350
*codersdk.Client
348351
User codersdk.User

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp