MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / TestGetJwtSession

Function TestGetJwtSession

oauthproxy_test.go:1853–1981  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1851}
1852
1853func TestGetJwtSession(t *testing.T) {
1854 /* token payload:
1855 {
1856 "sub": "1234567890",
1857 "aud": "https://test.myapp.com",
1858 "name": "John Doe",
1859 "email": "john@example.com",
1860 "iss": "https://issuer.example.com",
1861 "iat": 1553691215,
1862 "exp": 1912151821
1863 }
1864 */
1865 goodJwt := "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9." +
1866 "eyJzdWIiOiIxMjM0NTY3ODkwIiwiYXVkIjoiaHR0cHM6Ly90ZXN0Lm15YXBwLmNvbSIsIm5hbWUiOiJKb2huIERvZSIsImVtY" +
1867 "WlsIjoiam9obkBleGFtcGxlLmNvbSIsImlzcyI6Imh0dHBzOi8vaXNzdWVyLmV4YW1wbGUuY29tIiwiaWF0IjoxNTUzNjkxMj" +
1868 "E1LCJleHAiOjE5MTIxNTE4MjF9." +
1869 "rLVyzOnEldUq_pNkfa-WiV8TVJYWyZCaM2Am_uo8FGg11zD7l-qmz3x1seTvqpH6Y0Ty00fmv6dJnGnC8WMnPXQiodRTfhBSe" +
1870 "OKZMu0HkMD2sg52zlKkbfLTO6ic5VnbVgwjjrB8am_Ta6w7kyFUaB5C1BsIrrLMldkWEhynbb8"
1871
1872 keyset := NoOpKeySet{}
1873 verifier := oidc.NewVerifier("https://issuer.example.com", keyset,
1874 &oidc.Config{ClientID: "https://test.myapp.com", SkipExpiryCheck: true,
1875 SkipClientIDCheck: true})
1876 verificationOptions := internaloidc.IDTokenVerificationOptions{
1877 AudienceClaims: []string{"aud"},
1878 ClientID: "https://test.myapp.com",
1879 ExtraAudiences: []string{},
1880 }
1881 internalVerifier := internaloidc.NewVerifier(verifier, verificationOptions)
1882
1883 test, err := NewAuthOnlyEndpointTest("", func(opts *options.Options) {
1884 opts.InjectRequestHeaders = []options.Header{
1885 {
1886 Name: "Authorization",
1887 Values: []options.HeaderValue{
1888 {
1889 ClaimSource: &options.ClaimSource{
1890 Claim: "id_token",
1891 Prefix: "Bearer ",
1892 },
1893 },
1894 },
1895 },
1896 {
1897 Name: "X-Forwarded-User",
1898 Values: []options.HeaderValue{
1899 {
1900 ClaimSource: &options.ClaimSource{
1901 Claim: "user",
1902 },
1903 },
1904 },
1905 },
1906 {
1907 Name: "X-Forwarded-Email",
1908 Values: []options.HeaderValue{
1909 {
1910 ClaimSource: &options.ClaimSource{

Callers

nothing calls this directly

Calls 6

NewVerifierFunction · 0.92
NewAuthOnlyEndpointTestFunction · 0.85
SetJWTBearerVerifiersMethod · 0.80
GetJWTBearerVerifiersMethod · 0.80
GetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected