Giter Site home page Giter Site logo

golaravelsession's Introduction

Go Laravel Session

Build Status

Basic Decrypt Laravel's SessionID and Read Session Data support for golang.

Features

  • Decrypt SessionID (now for the default AES-256-CBC cipher only)
  • Read Session Data from php-serialized format

Purpose

  • golang websocket app combined with laravel app (authorize user)
  • other

Examples

  • GetSessionID
cookie := "eyJpdiI6IjVrTVVDSmlyb1FtN2NrbmlOTllOUkE9PSIsInZhbHVlIjoiUU9pbCtMTjhQQnQyamJ6ZE5qenVWanhuZktUcjBkOUVsWU5ibkhlWHJyc25DNnZYQlRrOWlFd01ObVJwam1yVUtNcGRUanV1aEJIWHBsYXNiZytNenc9PSIsIm1hYyI6ImMzYzVmMGE1NWY5ZjEzMzRjOTVkN2FlZGY2YzZhNDExOTVhZjUzMjYzZmE3OTE1ODIwYWYzNmY5ODQzYjIwOGEifQ=="
key := "base64:qsDvCdhT+JPXEBD3ys/XraOXVNpshsyElzJmtgnBqEI="

sessionID, _ := GetSessionID(cookie, key)
fmt.Println(sessionID)
//produces: RYodG5AekDidQCVLvs4fQIRAPSwarZV26U4shNVX
  • ParseSessionData

this is just wrapper usage of package github.com/yvasiyarov/php_session_decoder/php_serialize

sessionData := `a:5:{s:6:"_token";s:40:"eE5gVNqGSn6wneCJAzhtTMulPFwvOfDyZRSoVStA";s:3:"url";a:0:{}s:9:"_previous";a:1:{s:3:"url";s:29:"https://test.dev";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}s:52:"login_admin_59ba36addc2b2f9401580f014c7f58ea4e30989d";i:1;}`
session, _ := ParseSessionData(sessionData)
fmt.Println(session["_token"].(string))

golaravelsession's People

Contributors

chekun avatar jawshua avatar ricky-rick avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.