Merge pull request #11216 from backstage/rugvip/oauth2-proxy

auth-backend: oauth2 proxy refactor + integration example + doc updates
This commit is contained in:
Patrik Oldsberg
2022-05-03 11:07:24 +02:00
committed by GitHub
8 changed files with 190 additions and 77 deletions
+25
View File
@@ -14,6 +14,10 @@
* limitations under the License.
*/
import {
DEFAULT_NAMESPACE,
stringifyEntityRef,
} from '@backstage/catalog-model';
import {
createRouter,
providers,
@@ -89,6 +93,27 @@ export default async function createPlugin(
},
},
}),
// This is an example of how to configure the OAuth2Proxy provider as well
// as how to sign a user in without a matching user entity in the catalog.
// You can try it out using `<ProxiedSignInPage {...props} provider="myproxy" />`
myproxy: providers.oauth2Proxy.create({
signIn: {
async resolver({ result }, ctx) {
const entityRef = stringifyEntityRef({
kind: 'user',
namespace: DEFAULT_NAMESPACE,
name: result.getHeader('x-forwarded-user')!,
});
return ctx.issueToken({
claims: {
sub: entityRef,
ent: [entityRef],
},
});
},
},
}),
},
});
}