Skip to content

Commit

Permalink
auth_jwt_test: add single page app demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Jul 25, 2021
1 parent b9097a3 commit f648331
Show file tree
Hide file tree
Showing 9 changed files with 24,673 additions and 56 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# eslint complains on ES modules
auth_jwt_test/tests/spa/js/*.js
20 changes: 20 additions & 0 deletions auth_jwt_test/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,23 @@ def whoami(self):
partner = request.env["res.partner"].browse(request.jwt_partner_id)
data.update(name=partner.name, email=partner.email)
return Response(json.dumps(data), content_type="application/json", status=200)

@route(
"/auth_jwt_test/keycloak/whoami",
type="http",
auth="jwt_demo_keycloak",
csrf=False,
cors="*",
save_session=False,
)
def whoami_keycloak(self):
"""To use with the demo_keycloak validator.
You can play with this using the browser app in tests/spa and the
identity provider in tests/keycloak.
"""
data = {}
if request.jwt_partner_id:
partner = request.env["res.partner"].browse(request.jwt_partner_id)
data.update(name=partner.name, email=partner.email)
return Response(json.dumps(data), content_type="application/json", status=200)
14 changes: 14 additions & 0 deletions auth_jwt_test/demo/auth_jwt_validator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@
<field name="partner_id_strategy">email</field>
<field name="partner_id_required" eval="False" />
</record>
<record id="demo_keycloak_validator" model="auth.jwt.validator">
<field name="name">demo_keycloak</field>
<field name="audience">auth_jwt_test_api</field>
<field name="issuer">http://localhost:8080/auth/realms/master</field>
<field name="signature_type">public_key</field>
<field name="public_key_algorithm">RS256</field>
<field
name="public_key_jwk_uri"
>http://localhost:8080/auth/realms/master/protocol/openid-connect/certs</field>
<field name="user_id_strategy">static</field>
<field name="static_user_id">1</field>
<field name="partner_id_strategy">email</field>
<field name="partner_id_required" eval="False" />
</record>
</odoo>
Loading

0 comments on commit f648331

Please sign in to comment.