pub fn new(subject: Option<String>) -> String {
        // Get the global config.
        let config: Arc<ConcreteConfig> = global_config();
        // Get the JWT secret from the config.
        let jwt_secret: &[u8] = config.jwt_secret.as_bytes();

        // Create the JWT.
        let jwt = ApiJwtClaims {
            iss: JWT_ISSUER,
            sub: subject.clone(),
            iat: Utc::now().timestamp(),
            hasura_claims: HasuraJwtClaims {
                default_role: AUTHENTICATED_USER,
                allowed_roles: vec![AUTHENTICATED_USER],
                user_id: subject,
            },
        };

        // Encode and return the JWT
        return encode(
            &Header::default(),
            &jwt,
            &EncodingKey::from_secret(jwt_secret),
        )
        .expect("Could not encode JWT");
    }
/// Construct and sign a new JWT.
Construct and sign a new JWT.
Construct and sign a new JWT .
pub fn new(subject: Option<String>) -> String {
        // Get the global config.
        let config: Arc<ConcreteConfig> = global_config();
        // Get the JWT secret from the config.
        let jwt_secret: &[u8] = config.jwt_secret.as_bytes();
        // Create the JWT.
        let jwt = ApiJwtClaims {
            iss: JWT_ISSUER,
            sub: subject.clone(),
            iat: Utc::now().timestamp(),
            hasura_claims: HasuraJwtClaims {
                default_role: AUTHENTICATED_USER,
                allowed_roles: vec![AUTHENTICATED_USER],
                user_id: subject,
            },
        };
        // Encode and return the JWT
        return encode(
            &Header::default(),
            &jwt,
            &EncodingKey::from_secret(jwt_secret),
        )
        .expect("Could not encode JWT");
    }
pub fn new ( subject : Option < String > ) -> String { // Get the global config. let config : Arc < ConcreteConfig > = global_config ( ) ; // Get the JWT secret from the config. let jwt_secret : & [ u8 ] = config . jwt_secret . as_bytes ( ) ; // Create the JWT. let jwt = ApiJwtClaims { iss : JWT_ISSUER , sub : subject . clone ( ) , iat : Utc :: now ( ) . timestamp ( ) , hasura_claims : HasuraJwtClaims { default_role : AUTHENTICATED_USER , allowed_roles : vec ! [ AUTHENTICATED_USER ] , user_id : subject , } , } ; // Encode and return the JWT return encode ( & Header :: default ( ) , & jwt , & EncodingKey :: from_secret ( jwt_secret ) , ) . expect ( " " ) ; }
Construct and sign a new JWT.
Construct and sign a new JWT .
subject
Option<String>
subject
Option<String>