osbuild-mock-openid-provider: use offline token as org id

This is quite a hack. Basically, the mock provider copies the offline token
into rh-org-id JWT claim. This allows us to test multi-tenancy.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-02-22 18:05:50 +01:00 committed by Ondřej Budai
parent c1dc58eba4
commit 33a310e4e1

View file

@ -82,13 +82,20 @@ func main() {
Type string `json:"typ"`
ExpiresAt int64 `json:"exp"`
IssuedAt int64 `json:"iat"`
RHOrgID string `json:"rh-org-id"`
jwt.Claims
}
if err := r.ParseForm(); err != nil {
panic(err)
}
cc := customClaims{
Type: "Bearer",
ExpiresAt: 0,
IssuedAt: time.Now().Unix(),
// Use refresh_token as rh-org-id
RHOrgID: r.Form.Get("refresh_token"),
}
token := jwt.NewWithClaims(jwt.SigningMethodRS256, cc)
token.Header["kid"] = "key-id"