These utilities are primarily for Generic Character Sheet.
Wrap up functionality to deal with jwt tokens generated by Auth0. Designed to work with AWS Lambda Functions and Azure Functions.
Environment Variables to set:
Authorization-Configuration-Url
:https://[Domain in Auth0]/.well-known/openid-configuration
Authorization-ClientID
:[Your ClientID]
Authorization-Issuer
:https://[Domain in Auth0]/
Authorization-Metadata
:https://[Your application website]/app_metadata
[Domain in Auth0]
can be gotten by going to Applications -> Settings, it will be a readonly setting near the top.
[Your application website]
This requires a rule set up to copy data to the token using the namespace you decide on.
The rule I am currently using looks like:
function(user, context, callback) {
const namespace = 'https://www.rangoric.com/';
context.idToken[namespace + 'user_metadata'] = user.user_metadata || {};
context.idToken[namespace + 'app_metadata'] = user.app_metadata || {};
context.idToken[namespace + 'name'] = user.name || 'No Name';
callback(null, user, context);
}
open Utilities.Jwt
let (isValid, actorProfile) = JwtSecurity.IsValid request//(request:HttpRequest)
let (isValid, actorProfile) = JwtSecurity.IsValidInGroups request groupList//(request:HttpRequest) (groupList:string list)
F# tuples use the old tuple style to interact with C#.
using Utilities.Jwt;
var tuple = JwtSecurity.IsValid(request);
var tuple = JwtSecurity.IsValidInGroups(request, groupList);
tuple.item1//isValid
tuple.item2//actorProfile
To Be Improved. Have to change it to expose testable pieces. Or expose itself in a testable way.