add service user and update readme

This commit is contained in:
Livio Amstutz 2022-04-06 14:06:23 +02:00
parent 30e40af24a
commit 6a8cf5be59
No known key found for this signature in database
GPG key ID: 26BB1C2FA5952CF0
3 changed files with 27 additions and 5 deletions

View file

@ -5,6 +5,7 @@ import (
"crypto/rand"
"crypto/rsa"
"fmt"
"math/big"
"time"
"github.com/google/uuid"
@ -15,6 +16,18 @@ import (
"github.com/caos/oidc/pkg/op"
)
var (
//serviceKey1 is a public key which will be used for the JWT Profile Authorization Grant
//the corresponding private key is in the service-key1.json (for demonstration purposes)
serviceKey1 = &rsa.PublicKey{
N: func() *big.Int {
n, _ := new(big.Int).SetString("00f6d44fb5f34ac2033a75e73cb65ff24e6181edc58845e75a560ac21378284977bb055b1a75b714874e2a2641806205681c09abec76efd52cf40984edcf4c8ca09717355d11ac338f280d3e4c905b00543bdb8ee5a417496cb50cb0e29afc5a0d0471fd5a2fa625bd5281f61e6b02067d4fe7a5349eeae6d6a4300bcd86eef331", 16)
return n
}(),
E: 65537,
}
)
//storage implements the op.Storage interface
//typically you would implement this as a layer on top of your database
//for simplicity this example keeps everything in-memory
@ -57,6 +70,13 @@ func NewStorage() *storage {
preferredLanguage: language.German,
},
},
services: map[string]Service{
"service": {
keys: map[string]*rsa.PublicKey{
"key1": serviceKey1,
},
},
},
signingKey: signingKey{
ID: "id",
Algorithm: "RS256",