Hi there monks,

I've got a Dancer2 app logging in to azure using the Dancer2::plugin::auth::oauth. Works like a dream. Gives me a session with all sorts of information about the user. In YAML for now, so I can inspect what I have.

Among all that information are the roles the user has. Something you can configure in the app registration on Azure. Works! I can see the information in Vim. Looks something like this in the YAML file:

oauth: azuread: login_info: roles: - Medewerkers - etm

The file is a lot longer offcourse, deleted all that.

As far as I know session->read() loads in the session (from whatever format) into a hash. When I do:

my $session_data = session->read('oauth'); say "Roles:"; print Dumper $$session_data{azuread}{login_info}{roles};

I get on the console:

Roles: $VAR1 = [ 'Medewerkers', 'etm' ];

To me it looks like I'm dumping an array reference. So the session hash contains arrays?

But no matter what I do (and I'm sure I did not do enough) I cannot access the individual values of that array. I kinda expected that something like print $$session_data{azuread}{login_info}{roles}[0] would work. Tried it in all sorts of variations. It confuses me to the bone.

What am I doing wrong? What is the way to read those individual values?

Peter


In reply to Reading session data by PeterKaagman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.