Skip to content

Rangoric/utilities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Utilities

These utilities are primarily for Generic Character Sheet.

JWT

Wrap up functionality to deal with jwt tokens generated by Auth0. Designed to work with AWS Lambda Functions and Azure Functions.

How To Use

Configuration

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);
}

Usage in F

open Utilities.Jwt

let (isValid, actorProfile) = JwtSecurity.IsValid request//(request:HttpRequest)
let (isValid, actorProfile) = JwtSecurity.IsValidInGroups request groupList//(request:HttpRequest) (groupList:string list)

C# is gets a little ugly.

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

Testing

To Be Improved. Have to change it to expose testable pieces. Or expose itself in a testable way.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages