-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script and process to generate OIDC config from federation directory. (…
…#139) Signed-off-by: Dan Lorenc <dlorenc@google.com>
- Loading branch information
dlorenc
authored
Jul 27, 2021
1 parent
e36f98f
commit c86b377
Showing
8 changed files
with
221 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# OIDC Federation Configs | ||
|
||
This directory contains configurations for individual OIDC endpoints that the public good instance of Fulcio should accept identity tokens from. | ||
|
||
## Usage | ||
|
||
To update the k8s `ConfigMap`, run `go run federation/main.go` from the root directory of this repository. | ||
|
||
## Adding New Entries | ||
|
||
We'll happily accept new entries here in the form of a pull request! | ||
Open one up with your endpoint, filling in a directory and a `config.yaml` with the following structure: | ||
|
||
```yaml | ||
url: <discovery url> | ||
contact: <your contact email> | ||
description: <a description of the use case> | ||
type: <spiffe|email> | ||
``` | ||
You'll then have to regenerate the ConfigMap with `go run federation/main.go`, and then send your PR. | ||
|
||
We'll discuss your use-case with you over the pull request, and merge! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2021 The Sigstore Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
url: https://accounts.google.com | ||
contact: lorenc.d@gmail.com | ||
description: "standard google OIDC auth" | ||
type: "email" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2021 The Sigstore Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
url: https://oidc.dlorenc.dev | ||
contact: lorenc.d@gmail.com | ||
description: "test address for federation!" | ||
type: "spiffe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright 2021 The Sigstore Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"path/filepath" | ||
|
||
"github.com/sigstore/fulcio/pkg/config" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
var rootPaths = []string{"federation", "federation/external"} | ||
var boilerPlate = `# | ||
# Copyright 2021 The Sigstore Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
` | ||
|
||
type federationConfig struct { | ||
URL string | ||
Type string | ||
} | ||
|
||
func main() { | ||
matches := []string{} | ||
for _, rp := range rootPaths { | ||
glob := filepath.Join(rp, "*/config.yaml") | ||
globs, err := filepath.Glob(glob) | ||
if err != nil { | ||
panic(err) | ||
} | ||
matches = append(matches, globs...) | ||
} | ||
fulcioConfig := config.FulcioConfig{ | ||
OIDCIssuers: map[string]config.OIDCIssuer{}, | ||
} | ||
for _, m := range matches { | ||
b, err := ioutil.ReadFile(m) | ||
if err != nil { | ||
panic(err) | ||
} | ||
cfg := federationConfig{} | ||
if err := yaml.Unmarshal(b, &cfg); err != nil { | ||
panic(err) | ||
} | ||
|
||
fulcioCfg := config.OIDCIssuer{ | ||
IssuerURL: cfg.URL, | ||
ClientID: "sigstore", | ||
Type: config.IssuerType(cfg.Type), | ||
} | ||
fulcioConfig.OIDCIssuers[cfg.URL] = fulcioCfg | ||
} | ||
|
||
m, err := json.MarshalIndent(fulcioConfig, "", " ") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Update the yaml | ||
yb, err := ioutil.ReadFile("config/fulcio-config.yaml") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
cm := map[string]interface{}{} | ||
if err := yaml.Unmarshal(yb, &cm); err != nil { | ||
panic(err) | ||
} | ||
data := cm["data"].(map[string]interface{}) | ||
data["config.json"] = string(m) | ||
|
||
newYaml, err := yaml.Marshal(cm) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
yamlWithBoilerplate := boilerPlate + string(newYaml) | ||
|
||
if err := ioutil.WriteFile("config/fulcio-config.yaml", []byte(yamlWithBoilerplate), 0600); err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2021 The Sigstore Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
url: https://oauth2.sigstore.dev/auth | ||
contact: lorenc.d@gmail.com | ||
description: "dex address for fulcio" | ||
type: "email" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters