Jump to content

Question regarding MUUT's Federated ID integration - possible?


SyberKnight
 Share

Recommended Posts

hello,
 
can somebody tell me if this is possible simply?
 
OBJECTIVE >

  • to embed the MUUT Forum into our website via their Federated ID method.
  • i can embed their forum into our website just fine, and it works out-of-the-box, BUT we need to host our own user database (not using MUUT's).

BACKGROUND INFO >

  • i'm a ProcessWire noob, but am excited to dive in (experienced in other CMS's).
  • i do front-end design mostly.
  • i do very little back-end development, but i do have experience installing & doing minor customizations.
  • i'm expert in HTML/CSS & intermediate in Javascript/Jquery
  • i usually work with PHP/MySQL code given to me or found online; can't write from scratch.

ISSUE/PROBLEM >

  • in order to use muut's forum and our own user db, they require that we have our own user registration/authentication system that uses "Federated ID". not ever having used PW before, i don't know if this would be compatible with that.
  • i just got thru a week-long experiment with a system i found called UserFrosting; but it's WAY too complex for me & what i need. so my next thought was to utilize a CMS's user system to be the user reg/auth bit for Muut. can ProcessWire be that system & integrate with MUUT?

REFERENCES >

CODE >

  • at the bottom of this post is the index.php code that i pieced together from the muut docs, guides, & support forum to use as a base (pre any customizations).
  • before that code, i have directly under these points are 2 code boxes containing 2 examples of the only section from index.php that i believe needs changing to work with ProcessWire.
  • after that is a 3rd code box with my attempt at connecting ProcessWire with MUUT - but i'm unsure if it's correct or not.

in the whole page code at bottom of this post, right under the <body>, in that PHP section's user array (a.k.a. Step 1), i found this code in the muut docs...

"id" => "johndoe",
"displayname" => "John Doe", 
"email" => "john@doe.com", 
"avatar" => "//gravatar.com/something", 

you'll note the commented out part with this in the index.php code; it's what i found elsewhere in a muut support thread...

"id" => $userObj->userID,
"displayname" => $userObj->fname . ' ' . $userObj->lname,
"email" => $userObj->email,
"avatar" => $userObj->photo,

so based on those 2 examples above, would it be correct/incorrect to use PW's user properties like this(?)...

"id" => $user->id,
"displayname" => $user->name,
"email" => $user->email,
"avatar" => $user->ICouldntFindWhatWouldGoHere,

...SUBQUESTION > i couldn't find what ProcessWire uses for a User-Avatar/Picture. anybody know?

 FYI > HERE is the whole code for this un-customized index.php file THAT WORKS withOUT our own user system...

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<title>Untitled Document</title>

<link rel="stylesheet" href="https://cdn.muut.com/1/moot.css" />
<style>
   .m-custom .nested {
      margin-left: 1em; }
   /* .is-commenting, .is-threaded {
      max-width: 700px; } */
</style>

<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>

</head>
<body>

<?php
// Step 1 
// Generate the message before the page loads
// give us the user data
     $user = array(
          'user' => array(
               "id" => "johndoe",              // "id" => $userObj->userID,
               "displayname" => "John Doe",    // "displayname" => $userObj->fname . ' ' . $userObj->lname,
               "email" => "john@doe.com",      // "email" => $userObj->email,
               "avatar" => "//gravatar.com/?", // "avatar" => $userObj->photo,
               "is_admin" => false,
          ),
     );

// Step 2
// encode the user array to generate the 'message'.
     $message = base64_encode(json_encode($user));

// assign the current timestamp to be used. 
     $timestamp = time();

// Step 3
// Generate the signature = my long secret key from account settings page
     $signature = sha1('####################' . ' ' . $message . ' ' . $timestamp);
?>

<div class="muut">
   <a class="muut-url" href="https://muut.com/i/sanctuary">Sanctuary Community</a>
        
<!-- custom sidebar -->
   <div class="m-h3">Your Forum Title Again</div>
        
   <a href="#!/chan1">Channel 1</a>
        
   <div class="nested">
      <a href="#!/chan1/subchan1">Subchannel 1</a>
      <a href="#!/chan1/subchan2">Subchannel 2</a>
   </div>
        
   <a href="#!/chan2">Channel 2</a>
        
</div><!-- end class="muut" -->

<!--div class="comments">
      <a class="muut" href="https://muut.com/i/sanctuary/comments" type="dynamic">Commenting</a>
   </div>
   <div class="messages">
      <span class="muut-messaging" data-forumname="evaluating-the-muutiny">Messages</span>
</div-->

<!-- END OF PAGE -->
<script src="//cdn.muut.com/1/moot.min.js"></script>
<script>
   $("#muut").muut({
      api: {
         key: '########', // my short api key from account settings page
         message: '<?php echo $message; ?>',
         timestamp: <?php echo $timestamp; ?>,
         signature: '<?php echo $signature; ?>',
         login_url: "http://sanctuaryinternational.com/community/index.php"
      }
   });
</script>

</body>
</html>

 
THANKS!!!!!!!

Link to comment
Share on other sites

So your index.php file - is this in ProcessWire and loading MUUT inside ProcessWire? Then you would have access to PW's current user.

There will be a conflict if this is how your code above works as your user array is called $user but in PW $user is an object containing the current user data.

As for whether there is an avatar field in ProcessWire - not out of the box, but everything in ProcessWire is custom fields so all you need to do is go to the admin, create an avatar field, assign it to the user template and you're sorted.

In summary, yes this looks correct:

"id" => $user->id,
"displayname" => $user->name,
"email" => $user->email,
"avatar" => $user->ICouldntFindWhatWouldGoHere

but you need to create an avatar field.

Also note that this does not magically give you a tie-in between registration/login systems between the systems from what I can tell. For example, in ProcessWire there is no default front-end user registration/login system (there are many topics and at least one module covering this though) so I see nothing above where MUUT would talk to ProcessWire and synchronise user data - it's actually a little odd that I can't find anything relating to this in their docs.

If instead it means MUUT just works with whatever ID ProcessWire passes to it then if you ever wanted to change CMS in future you would be in real trouble as the link between the two systems would be tenuous at best.

Link to comment
Share on other sites

In the future, please only post once. Now you just made unnecessary work for the moderators as they will delete your other posts.

@Beluga,

my apologies. i did not mean to waste anybody's time. i was just feeling overwhelmed & unsure of which category to post in for the best exposure in hopes of getting some help. so, in the future, if i'm again in such a position, what do you suggest i do? just pick on & stick to it? i did that but got no replies, thus the expansion. i don't want to waste anybody's time, but i also have time constraints. so what's the best route to take when i have an important, time sensitive (to me) question & can't figure out the best place to ask it?

THANKS!

@SyberKnight, Welcome to the ProcessWire Forums.

When you have some time, please review our Community Rules Guidelines.  It will detail what is permitted or not permitted within this community.

Thanks.

@cstevensjr,

thank you for the link. i just ran thru it & am not seeing anything that i've violated (barring the multiple requests on other categories as Beluga above pointed out). so if i'm missing something else, please let me know what that is. i don't want to break any rules.

THANKS!

Link to comment
Share on other sites

So your index.php file - is this in ProcessWire and loading MUUT inside ProcessWire? Then you would have access to PW's current user.

There will be a conflict if this is how your code above works as your user array is called $user but in PW $user is an object containing the current user data.

As for whether there is an avatar field in ProcessWire - not out of the box, but everything in ProcessWire is custom fields so all you need to do is go to the admin, create an avatar field, assign it to the user template and you're sorted.

In summary, yes this looks correct:

"id" => $user->id,
"displayname" => $user->name,
"email" => $user->email,
"avatar" => $user->ICouldntFindWhatWouldGoHere

but you need to create an avatar field.

Also note that this does not magically give you a tie-in between registration/login systems between the systems from what I can tell. For example, in ProcessWire there is no default front-end user registration/login system (there are many topics and at least one module covering this though) so I see nothing above where MUUT would talk to ProcessWire and synchronise user data - it's actually a little odd that I can't find anything relating to this in their docs.

If instead it means MUUT just works with whatever ID ProcessWire passes to it then if you ever wanted to change CMS in future you would be in real trouble as the link between the two systems would be tenuous at best.

@Pete,

thank you very much for your time & thoughtful reply!!!

yes, as i understand it, my ProcessWire index.php page would need to include all that code i put in my original post above.

as i'm reading some of the documentation & tutorials for PW, along with your comment above, i THINK i understand a little better about the avatar thing; feeling slightly confident i can figure that part out.

but this user->muut thing i'm still very concerned & confused about. 

this is apparently doable, as far as the muut people are concerned. they're first response to my post over there was to setup a WordPress site - but i just cannot bring myself to do such a horrible thing ;-)

not being a backend developer tho, can you speak more on what you mentioned regarding the "conflict" between the MUUT $user array & the PW $user object?

would there not be some sort of "adapter"-like code for such a situation?

and again, as far as i understand it thus far, the MUUT database does NOT sync with the PW database. i believe that the MUUT user db is REPLACED by the PW db if i use this "Federated ID" thing. so i would need to create a user registration/login form in PW.

lastly, your last sentence also concerns me. so if down the road, something happens that we need to shift away from PW, i wouldn't be able to take our user database & import it in to another system?

if you still feel up for the challenge of helping me understand this, here is my post/thread on the MUUT system...

https://muut.com/forum/#!/setting-up:noob-needing-federated-id-h

...the responses i've gotten there are still too vague for me, & as it continues, it just brings up more questions than answers.

 

here's the condensed sum of responses from the muut people in that link...

Basically Muut can work anywhere that you can generate the embed code serverside with user information included. Fed Ids are just embeds that have user information included, and a server generated signature so that they can't be forged. So there's very very few platforms Muut wouldn't work on for Fed Ids.

Basically it works like this. You have some site that user registers and authenticates on. When they view the page you have Muut embedded on (it needs to be embedded on a page that is dynamically generated on a server you control), you generate the embed code when they view the page using PHP or whatever the serverside language is. You add in the user information to the actual HTML generated that has the Muut embed.

When Muut loads in the browser it uses the information generated in the HTML to communicate with Muut, create the account if it's missing, or authenticate as that user if the account already exists.

You never directly communicate with Muut you simply generate the HTML page you embed Muut on from your server with the user information included.

Users will be able to log in with a muut account on muut.com/santuary. The way to stop that would be to use, “allow embedding with the secret key only,” setting. This setting turns off the muut.com page and muut will only appear on pages that use secret key embedding. So basically, Muut will only appear on the pages in which you've set up Fed ID.

Fed ID will only work on the page in which it's used.

If you use Fed ID to embed your forum on mysite.com/fedforum but then don't use it to embed your forum on mysite.com/forum — users will log in with Muut on both mysite.com/forum and your muut.com forum page. The only page they'll use Fed ID to login with is on mysite.com/fedforum.

THANKS AGAIN SO MUCH!!!

.peace.

Link to comment
Share on other sites

I read a bit more into MUUT and they just keep their database totally separate, so the users only exist in the CMS you choose. So basically, if you ever switch CMS, you would need to convert your user accounts to a new CMS and change the MUUT user array data to the new CMS' variable. Not a big deal actually.

What I meant by the $user conflict is you can't have two things called $user. $user is reserved in ProcessWire, so not sure what the options are there. There also doesn't seem to be anything in the index.php you posted above that actually does anything to do with MUUT, however now I say that I see the JS at the end that points to the URL of the MUUT forum, so maybe it's passing some variables via JS?

The reason I asked about index.php is because in ProcessWire you don't do any templating in the root index.php file. You edit the templates in /site/templates/ instead.

I think, whichever CMS you ultimately settle on to work with MUUT, you need to understand the CMS you're using and how it works first, so read some tutorials, look into the docs and watch the overview video (quite out of date now, but gives you an idea of how things work).

I'm also concerned when you say you have time constraints - what you're attempting to do isn't simple if you're not au fait with both systems, though top marks for diving in at the deep end and giving it a go :)

  • Like 2
Link to comment
Share on other sites

Wow, THANKS SO MUCH Pete!!! i REALLY appreciate your time & help...

I read a bit more into MUUT and they just keep their database totally separate, so the users only exist in the CMS you choose. So basically, if you ever switch CMS, you would need to convert your user accounts to a new CMS and change the MUUT user array data to the new CMS' variable. Not a big deal actually.

whew  :cool:

What I meant by the $user conflict is you can't have two things called $user. $user is reserved in ProcessWire, so not sure what the options are there. There also doesn't seem to be anything in the index.php you posted above that actually does anything to do with MUUT, however now I say that I see the JS at the end that points to the URL of the MUUT forum, so maybe it's passing some variables via JS?

yeah, i believe the forum "embed" is done via JS and the "Federated ID" is done via the PHP part.

The reason I asked about index.php is because in ProcessWire you don't do any templating in the root index.php file. You edit the templates in /site/templates/ instead.

i don't think it'll be a problem with regards to being in a directory. i have a non-CMS html/php page within a test directory and the embed & forum "works"; it's just using muut's user db instead of my own. so if i can get the "$user" thing changed on muut's end, then it should work - well, that's what i'm gathering anyways. i guess my next step is to ask them that question. unless you know of a safe way to change PW's $user to something else(?).

I think, whichever CMS you ultimately settle on to work with MUUT, you need to understand the CMS you're using and how it works first, so read some tutorials, look into the docs and watch the overview video (quite out of date now, but gives you an idea of how things work).

I'm also concerned when you say you have time constraints - what you're attempting to do isn't simple if you're not au fait with both systems, though top marks for diving in at the deep end and giving it a go :)

i agree, and i'm actually going thru a 2-part video tutorial i found on YouTube now, that's walking me thru how it works.

i also read a tutorial/post written for people who have used ModX in the past & are switching over to PW - that helped with getting my terminology straight in my head.

the time thing... well... it's one of those "as soon as possible, need it yesterday" kinda things, with a lot of pressure to get'r'done asap. but diving in where i have no floatation devices into unknown waters is sorta my personality, it guess; for better or worse ;-)

so, i'll report back here what i hear from muut about the $user thing - unless you have a way from PW's end first.

THANKS!!!!!

.peace.

Link to comment
Share on other sites

  • 2 weeks later...

@Pete,

hey, just wanted to follow-thru with an update & to mark this thread as solved.

i ended up having to put ProcessWire down - i was just banging my head up against too many stone walls. not being a php backend developer, i guess PW isn't for me; which sucks, cause i like it's concept & structure. but it requires more php knowledge than what i have (for now).

so i went back to something familiar... ModX... and still banged my head a lot these past few weeks, but finally got it figured out & working there.

if ever interested, it's posted @ http://forums.modx.com/thread/99335/need-help-with-php-connecting-muut-forum-to-modx#dis-post-537478

but thanks again for your time & efforts! it's MUCH appreciated.

.peace.:.jason.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...