Giter Site home page Giter Site logo

vipps-login-dotnet's Introduction

Vipps Log In for ASP.NET and Episerver

Please keep up to date with updates as soon as they happen.

We encourage you to create an issue here if you require assistance or run in to a problem.

Description

This repository contains the code to use Vipps Log In OpenIdConnect (OIDC) Authentication middleware in your ASP.NET application using OWIN. Information about the Vipps Log In API can be found here: https://github.com/vippsas/vipps-login-api

This repository consists of three NuGet packages:

  • Vipps.Login - OWIN Middleware that enables an application to use OpenIdConnect for authentication.
  • Vipps.Login.Episerver - Episerver code for Vipps Login
  • Vipps.Login.Episerver.Commerce - Episerver Commerce code for Vipps Login

Features

  • OWIN Middleware to support Vipps Login through OpenIdConnect
  • Library to simplify Episerver configuration and set up

How to get started?

Start by installing the NuGet packages:

For the OWIN middleware

  • Install-Package Vipps.Login

And for the Episerver extensions

  • Install-Package Vipps.Login.Episerver
  • Install-Package Vipps.Login.Episerver.Commerce

Get API keys for Vipps Log In API

Activate and set up Vipps Login: https://github.com/vippsas/vipps-login-api/blob/master/vipps-login-api-faq.md#how-can-i-activate-and-set-up-vipps-login

Configure a redirect URI to your site(s): https://{your-site}/vipps-login (replace {your-site} with your own host name, it can be localhost as well)

To use the VippsLoginConfig helper class, add the ClientId and the ClientSecret to the Web.Config AppSettings, as such:

<add key="VippsLogin:ClientId" value="..." />
<add key="VippsLogin:ClientSecret" value="..." />
<add key="VippsLogin:Authority" value="https://apitest.vipps.no/access-management-1.0/access" />

For production use

<add key="VippsLogin:Authority" value="https://api.vipps.no/access-management-1.0/access" />

See https://github.com/vippsas/vipps-login-api/blob/master/vipps-login-api.md#base-urls

Configuration

Now you can configure your ASP.NET or Episerver application:

Accessing Vipps user data

The Vipps UserInfo can be accessed by using the GetVippsUserInfo(IIdentity identity) method on IVippsLoginService, this will give you the most recent user info that was retrieved when the user logged in (cached, stored as claims on the identity).

public class AccountController : Controller
{
    private readonly IVippsLoginService _vippsLoginService;
    public AccountController(IVippsLoginService vippsLoginService)
    {
        _vippsLoginService = vippsLoginService;
    }

    public ActionResult Index()
    {
        var userInfo =  _vippsLoginService.GetVippsUserInfo(User.Identity)
        ...
    }
}

More info

Package maintainer

https://github.com/brianweet

Changelog

Changelog

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.