mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-24 06:27:17 +02:00
config: allow blank identity providers when loading sessions for service account support (#3709)
This commit is contained in:
parent
1b596115e9
commit
6a9d6e45e1
2 changed files with 25 additions and 7 deletions
|
@ -69,6 +69,7 @@ func (store *SessionStore) LoadSessionState(r *http.Request) (*sessions.State, e
|
||||||
}
|
}
|
||||||
|
|
||||||
// confirm that the identity provider id matches the state
|
// confirm that the identity provider id matches the state
|
||||||
|
if state.IdentityProviderID != "" {
|
||||||
idp, err := store.options.GetIdentityProviderForRequestURL(urlutil.GetAbsoluteURL(r).String())
|
idp, err := store.options.GetIdentityProviderForRequestURL(urlutil.GetAbsoluteURL(r).String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -78,6 +79,7 @@ func (store *SessionStore) LoadSessionState(r *http.Request) (*sessions.State, e
|
||||||
return nil, fmt.Errorf("unexpected session state identity provider id: %s != %s",
|
return nil, fmt.Errorf("unexpected session state identity provider id: %s != %s",
|
||||||
idp.GetId(), state.IdentityProviderID)
|
idp.GetId(), state.IdentityProviderID)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &state, nil
|
return &state, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,4 +125,20 @@ func TestSessionStore_LoadSessionState(t *testing.T) {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Nil(t, s)
|
assert.Nil(t, s)
|
||||||
})
|
})
|
||||||
|
t.Run("blank idp", func(t *testing.T) {
|
||||||
|
rawJWS := makeJWS(t, &sessions.State{
|
||||||
|
Issuer: "authenticate.example.com",
|
||||||
|
ID: "example",
|
||||||
|
})
|
||||||
|
|
||||||
|
r, err := http.NewRequest(http.MethodGet, "https://p2.example.com", nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
r.Header.Set(httputil.HeaderPomeriumAuthorization, rawJWS)
|
||||||
|
s, err := store.LoadSessionState(r)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Empty(t, cmp.Diff(&sessions.State{
|
||||||
|
Issuer: "authenticate.example.com",
|
||||||
|
ID: "example",
|
||||||
|
}, s))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue